| package doumeemes.api.ext; | 
|   | 
| import doumeemes.api.BaseController; | 
| import doumeemes.core.annotation.excel.ExcelExporter; | 
| import doumeemes.core.annotation.pr.PreventRepeat; | 
| import doumeemes.core.model.ApiResponse; | 
| import doumeemes.core.model.PageData; | 
| import doumeemes.core.model.PageWrap; | 
| import doumeemes.core.utils.Constants; | 
| import doumeemes.dao.business.model.Category; | 
| import doumeemes.dao.business.model.CategoryUnion; | 
| import doumeemes.dao.ext.dto.QueryCategoryUnionExtDTO; | 
| import doumeemes.dao.ext.vo.CategoryUnionExtListVO; | 
| import doumeemes.service.business.CategoryService; | 
| import doumeemes.service.business.CategoryUnionService; | 
| import doumeemes.service.ext.CategoryUnionExtService; | 
| import io.swagger.annotations.Api; | 
| import io.swagger.annotations.ApiImplicitParam; | 
| 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 2022/04/27 16:15 | 
|  */ | 
| @RestController | 
| @RequestMapping("/ext/categoryUnionExt") | 
| @Api(tags = "分类组合信息接口") | 
| public class CategoryUnionExtController extends BaseController { | 
|   | 
|     @Autowired | 
|     private CategoryUnionExtService categoryUnionExtService; | 
|      | 
|     @Autowired | 
|     private CategoryUnionService categoryUnionService; | 
|   | 
|     @Autowired | 
|     private CategoryService categoryService; | 
|   | 
|   | 
|     @PreventRepeat | 
|     @ApiOperation("新建") | 
|     @PostMapping("/create") | 
|     @RequiresPermissions("ext:categoryunionext:create") | 
|     public ApiResponse create(@RequestBody CategoryUnion categoryUnion) { | 
|         return categoryUnionService.insertData(categoryUnion); | 
|     } | 
|   | 
|     @ApiOperation("根据ID删除") | 
|     @ApiImplicitParam(value = "主键id", name = "id", paramType = "query", dataType = "Integer") | 
|     @GetMapping("/delete/{id}") | 
|     @RequiresPermissions("ext:categoryunionext:delete") | 
|     public ApiResponse deleteById(@PathVariable Integer id) { | 
|   | 
|         CategoryUnion query=  categoryUnionService.findById(id); | 
|         query.setDeleted(Constants.ONE); | 
|         categoryUnionService.updateById(query); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("批量删除") | 
|     @ApiImplicitParam(value = "主键ids", name = "ids", paramType = "query", dataType = "String") | 
|     @GetMapping("/delete/batch") | 
|     @RequiresPermissions("ext:categoryunionext:delete") | 
|     public ApiResponse deleteByIds(@RequestParam String ids) { | 
|         String [] idArray = ids.split(","); | 
|         List<CategoryUnion> idList = new ArrayList<>(); | 
|         for (String id : idArray) { | 
|             CategoryUnion query=  categoryUnionService.findById(Integer.valueOf(id)); | 
|             query.setDeleted(Constants.ONE); | 
|             idList.add(query); | 
|         } | 
|         categoryUnionService.updateByIdInBatch(idList); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("根据ID修改") | 
|     @PostMapping("/updateById") | 
|     @RequiresPermissions("ext:categoryunionext:update") | 
|     public ApiResponse updateById(@RequestBody CategoryUnion categoryUnion) { | 
|   | 
|         return  categoryUnionService.editById(categoryUnion); | 
|     } | 
|   | 
|     @ApiOperation("分页查询") | 
|     @PostMapping("/page") | 
|     @RequiresPermissions("ext:categoryunionext:query") | 
|     public ApiResponse<PageData<CategoryUnionExtListVO>> findPage (@RequestBody PageWrap<QueryCategoryUnionExtDTO> pageWrap) { | 
|         pageWrap.getModel().setDeleted(Constants.ZERO); | 
|         pageWrap.getModel().setRootDepartId(getLoginUser().getRootDepartment().getId()); | 
|         return ApiResponse.success(categoryUnionExtService.findPage(pageWrap)); | 
|     } | 
|   | 
|     @ApiOperation("导出Excel") | 
|     @PostMapping("/exportExcel") | 
|     @RequiresPermissions("ext:categoryunionext:exportExcel") | 
|     public void exportExcel (@RequestBody PageWrap<QueryCategoryUnionExtDTO> pageWrap, HttpServletResponse response) { | 
|         ExcelExporter.build(CategoryUnionExtListVO.class).export(categoryUnionExtService.findPage(pageWrap).getRecords(), "分类组合信息", response); | 
|     } | 
|   | 
|     @ApiOperation("根据ID查询") | 
|     @GetMapping("/{id}") | 
|     @RequiresPermissions("ext:categoryunionext:query") | 
|     public ApiResponse findById(@PathVariable Integer id) { | 
|         CategoryUnion categoryUnion=  categoryUnionService.findById(id); | 
|   | 
|         Category category= categoryService.findById(categoryUnion.getCateBigId()); | 
|         Category category1= categoryService.findById(categoryUnion.getCateMiddleId()); | 
|         Category category2= categoryService.findById(categoryUnion.getCateSmallId()); | 
|         categoryUnion.setCateType(category.getCateType()); | 
|         String bname=category!=null?category.getName():""; | 
|         String mname=category1!=null?"-"+category1.getName():""; | 
|         String sname=category2!=null?"-"+category2.getName():""; | 
|         categoryUnion.setCombinationName(bname+mname+sname); | 
|         return ApiResponse.success(categoryUnion); | 
|     } | 
|   | 
|     @ApiOperation("查询所有的") | 
|     @PostMapping("/checkAllList") | 
|     public ApiResponse<List<CategoryUnionExtListVO>> checkAllList (@RequestBody QueryCategoryUnionExtDTO pageWrap) { | 
|         pageWrap.setDeleted(Constants.ZERO); | 
|         pageWrap.setRootDepartId(getLoginUser().getRootDepartment().getId()); | 
|         return ApiResponse.success(categoryUnionExtService.checkAllList(pageWrap)); | 
|     } | 
|   | 
|   | 
|     @ApiOperation("申请单,返工返修申请不良原因") | 
|     @GetMapping("/checkFGFXList") | 
|     public ApiResponse<List<CategoryUnionExtListVO>> checkFGFXList (@RequestParam String applianceids) { | 
|   | 
|         return ApiResponse.success(categoryUnionExtService.checkFGFXList(applianceids)); | 
|     } | 
|   | 
| } |