From a8a841000119370ec34a59a7f4f51dc2f8ee0976 Mon Sep 17 00:00:00 2001
From: liuxm <liuxm_a@163.com>
Date: 星期四, 13 六月 2024 14:22:02 +0800
Subject: [PATCH] 去掉原controller 中的try catch 和BindingResult

---
 pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proItems/ProItemsCtrl.java |   72 +++++++-----------------------------
 1 files changed, 14 insertions(+), 58 deletions(-)

diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proItems/ProItemsCtrl.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proItems/ProItemsCtrl.java
index 8abe361..59af6ee 100644
--- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proItems/ProItemsCtrl.java
+++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proItems/ProItemsCtrl.java
@@ -6,18 +6,14 @@
 import com.dy.common.webUtil.BaseResponseUtils;
 import com.dy.common.webUtil.QueryResultVo;
 import com.dy.pmsGlobal.aop.Log;
-import com.dy.pmsGlobal.pojoBa.BaRole;
-import com.dy.pmsGlobal.pojoPlt.PltProductParams;
 import com.dy.pmsGlobal.pojoPlt.PltProductQualityInspectionItems;
 import com.dy.pmsGlobal.pojoPlt.PltProductUnqualifiedReason;
 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.Objects;
 
 /**
  * 浜у搧鍝佽川妫�鏌ラ」鐩�
@@ -36,25 +32,15 @@
     /**
      * 淇濆瓨浜у搧鍝佽川妫�鏌ラ」鐩�
      * @param item
-     * @param bindingResult
      * @return
      */
     @PostMapping(path="save")
     @SsoPowerAop(power = "10300003")
     @Log("淇濆瓨浜у搧鍝佽川妫�鏌ラ」鐩俊鎭�")
-    public BaseResponse<Boolean> save(@RequestBody @Valid PltProductQualityInspectionItems item, BindingResult bindingResult){
-        int count = 0;
-        try {
-            if (bindingResult != null && bindingResult.hasErrors()) {
-                return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
-            }
-            item.deleted = false;
-            item.disabled = false;
-            count =sv.save(item);
-        }catch (Exception e){
-            log.error("淇濆瓨浜у搧鍝佽川妫�鏌ラ」鐩紓甯�", e);
-            return BaseResponseUtils.buildException(e.getMessage());
-        }
+    public BaseResponse<Boolean> save(@RequestBody @Valid PltProductQualityInspectionItems item){
+        item.deleted = false;
+        item.disabled = false;
+        int count =sv.save(item);
         if (count <= 0) {
             return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
         } else {
@@ -66,23 +52,13 @@
     /**
      * 鏇存柊浜у搧鍝佽川妫�鏌ラ」鐩俊鎭�
      * @param item
-     * @param bindingResult
      * @return
      */
     @PostMapping(path="update")
     @SsoPowerAop(power = "10300003")
     @Log("鏇存柊浜у搧鍝佽川妫�鏌ラ」鐩俊鎭�")
-    public BaseResponse<Boolean> update(@RequestBody @Valid PltProductQualityInspectionItems item,BindingResult bindingResult){
-        int count ;
-        try {
-            if (bindingResult != null && bindingResult.hasErrors()) {
-                return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
-            }
-            count = sv.update(item);
-        }catch (Exception e){
-            log.error("鏇存柊浜у搧鍝佽川妫�鏌ラ」鐩紓甯�", e);
-            return BaseResponseUtils.buildException(e.getMessage());
-        }
+    public BaseResponse<Boolean> update(@RequestBody @Valid PltProductQualityInspectionItems item){
+        int count = sv.update(item);
         if (count <= 0) {
             return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
         } else {
@@ -99,13 +75,8 @@
     @SsoPowerAop(power = "10300003")
     @Log("鍒犻櫎浜у搧鍝佽川妫�鏌ラ」鐩俊鎭�")
     public BaseResponse<Boolean> delete(String id){
-        int count;
-        try {
-            count = sv.delete(Long.parseLong(id));
-        }catch (Exception e){
-            log.error("鍒犻櫎浜у搧鍝佽川妫�鏌ラ」鐩紓甯�", e);
-            return BaseResponseUtils.buildException(e.getMessage());
-        }
+        int count = sv.delete(Long.parseLong(id));
+
         if (count <= 0) {
             return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
         } else {
@@ -123,13 +94,8 @@
     @SsoPowerAop(power = "10300002") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
     @Log("鏍规嵁ID鏌ヨ浜у搧鍝佽川妫�鏌ラ」鐩俊鎭�")
     public BaseResponse<PltProductQualityInspectionItems> one(String id){
-        try{
-            PltProductQualityInspectionItems item=sv.selectById(id);
-            return BaseResponseUtils.buildSuccess(JSON.toJSON(item));
-        }catch (Exception e){
-            log.error("鏌ヨ浜у搧鍝佽川妫�鏌ラ」鐩紓甯�", e);
-            return BaseResponseUtils.buildException(e.getMessage());
-        }
+        PltProductQualityInspectionItems item=sv.selectById(id);
+        return BaseResponseUtils.buildSuccess(JSON.toJSON(item));
     }
 
     /**
@@ -141,13 +107,8 @@
     @SsoPowerAop(power = "10300002")
     @Log("鏌ヨ浜у搧鍝佽川妫�鏌ラ」鐩俊鎭�")
     public BaseResponse<QueryResultVo<List<PltProductQualityInspectionItems>>> some(@RequestBody QueryVo vo){
-        try {
-            QueryResultVo<List<PltProductQualityInspectionItems>> list = sv.selectSome(vo) ;
-            return BaseResponseUtils.buildSuccess(list);
-        }catch (Exception e){
-            log.error("鏌ヨ浜у搧鍝佽川妫�鏌ラ」鐩紓甯�", e);
-            return BaseResponseUtils.buildException(e.getMessage());
-        }
+        QueryResultVo<List<PltProductQualityInspectionItems>> list = sv.selectSome(vo) ;
+        return BaseResponseUtils.buildSuccess(list);
     }
     /**
      * 绂佺敤鎴栧惎鐢�
@@ -158,13 +119,8 @@
     @SsoPowerAop(power = "10100011")
     @Log("绂佺敤鎴栧惎鐢ㄨ川妫�椤圭洰")
     public BaseResponse<Boolean> disabled(@RequestBody PltProductUnqualifiedReason reason){
-        int count;
-        try {
-            count = sv.disabled(reason.id,reason.disabled);
-        }catch (Exception e){
-            log.error("绂佺敤鎴栧惎鐢ㄨ川妫�椤圭洰寮傚父", e);
-            return BaseResponseUtils.buildException(e.getMessage());
-        }
+        int count = sv.disabled(reason.id,reason.disabled);
+
         if (count <= 0) {
             return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
         } else {

--
Gitblit v1.8.0