|  |  | 
 |  |  | import jakarta.validation.Valid; | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.validation.BindingResult; | 
 |  |  | import org.springframework.web.bind.annotation.*; | 
 |  |  |  | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Map; | 
 |  |  | import java.util.Objects; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * 生产流程 | 
 |  |  | 
 |  |  |     /** | 
 |  |  |      * 保存 | 
 |  |  |      * @param  process | 
 |  |  |      * @param bindingResult | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @PostMapping(path="save") | 
 |  |  |     @SsoPowerAop(power = "-1") | 
 |  |  |     @SsoPowerAop(power = "10200003") | 
 |  |  |     @Log("保存生产流程") | 
 |  |  |     public BaseResponse<Boolean> save(@RequestBody @Valid PrProductionProcess process, BindingResult bindingResult){ | 
 |  |  |         if (bindingResult != null && bindingResult.hasErrors()) { | 
 |  |  |             return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); | 
 |  |  |         } | 
 |  |  |         int count; | 
 |  |  |         try { | 
 |  |  |             count = sv.save(process); | 
 |  |  |         }catch (Exception e){ | 
 |  |  |             log.error("保存生产流程异常", e); | 
 |  |  |             return BaseResponseUtils.buildException(e.getMessage()); | 
 |  |  |         } | 
 |  |  |     public BaseResponse<Boolean> save(@RequestBody @Valid PrProductionProcess process){ | 
 |  |  |         int count = sv.save(process); | 
 |  |  |         if (count <= 0) { | 
 |  |  |             return BaseResponseUtils.buildFail("数据库存储失败"); | 
 |  |  |         } else { | 
 |  |  | 
 |  |  |     /** | 
 |  |  |      * 更新 | 
 |  |  |      * @param process | 
 |  |  |      * @param bindingResult | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @PostMapping(path="update") | 
 |  |  |     @SsoPowerAop(power = "-1") | 
 |  |  |     @SsoPowerAop(power = "10200003") | 
 |  |  |     @Log("更新生产流程") | 
 |  |  |     public BaseResponse<Boolean> update(@RequestBody @Valid PrProductionProcess process, BindingResult bindingResult){ | 
 |  |  |         int count; | 
 |  |  |         try { | 
 |  |  |             if (bindingResult != null && bindingResult.hasErrors()) { | 
 |  |  |                 return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); | 
 |  |  |             } | 
 |  |  |             count = sv.update(process); | 
 |  |  |         }catch (Exception e){ | 
 |  |  |             log.error("更新生产流程异常", e); | 
 |  |  |             return BaseResponseUtils.buildException(e.getMessage()); | 
 |  |  |         } | 
 |  |  |     public BaseResponse<Boolean> update(@RequestBody @Valid PrProductionProcess process){ | 
 |  |  |         int count = sv.update(process); | 
 |  |  |         if (count <= 0) { | 
 |  |  |             return BaseResponseUtils.buildFail("数据库存储失败"); | 
 |  |  |         } else { | 
 |  |  | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @GetMapping(path="one") | 
 |  |  |     @SsoPowerAop(power = "-1") | 
 |  |  |     @SsoPowerAop(power = "10200002") | 
 |  |  |     @Log("根据ID查询生产流程") | 
 |  |  |     public BaseResponse<PrProductionProcess> one(Long id){ | 
 |  |  |         try{ | 
 |  |  |             PrProductionProcess process=sv.selectById(id); | 
 |  |  |             return BaseResponseUtils.buildSuccess(process); | 
 |  |  |         }catch (Exception e){ | 
 |  |  |             log.error("根据ID查询生产流程异常", e); | 
 |  |  |             return BaseResponseUtils.buildException(e.getMessage()); | 
 |  |  |         } | 
 |  |  |         PrProductionProcess process=sv.selectById(id); | 
 |  |  |         return BaseResponseUtils.buildSuccess(process); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @PostMapping(path="some") | 
 |  |  |     @SsoPowerAop(power = "-1") | 
 |  |  |     @SsoPowerAop(power = "10200002") | 
 |  |  |     @Log("分页查询生产流程") | 
 |  |  |     public BaseResponse<QueryResultVo<List<PrProductionProcess>>> some(@RequestBody QueryVo vo){ | 
 |  |  |         try { | 
 |  |  |             QueryResultVo<List<PrProductionProcess>> list = sv.selectSome(vo) ; | 
 |  |  |             return BaseResponseUtils.buildSuccess(list); | 
 |  |  |         }catch (Exception e){ | 
 |  |  |             log.error("分页查询生产流程异常", e); | 
 |  |  |             return BaseResponseUtils.buildException(e.getMessage()); | 
 |  |  |         } | 
 |  |  |         QueryResultVo<List<PrProductionProcess>> list = sv.selectSome(vo) ; | 
 |  |  |         return BaseResponseUtils.buildSuccess(list); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @GetMapping(path="queryAll") | 
 |  |  |     @SsoPowerAop(power = "-1") | 
 |  |  |     @SsoPowerAop(power = "10200002") | 
 |  |  |     @Log("查询所有生产流程") | 
 |  |  |     public BaseResponse<List<Map<String,String>>> queryAll(){ | 
 |  |  |         try { | 
 |  |  |             return BaseResponseUtils.buildSuccess(sv.queryAll()); | 
 |  |  |         }catch (Exception e){ | 
 |  |  |             log.error("查询所有生产流程异常", e); | 
 |  |  |             return BaseResponseUtils.buildException(e.getMessage()); | 
 |  |  |         } | 
 |  |  |     public BaseResponse<List<Map<String,String>>> queryAll(Long proId){ | 
 |  |  |         return BaseResponseUtils.buildSuccess(sv.queryAll(proId)); | 
 |  |  |     } | 
 |  |  | } |