package com.cdf.controller.api; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.cdf.common.ResultData; import com.cdf.entity.Shop; import com.cdf.entity.Video; import com.cdf.service.IShopCategoryService; import com.cdf.service.IShopService; import com.cdf.service.IVideoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.List; @RestController @RequestMapping("/api") public class ShopApiController { @Autowired private IShopCategoryService shopCategoryService; @Autowired private IShopService shopService; @GetMapping("/getShopCategory") public ResultData getShopCategory(){ return ResultData.ok(shopCategoryService.list()); } @GetMapping("/getShopByCategory") public ResultData getShopByCategory(@RequestParam(required = false) Integer categoryId){ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); if(categoryId != null){ wrapper.eq(Shop::getCategoryId,categoryId); } wrapper.orderByAsc(Shop::getSort); wrapper.orderByDesc(Shop::getCreateTime); return ResultData.ok(shopService.list(wrapper)); } }