xuhy
2024-08-31 80206642e27a501ab2f2725d4104c7579698793d
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TGoodsController.java
@@ -3,9 +3,9 @@
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.domain.TGoods;
import com.ruoyi.system.query.TGoodsQuery;
import com.ruoyi.system.service.TGoodsService;
import com.ruoyi.system.service.TGoodsService;
import com.ruoyi.system.vo.TGoodsVO;
import io.swagger.annotations.Api;
@@ -29,10 +29,12 @@
public class TGoodsController {
    private final TGoodsService goodsService;
    private final TokenService tokenService;
    @Autowired
    public TGoodsController(TGoodsService goodsService) {
    public TGoodsController(TGoodsService goodsService, TokenService tokenService) {
        this.goodsService = goodsService;
        this.tokenService = tokenService;
    }
    /**
@@ -41,6 +43,7 @@
    @ApiOperation( value = "查询商品管理分页列表")
    @PostMapping(value = "/pageList")
    public AjaxResult<PageInfo<TGoodsVO>> pageList(@RequestBody TGoodsQuery query) {
        query.setShopId(tokenService.getLoginUser().getObjectId());
        return AjaxResult.success(goodsService.pageList(query));
    }
@@ -50,6 +53,7 @@
    @ApiOperation( value = "添加商品管理")
    @PostMapping(value = "/add")
    public AjaxResult<Boolean> add(@RequestBody TGoods dto) {
        dto.setShopId(tokenService.getLoginUser().getObjectId());
        return AjaxResult.success(goodsService.save(dto));
    }