package org.jeecg.modules.dnc.controller; import cn.hutool.core.util.StrUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.modules.dnc.entity.ProcessInfo; import org.jeecg.modules.dnc.response.CommonCode; import org.jeecg.modules.dnc.response.QueryListResponseResult; import org.jeecg.modules.dnc.response.ResponseResult; import org.jeecg.modules.dnc.service.IProcessInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Collections; import java.util.List; @Slf4j @Api(tags = "新建工序表") @RestController @RequestMapping("/nc/process") public class ProcessController extends JeecgController { @Autowired private IProcessInfoService processInfoService; @AutoLog(value = "新建工序表-新增或编辑工序基本信息") @ApiOperation(value = "新建工序表-新增或编辑工序基本信息", notes = "新建工序表-新增或编辑工序基本信息") @PostMapping("/addOrEdit") public ResponseResult addOrEdit(@RequestBody ProcessInfo processInfo) { boolean b = processInfoService.addOrEdit(processInfo); if(b) { return new ResponseResult(CommonCode.SUCCESS); } return new ResponseResult(CommonCode.FAIL); } @AutoLog(value = "新建工序表-根据工序名称模糊查询") @ApiOperation(value = "新建工序表-根据工序名称模糊查询", notes = "新建工序表-根据工序名称模糊查询") @GetMapping("/find/list") public QueryListResponseResult findByProcessName(@RequestParam(value = "processName", required = false) String processName) { if(!StrUtil.isEmpty(processName)) return new QueryListResponseResult(CommonCode.SUCCESS, Collections.emptyList()); List list = processInfoService.findByProcessName(processName); if(list == null) list = Collections.emptyList(); return new QueryListResponseResult(CommonCode.SUCCESS, list); } @AutoLog(value = "新建工序表-工序列表") @ApiOperation(value = "新建工序表-工序列表", notes = "新建工序表-工序列表") @GetMapping("/find/all") public QueryListResponseResult findAll() { List list = processInfoService.list(); if(list == null) list = Collections.emptyList(); return new QueryListResponseResult(CommonCode.SUCCESS, list); } }