Pu Zhibing
2024-12-17 d53c16a12e612a95dc8f6fb248e3669cbc441eb4
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsShopController.java
@@ -1,8 +1,20 @@
package com.ruoyi.other.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.other.api.domain.GoodsShop;
import com.ruoyi.other.api.vo.GetGoodsShopByGoodsIds;
import com.ruoyi.other.service.GoodsShopService;
import com.ruoyi.other.vo.ShopGoodsList;
import com.ruoyi.other.vo.ShopGoodsListVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
 * <p>
@@ -14,7 +26,53 @@
 */
@RestController
@RequestMapping("/goods-shop")
public class GoodsShopController {
public class GoodsShopController extends BaseController {
   @Resource
   private GoodsShopService goodsShopService;
   /**
    * 获取商品门店关系数据
    * @param goodsShop
    * @return
    */
   @ResponseBody
   @PostMapping("/getGoodsShop")
   public R<GoodsShop> getGoodsShop(@RequestBody GoodsShop goodsShop){
      GoodsShop one = goodsShopService.getOne(new LambdaQueryWrapper<GoodsShop>().eq(GoodsShop::getGoodsId, goodsShop.getGoodsId())
            .eq(GoodsShop::getShopId, goodsShop.getShopId()));
      return R.ok(one);
   }
   /**
    * 根据商品id集合和门店id查询数据
    * @param goodsIds
    * @return
    */
   @ResponseBody
   @PostMapping("/getGoodsShopByGoodsIds")
   public R<List<GoodsShop>> getGoodsShopByGoodsIds(@RequestBody GetGoodsShopByGoodsIds goodsIds) {
      List<GoodsShop> list = goodsShopService.list(new LambdaQueryWrapper<GoodsShop>()
            .eq(goodsIds.getShopId() != null,GoodsShop::getShopId, goodsIds.getShopId())
            .in(goodsIds.getGoodsIds() !=null ,GoodsShop::getGoodsId, goodsIds.getGoodsIds()));
      return R.ok(list);
   }
   @ResponseBody
   @GetMapping("/getShopGoodsList")
   @ApiOperation(value = "获取商品管理列表", tags = {"门店后台-商品管理"})
   public TableDataInfo<ShopGoodsList> getShopGoodsList(ShopGoodsListVo shopGoodsListVo){
      startPage();
      List<ShopGoodsList> shopGoodsList = goodsShopService.getShopGoodsList(shopGoodsListVo);
      return getDataTable(shopGoodsList);
   }
}