|  |  | 
 |  |  | import com.doumee.api.BaseController; | 
 |  |  | import com.doumee.core.annotation.excel.ExcelExporter; | 
 |  |  | import com.doumee.core.annotation.pr.PreventRepeat; | 
 |  |  | import com.doumee.core.model.LoginUserInfo; | 
 |  |  | import com.doumee.core.model.PageData; | 
 |  |  | import com.doumee.core.model.PageWrap; | 
 |  |  | import com.doumee.dao.business.model.Goods; | 
 |  |  | import com.doumee.dao.business.model.dto.BatchDisableDTO; | 
 |  |  | import com.doumee.dao.business.model.dto.GoodCreatePlatRequest; | 
 |  |  | import com.doumee.dao.business.model.dto.GoodsRequest; | 
 |  |  | import com.doumee.service.CateParamSelectService; | 
 |  |  | import com.doumee.service.business.GoodsService; | 
 |  |  | import io.swagger.annotations.*; | 
 |  |  | import lombok.extern.java.Log; | 
 |  |  | import org.apache.shiro.SecurityUtils; | 
 |  |  | import org.apache.shiro.authz.annotation.RequiresPermissions; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.web.bind.annotation.*; | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private GoodsService goodsService; | 
 |  |  |     @Autowired | 
 |  |  |     private CateParamSelectService cateParamSelectService; | 
 |  |  |  | 
 |  |  |     @PreventRepeat | 
 |  |  |     @ApiOperation("新建") | 
 |  |  | 
 |  |  |         return ApiResponse.success(goodsService.create(goods)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @PreventRepeat | 
 |  |  |     @ApiOperation("企业新建商品") | 
 |  |  |     @PostMapping("/companyCreate") | 
 |  |  | //    @RequiresPermissions("business:goods:create") | 
 |  |  |     public ApiResponse companyCreate(@RequestBody Goods goods) { | 
 |  |  |         goodsService.companyCreate(goods); | 
 |  |  |         cateParamSelectService.dealCateParamSelect(); | 
 |  |  |         return ApiResponse.success("操作成功"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PreventRepeat | 
 |  |  |     @ApiOperation("从平台选择商品") | 
 |  |  |     @PostMapping("/createPlat") | 
 |  |  |     @RequiresPermissions("business:goods:create") | 
 |  |  |     public ApiResponse createPlat(@RequestBody GoodCreatePlatRequest param) { | 
 |  |  |         goodsService.createPlat(param); | 
 |  |  |         cateParamSelectService.dealCateParamSelect(); | 
 |  |  |         return ApiResponse.success("操作成功"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @ApiOperation("根据ID删除") | 
 |  |  |     @GetMapping("/delete/{id}") | 
 |  |  |     @RequiresPermissions("business:goods:delete") | 
 |  |  |     public ApiResponse deleteById(@PathVariable Integer id) { | 
 |  |  |         goodsService.deleteById(id); | 
 |  |  |         cateParamSelectService.dealCateParamSelect(); | 
 |  |  |         return ApiResponse.success(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |             idList.add(Integer.valueOf(id)); | 
 |  |  |         } | 
 |  |  |         goodsService.deleteByIdInBatch(idList); | 
 |  |  |         cateParamSelectService.dealCateParamSelect(); | 
 |  |  |         return ApiResponse.success(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |         return ApiResponse.success(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @ApiOperation("企业根据ID修改") | 
 |  |  |     @PostMapping("/companyUpdateById") | 
 |  |  |     @RequiresPermissions("business:goods:update") | 
 |  |  |     public ApiResponse companyUpdateById(@RequestBody Goods goods) { | 
 |  |  |         goodsService.companyUpdateById(goods); | 
 |  |  |         cateParamSelectService.dealCateParamSelect(); | 
 |  |  |         return ApiResponse.success(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @ApiOperation("分页查询") | 
 |  |  |     @PostMapping("/page") | 
 |  |  |     @RequiresPermissions("business:goods:query") | 
 |  |  |     public ApiResponse<PageData<Goods>> findPage (@RequestBody PageWrap<Goods> pageWrap) { | 
 |  |  |         LoginUserInfo loginUserInfo = this.getLoginUser(); | 
 |  |  |         pageWrap.getModel().setCompanyId(loginUserInfo.getCompanyId()); | 
 |  |  |         return ApiResponse.success(goodsService.findPage(pageWrap)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |     }) | 
 |  |  | //    @RequiresPermissions("business:goods:create") | 
 |  |  |     public ApiResponse<Integer> importExcel (@ApiParam(value = "file") MultipartFile file) { | 
 |  |  |         return ApiResponse.success(goodsService.importBatch(file)); | 
 |  |  |         Integer val = goodsService.importBatch(file); | 
 |  |  |         cateParamSelectService.dealCateParamSelect(); | 
 |  |  |         return ApiResponse.success(val); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @ApiOperation("修改状态") | 
 |  |  |     @PostMapping("/updateDisableById") | 
 |  |  |     @RequiresPermissions("business:category:update") | 
 |  |  |     @RequiresPermissions("business:goods:update") | 
 |  |  |     public ApiResponse updateDisableById(@RequestBody Goods goods) { | 
 |  |  |         goodsService.updateDisableById(goods); | 
 |  |  |         return ApiResponse.success(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @ApiOperation("批量修改状态") | 
 |  |  |     @PostMapping("/batchUpdateDisableById") | 
 |  |  |     @RequiresPermissions("business:goods:update") | 
 |  |  |     public ApiResponse<String> batchUpdateDisableById(@RequestBody BatchDisableDTO batchDisableDTO) { | 
 |  |  |         return ApiResponse.success(goodsService.batchUpdateDisableById(batchDisableDTO)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @ApiOperation("列表 - H5") | 
 |  |  |     @PostMapping("/list") | 
 |  |  |     public ApiResponse<List<Goods>> findList (@RequestBody Goods goods) { | 
 |  |  |         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
 |  |  |         goods.setCompanyId(user.getCompanyId()); | 
 |  |  |         return ApiResponse.success(goodsService.findList(goods)); | 
 |  |  |     } | 
 |  |  |  |