| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | |
| | | /** |
| | | /** |
| | | * @Description: 刀具信息 |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-07-28 |
| | | * @Date: 2025-07-28 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Api(tags="刀具信息") |
| | | @Api(tags = "刀具信息") |
| | | @RestController |
| | | @RequestMapping("/cms/cuttingTool") |
| | | @Slf4j |
| | | public class CuttingToolController extends JeecgController<CuttingTool, ICuttingToolService> { |
| | | @Autowired |
| | | private ICuttingToolService cuttingToolService; |
| | | @Autowired |
| | | private ICuttingToolService cuttingToolService; |
| | | |
| | | @Autowired |
| | | private ICuttingPropertiesService cuttingPropertiesService; |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | | * |
| | | * @param cuttingTool |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "刀具信息-分页列表查询") |
| | | @ApiOperation(value="刀具信息-分页列表查询", notes="刀具信息-分页列表查询") |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<CuttingTool>> queryPageList(CuttingTool cuttingTool, |
| | | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
| | | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | QueryWrapper<CuttingTool> queryWrapper = QueryGenerator.initQueryWrapper(cuttingTool, req.getParameterMap()); |
| | | Page<CuttingTool> page = new Page<CuttingTool>(pageNo, pageSize); |
| | | IPage<CuttingTool> pageList = cuttingToolService.page(page, queryWrapper); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param cuttingTool |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具信息-添加") |
| | | @ApiOperation(value="刀具信息-添加", notes="刀具信息-添加") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_tool:add") |
| | | @PostMapping(value = "/add") |
| | | public Result<String> add(@RequestBody CuttingTool cuttingTool) { |
| | | cuttingToolService.save(cuttingTool); |
| | | List<CuttingProperties> cuttingPropertiesList = cuttingTool.getCuttingPropertiesList(); |
| | | for (CuttingProperties cuttingProperties : cuttingPropertiesList) { |
| | | cuttingProperties.setCuttingId(cuttingTool.getId()); |
| | | cuttingPropertiesService.save(cuttingProperties); |
| | | } |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 编辑 |
| | | * |
| | | * @param cuttingTool |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具信息-编辑") |
| | | @ApiOperation(value="刀具信息-编辑", notes="刀具信息-编辑") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_tool:edit") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | public Result<String> edit(@RequestBody CuttingTool cuttingTool) { |
| | | cuttingToolService.saveOrUpdate(cuttingTool); |
| | | List<String> deletePropertiesIds = cuttingTool.getDeletePropertiesIds(); |
| | | if (deletePropertiesIds != null) { |
| | | for (String deletePropertiesId : deletePropertiesIds) { |
| | | cuttingPropertiesService.removeById(deletePropertiesId); |
| | | } |
| | | } |
| | | List<CuttingProperties> cuttingPropertiesList = cuttingTool.getCuttingPropertiesList(); |
| | | for (CuttingProperties cuttingProperties : cuttingPropertiesList) { |
| | | cuttingProperties.setCuttingId(cuttingTool.getId()); |
| | | cuttingPropertiesService.saveOrUpdate(cuttingProperties); |
| | | } |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具信息-通过id删除") |
| | | @ApiOperation(value="刀具信息-通过id删除", notes="刀具信息-通过id删除") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_tool:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name="id",required=true) String id) { |
| | | cuttingToolService.removeById(id); |
| | | cuttingPropertiesService.remove(new LambdaQueryWrapper<CuttingProperties>().eq(CuttingProperties::getCuttingId, id)); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具信息-批量删除") |
| | | @ApiOperation(value="刀具信息-批量删除", notes="刀具信息-批量删除") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_tool:deleteBatch") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { |
| | | this.cuttingToolService.removeByIds(Arrays.asList(ids.split(","))); |
| | | return Result.OK("批量删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id查询 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "刀具信息-通过id查询") |
| | | @ApiOperation(value="刀具信息-通过id查询", notes="刀具信息-通过id查询") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<CuttingTool> queryById(@RequestParam(name="id",required=true) String id) { |
| | | CuttingTool cuttingTool = cuttingToolService.getById(id); |
| | | if(cuttingTool==null) { |
| | | return Result.error("未找到对应数据"); |
| | | } |
| | | return Result.OK(cuttingTool); |
| | | } |
| | | @Autowired |
| | | private ICuttingPropertiesService cuttingPropertiesService; |
| | | |
| | | /** |
| | | * 导出excel |
| | | * |
| | | * @param request |
| | | * @param cuttingTool |
| | | */ |
| | | * 分页列表查询 |
| | | * |
| | | * @param cuttingTool |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "刀具信息-分页列表查询") |
| | | @ApiOperation(value = "刀具信息-分页列表查询", notes = "刀具信息-分页列表查询") |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<CuttingTool>> queryPageList(CuttingTool cuttingTool, |
| | | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | QueryWrapper<CuttingTool> queryWrapper = QueryGenerator.initQueryWrapper(cuttingTool, req.getParameterMap()); |
| | | Page<CuttingTool> page = new Page<CuttingTool>(pageNo, pageSize); |
| | | IPage<CuttingTool> pageList = cuttingToolService.page(page, queryWrapper); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param cuttingTool |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具信息-添加") |
| | | @ApiOperation(value = "刀具信息-添加", notes = "刀具信息-添加") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_tool:add") |
| | | @PostMapping(value = "/add") |
| | | public Result<String> add(@RequestBody CuttingTool cuttingTool) { |
| | | cuttingToolService.save(cuttingTool); |
| | | List<CuttingProperties> cuttingPropertiesList = cuttingTool.getCuttingPropertiesList(); |
| | | for (CuttingProperties cuttingProperties : cuttingPropertiesList) { |
| | | cuttingProperties.setCuttingId(cuttingTool.getId()); |
| | | cuttingPropertiesService.save(cuttingProperties); |
| | | } |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 编辑 |
| | | * |
| | | * @param cuttingTool |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具信息-编辑") |
| | | @ApiOperation(value = "刀具信息-编辑", notes = "刀具信息-编辑") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_tool:edit") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) |
| | | public Result<String> edit(@RequestBody CuttingTool cuttingTool) { |
| | | cuttingToolService.saveOrUpdate(cuttingTool); |
| | | List<String> deletePropertiesIds = cuttingTool.getDeletePropertiesIds(); |
| | | if (deletePropertiesIds != null) { |
| | | for (String deletePropertiesId : deletePropertiesIds) { |
| | | cuttingPropertiesService.removeById(deletePropertiesId); |
| | | } |
| | | } |
| | | List<CuttingProperties> cuttingPropertiesList = cuttingTool.getCuttingPropertiesList(); |
| | | for (CuttingProperties cuttingProperties : cuttingPropertiesList) { |
| | | cuttingProperties.setCuttingId(cuttingTool.getId()); |
| | | cuttingPropertiesService.saveOrUpdate(cuttingProperties); |
| | | } |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具信息-通过id删除") |
| | | @ApiOperation(value = "刀具信息-通过id删除", notes = "刀具信息-通过id删除") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_tool:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name = "id", required = true) String id) { |
| | | cuttingToolService.removeById(id); |
| | | cuttingPropertiesService.remove(new LambdaQueryWrapper<CuttingProperties>().eq(CuttingProperties::getCuttingId, id)); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具信息-批量删除") |
| | | @ApiOperation(value = "刀具信息-批量删除", notes = "刀具信息-批量删除") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_tool:deleteBatch") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | this.cuttingToolService.removeByIds(Arrays.asList(ids.split(","))); |
| | | return Result.OK("批量删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id查询 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "刀具信息-通过id查询") |
| | | @ApiOperation(value = "刀具信息-通过id查询", notes = "刀具信息-通过id查询") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<CuttingTool> queryById(@RequestParam(name = "id", required = true) String id) { |
| | | CuttingTool cuttingTool = cuttingToolService.getById(id); |
| | | if (cuttingTool == null) { |
| | | return Result.error("未找到对应数据"); |
| | | } |
| | | return Result.OK(cuttingTool); |
| | | } |
| | | |
| | | /** |
| | | * 导出excel |
| | | * |
| | | * @param request |
| | | * @param cuttingTool |
| | | */ |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_tool:exportXls") |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, CuttingTool cuttingTool) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 通过excel导入数据 |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | * 通过excel导入数据 |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | //@RequiresPermissions("cms_cutting_tool:importExcel") |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | return super.importExcel(request, response, CuttingTool.class); |
| | | } |
| | | |
| | | |
| | | @GetMapping(value = "/getCuttingToolList") |
| | | public Result<?> getCuttingToolList(@RequestParam("pageNo") Integer pageNo, |
| | | @RequestParam("pageSize") Integer pageSize, |
| | | @RequestParam Map<String, Object> params) { |
| | | IPage<Map<String, Object>> cuttingToolList = cuttingToolService.getCuttingToolList(pageNo, pageSize, params); |
| | | for (Map<String, Object> record : cuttingToolList.getRecords()) { |
| | | String cuttingId = (String) record.get("id"); |
| | | List<CuttingProperties> cuttingPropertiesList = cuttingPropertiesService.selectListByCuttingId(cuttingId); |
| | | record.put("cuttingPropertiesList", cuttingPropertiesList); |
| | | } |
| | | return Result.ok(cuttingToolList); |
| | | } |
| | | //选择刀具的接口 |
| | | @GetMapping(value = "/getCuttingToolList") |
| | | public Result<?> getCuttingToolList(@RequestParam("pageNo") Integer pageNo, |
| | | @RequestParam("pageSize") Integer pageSize, |
| | | @RequestParam Map<String, Object> params) { |
| | | IPage<Map<String, Object>> cuttingToolList = cuttingToolService.getCuttingToolList(pageNo, pageSize, params); |
| | | for (Map<String, Object> record : cuttingToolList.getRecords()) { |
| | | String cuttingId = (String) record.get("id"); |
| | | List<CuttingProperties> cuttingPropertiesList = cuttingPropertiesService.selectListByCuttingId(cuttingId); |
| | | record.put("cuttingPropertiesList", cuttingPropertiesList); |
| | | } |
| | | return Result.ok(cuttingToolList); |
| | | } |
| | | |
| | | } |