有店铺id查详情 没有查所有
@RestController @RequestMapping("/api/shops") public class ShopController { @Autowired private ShopService shopService; /** * 有 shopId -> 查单个店铺详情 * 无 shopId -> 查所有店铺信息 */ @GetMapping public Result getShops(@RequestParam(required = false) Long shopId) { if (shopId != null) { // 查单个店铺 ShopVO shop = shopService.getShopById(shopId); return Result.success(shop); } else { // 查所有店铺 List<ShopVO> shopList = shopService.getAllShops(); return Result.success(shopList); } } }