| 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.model.ApiResponse; | 
| import com.doumee.core.model.PageWrap; | 
| import com.doumee.core.model.PageData; | 
| import com.doumee.dao.business.model.BaseCategory; | 
| import com.doumee.dao.business.model.Category; | 
| import com.doumee.dao.business.model.dto.BaseCategoryRequest; | 
| import com.doumee.service.business.BaseCategoryService; | 
| import io.swagger.annotations.Api; | 
| import io.swagger.annotations.ApiOperation; | 
| 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; | 
|   | 
| /** | 
|  * @author 江蹄蹄 | 
|  * @date 2023/09/07 11:41 | 
|  */ | 
| @Api(tags = "素材库-品类信息表") | 
| @RestController | 
| @RequestMapping("/business/baseCategory") | 
| public class BaseCategoryController extends BaseController { | 
|   | 
|     @Autowired | 
|     private BaseCategoryService baseCategoryService; | 
|   | 
|     @PreventRepeat | 
|     @ApiOperation("新建") | 
|     @PostMapping("/create") | 
| //    @RequiresPermissions("business:basecategory:create") | 
|     public ApiResponse create(@RequestBody BaseCategoryRequest baseCategory) { | 
|         return ApiResponse.success(baseCategoryService.create(baseCategory)); | 
|     } | 
|   | 
|     @ApiOperation("根据ID删除") | 
|     @GetMapping("/delete/{id}") | 
|     @RequiresPermissions("business:basecategory:delete") | 
|     public ApiResponse deleteById(@PathVariable Integer id) { | 
|         baseCategoryService.deleteById(id); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("批量删除") | 
|     @GetMapping("/delete/batch") | 
|     @RequiresPermissions("business:basecategory: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)); | 
|         } | 
|         baseCategoryService.deleteByIdInBatch(idList); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation(value = "根据ID修改-列表属性修改") | 
|     @PostMapping("/updateByIdOrigin") | 
|     @RequiresPermissions("business:basecategory:update") | 
|     public ApiResponse updateById(@RequestBody BaseCategory baseCategory) { | 
|         baseCategoryService.updateById(baseCategory); | 
|         return ApiResponse.success(null); | 
|     } | 
|     @ApiOperation("修改状态") | 
|     @PostMapping("/updateDisableById") | 
|     @RequiresPermissions("business:basecategory:update") | 
|     public ApiResponse updateDisableById(@RequestBody BaseCategory category) { | 
|         baseCategoryService.updateDisableById(category); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     /** | 
|      * 主键更新 | 
|      * | 
|      * @param baseCategory 实体对象 | 
|      */ | 
|     @ApiOperation("根据ID修改-编辑修改") | 
|     @PostMapping("/updateById") | 
|     @RequiresPermissions("business:basecategory:update") | 
|     public ApiResponse update(@RequestBody  BaseCategoryRequest baseCategory){ | 
|         baseCategoryService.update(baseCategory); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("分页查询`") | 
|     @PostMapping("/page") | 
|     @RequiresPermissions("business:basecategory:query") | 
|     public ApiResponse<PageData<BaseCategory>> findPage (@RequestBody PageWrap<BaseCategory> pageWrap) { | 
|         return ApiResponse.success(baseCategoryService.findPage(pageWrap)); | 
|     } | 
|   | 
|     @ApiOperation("导出Excel") | 
|     @PostMapping("/exportExcel") | 
|     @RequiresPermissions("business:basecategory:exportExcel") | 
|     public void exportExcel (@RequestBody PageWrap<BaseCategory> pageWrap, HttpServletResponse response) { | 
|         ExcelExporter.build(BaseCategory.class).export(baseCategoryService.findPage(pageWrap).getRecords(), "素材库-品类信息表", response); | 
|     } | 
|   | 
|     @ApiOperation("根据ID查询") | 
|     @GetMapping("/{id}") | 
| //    @RequiresPermissions("business:basecategory:query") | 
|     public ApiResponse findById(@PathVariable Integer id) { | 
|         return ApiResponse.success(baseCategoryService.findById(id)); | 
|     } | 
|   | 
|     /** | 
|      * 条件查询 | 
|      * | 
|      * @param baseCategory 实体对象 | 
|      * @return List<BaseCategory> | 
|      */ | 
|     @ApiOperation("根据ID查询") | 
|     @PostMapping("/findList") | 
|     public ApiResponse<List<BaseCategory>> findList(@RequestBody BaseCategory baseCategory){ | 
|         return ApiResponse.success(baseCategoryService.findList(baseCategory)); | 
|     } | 
| } |