| package com.doumee.api.business; | 
|   | 
| import com.doumee.api.BaseController; | 
| import com.doumee.core.annotation.excel.ExcelExporter; | 
| import com.doumee.core.annotation.pr.PreventRepeat; | 
| import com.doumee.core.constants.ResponseStatus; | 
| import com.doumee.core.exception.BusinessException; | 
| import com.doumee.core.model.ApiResponse; | 
| import com.doumee.core.model.LoginUserInfo; | 
| import com.doumee.core.model.PageData; | 
| import com.doumee.core.model.PageWrap; | 
| import com.doumee.core.utils.Constants; | 
| import com.doumee.dao.business.model.BaseCateParam; | 
| import com.doumee.dao.business.model.BaseCategory; | 
| import com.doumee.dao.business.model.Category; | 
| import com.doumee.service.business.BaseCateParamService; | 
| import com.doumee.service.business.BaseCategoryService; | 
| import com.doumee.service.business.CategoryService; | 
| import io.swagger.annotations.Api; | 
| import io.swagger.annotations.ApiOperation; | 
| import lombok.extern.java.Log; | 
| import org.apache.shiro.authz.annotation.RequiresPermissions; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.web.bind.annotation.*; | 
|   | 
| import javax.servlet.http.HttpServletResponse; | 
| import java.util.ArrayList; | 
| import java.util.List; | 
| import java.util.Objects; | 
|   | 
| /** | 
|  * @author 江蹄蹄 | 
|  * @date 2023/05/12 13:58 | 
|  */ | 
| @Api(tags = "品类信息表") | 
| @RestController | 
| @RequestMapping("/business/category") | 
| public class CategoryController extends BaseController { | 
|   | 
|     @Autowired | 
|     private CategoryService categoryService; | 
|   | 
|     @Autowired | 
|     private BaseCategoryService baseCategoryService; | 
|   | 
|     @Autowired | 
|     private BaseCateParamService baseCateParamService; | 
|   | 
|     @PreventRepeat | 
|     @ApiOperation("新建") | 
|     @PostMapping("/create") | 
|     @RequiresPermissions("business:category:create") | 
|     public ApiResponse create(@RequestBody Category category) { | 
|         return ApiResponse.success(categoryService.create(category)); | 
|     } | 
|   | 
|   | 
|     @PreventRepeat | 
|     @ApiOperation("企业新建分类") | 
|     @PostMapping("/companyCreate") | 
|     @RequiresPermissions("business:category:create") | 
|     public ApiResponse companyCreate(@RequestBody Category category) { | 
|         return ApiResponse.success(categoryService.companyCreate(category)); | 
|     } | 
|   | 
|     @ApiOperation("根据ID删除") | 
|     @GetMapping("/delete/{id}") | 
|     @RequiresPermissions("business:category:delete") | 
|     public ApiResponse deleteById(@PathVariable Integer id) { | 
|         categoryService.deleteById(id); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("批量删除") | 
|     @GetMapping("/delete/batch") | 
|     @RequiresPermissions("business:category:delete") | 
|     public ApiResponse deleteByIdInBatch(@RequestParam String ids) { | 
|         String [] idArray = ids.split(","); | 
|         List<Integer> idList = new ArrayList<>(); | 
|         for (String id : idArray) { | 
|             idList.add(Integer.valueOf(id)); | 
|         } | 
|         categoryService.deleteByIdInBatch(idList); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("根据ID修改") | 
|     @PostMapping("/updateById") | 
|     @RequiresPermissions("business:category:update") | 
|     public ApiResponse updateById(@RequestBody Category category) { | 
|         categoryService.updateById(category); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("企业根据ID修改") | 
|     @PostMapping("/companyUpdateById") | 
|     @RequiresPermissions("business:category:update") | 
|     public ApiResponse companyUpdateById(@RequestBody Category category) { | 
|         categoryService.companyUpdateById(category); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("分页查询") | 
|     @PostMapping("/page") | 
|     @RequiresPermissions("business:category:query") | 
|     public ApiResponse<PageData<Category>> findPage (@RequestBody PageWrap<Category> pageWrap) { | 
|         LoginUserInfo loginUserInfo = this.getLoginUser(); | 
|         pageWrap.getModel().setCompanyId(loginUserInfo.getCompanyId()); | 
|         return ApiResponse.success(categoryService.findPage(pageWrap)); | 
|     } | 
|   | 
|     @ApiOperation("导出Excel") | 
|     @PostMapping("/exportExcel") | 
|     @RequiresPermissions("business:category:exportExcel") | 
|     public void exportExcel (@RequestBody PageWrap<Category> pageWrap, HttpServletResponse response) { | 
|         ExcelExporter.build(Category.class).export(categoryService.findPage(pageWrap).getRecords(), "品类信息表", response); | 
|     } | 
|   | 
|     @ApiOperation("根据ID查询") | 
|     @GetMapping("/{id}") | 
|     @RequiresPermissions("business:category:query") | 
|     public ApiResponse findById(@PathVariable Integer id) { | 
|         return ApiResponse.success(categoryService.findById(id)); | 
|     } | 
|   | 
|     @ApiOperation("修改状态") | 
|     @PostMapping("/updateDisableById") | 
|     @RequiresPermissions("business:category:update") | 
|     public ApiResponse updateDisableById(@RequestBody Category category) { | 
|         categoryService.updateDisableById(category); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("列表") | 
|     @PostMapping("/list") | 
|     public ApiResponse<List<Category>> findList (@RequestBody Category category) { | 
|         return ApiResponse.success(categoryService.findList(category)); | 
|     } | 
|   | 
|     @ApiOperation("列表 - 商品选择") | 
|     @GetMapping("/findListForGoodsId") | 
|     public ApiResponse<List<Category>> findListForGoodsId (Integer goodsId) { | 
|         return ApiResponse.success(categoryService.findListForGoods(goodsId)); | 
|     } | 
|   | 
|   | 
|     @ApiOperation("企业选择分类列表 - H5") | 
|     @PostMapping("/companyFindList") | 
|     public ApiResponse<List<Category>> companyFindList (@RequestBody Category category) { | 
|         return ApiResponse.success(categoryService.companyFindList(category)); | 
|     } | 
|   | 
|     @ApiOperation("平台分类列表") | 
|     @PostMapping("/baseCategoryList") | 
|     public ApiResponse<List<BaseCategory>> baseCategoryList () { | 
|         BaseCategory baseCategory = new BaseCategory(); | 
|         baseCategory.setIsdeleted(Constants.ZERO); | 
|         baseCategory.setStatus(Constants.ZERO); | 
|         baseCategoryService.findList(baseCategory); | 
|         List list = baseCategoryService.findList(baseCategory); | 
|         return ApiResponse.success(list); | 
|     } | 
|   | 
|     @ApiOperation("平台分类详情") | 
|     @GetMapping("/baseCategoryDetail") | 
|     public ApiResponse<BaseCategory> baseCategoryDetail (Integer baseCategoryId) { | 
|   | 
|         BaseCategory baseCategory = baseCategoryService.findById(baseCategoryId); | 
|         if(Objects.isNull(baseCategory)){ | 
|             throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|         } | 
|         BaseCateParam baseCateParam = new BaseCateParam(); | 
|         baseCateParam.setIsdeleted(Constants.ZERO); | 
|         baseCateParam.setStatus(Constants.ZERO); | 
|         baseCateParam.setCategoryId(baseCategoryId); | 
|         baseCategory.setBaseCateParamList( | 
|                 baseCateParamService.findList(baseCateParam) | 
|         ); | 
|         return ApiResponse.success(baseCategory); | 
|     } | 
|   | 
|     @ApiOperation("列表 - SaaSH5") | 
|     @PostMapping("/saasList") | 
|     public ApiResponse<List<Category>> saasList (@RequestBody Category category) { | 
|         return ApiResponse.success(categoryService.findListSaaS(category)); | 
|     } | 
|   | 
| } |