|  |  | 
 |  |  | import com.dy.common.webUtil.BaseResponseUtils; | 
 |  |  | import com.dy.common.webUtil.QueryResultVo; | 
 |  |  | import com.dy.pmsGlobal.aop.Log; | 
 |  |  | import com.dy.pmsGlobal.daoOth.OthFileMapper; | 
 |  |  | import com.dy.pmsGlobal.dyFile.FileOperate; | 
 |  |  | import com.dy.pmsGlobal.dyFile.FileRestVo; | 
 |  |  | import com.dy.pmsGlobal.pojoOth.OthFile; | 
 |  |  | import com.dy.pmsGlobal.pojoPlt.PltProduct; | 
 |  |  | import jakarta.validation.Valid; | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.beans.factory.annotation.Value; | 
 |  |  | import org.springframework.validation.BindingResult; | 
 |  |  | import org.springframework.web.bind.annotation.*; | 
 |  |  |  | 
 |  |  | 
 |  |  |     @PostMapping(path="save") | 
 |  |  |     @SsoPowerAop(power = "10300001") | 
 |  |  |     @Log("保存产品信息") | 
 |  |  |     public BaseResponse<PltProduct> save(@RequestBody @Valid PltProduct pro, BindingResult bindingResult){ | 
 |  |  |     public BaseResponse<PltProduct> save(@RequestBody @Valid PltProduct pro, | 
 |  |  |                                          BindingResult bindingResult){ | 
 |  |  |         pro.id = null; | 
 |  |  |         Long id; | 
 |  |  |         int count; | 
 |  |  |         try { | 
 |  |  |             if (bindingResult != null && bindingResult.hasErrors()) { | 
 |  |  |                 return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); | 
 |  |  |             } | 
 |  |  |             pro.setDeleted(false); | 
 |  |  |             id = proSv.save(pro); | 
 |  |  |             count = proSv.save(pro); | 
 |  |  |         }catch (Exception e){ | 
 |  |  |             log.error("保存产品异常", e); | 
 |  |  |             return BaseResponseUtils.buildException(e.getMessage()); | 
 |  |  |         } | 
 |  |  |         if (id <= 0) { | 
 |  |  |         if (count <= 0) { | 
 |  |  |             return BaseResponseUtils.buildFail("数据库存储失败"); | 
 |  |  |         } else { | 
 |  |  |             return BaseResponseUtils.buildSuccess(true); | 
 |  |  | 
 |  |  |     @GetMapping(path="delete") | 
 |  |  |     @SsoPowerAop(power = "10300001") | 
 |  |  |     @Log("删除产品信息") | 
 |  |  |     public BaseResponse<PltProduct> delete(String id){ | 
 |  |  |     public BaseResponse<Boolean> delete(String id){ | 
 |  |  |         int count; | 
 |  |  |         try { | 
 |  |  |             return BaseResponseUtils.buildSuccess(proSv.delete(Long.parseLong(id))); | 
 |  |  |             count = proSv.delete(Long.parseLong(id)); | 
 |  |  |         }catch (Exception e){ | 
 |  |  |             log.error("删除产品异常", e); | 
 |  |  |             return BaseResponseUtils.buildException(e.getMessage()); | 
 |  |  |         } | 
 |  |  |         if (count <= 0) { | 
 |  |  |             return BaseResponseUtils.buildFail("数据库存储失败"); | 
 |  |  |         } else { | 
 |  |  |             return BaseResponseUtils.buildSuccess(true); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |             return BaseResponseUtils.buildException(e.getMessage()); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 查询所有产品 | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @GetMapping(path="all") | 
 |  |  |     @SsoPowerAop(power = "10300000") | 
 |  |  |     @Log("查询所有产品") | 
 |  |  |     public BaseResponse<List<PltProduct>> all(){ | 
 |  |  |         try { | 
 |  |  |             List<PltProduct> list = proSv.selectAll() ; | 
 |  |  |             return BaseResponseUtils.buildSuccess(list); | 
 |  |  |         }catch (Exception e){ | 
 |  |  |             log.error("查询所有产品异常", e); | 
 |  |  |             return BaseResponseUtils.buildException(e.getMessage()); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | } |