From a2093e0389656b3485303da48204f0939c95e8fb Mon Sep 17 00:00:00 2001
From: 刘小明 <liuxm_a@163.com>
Date: 星期五, 26 七月 2024 17:31:47 +0800
Subject: [PATCH] 静态常量整理

---
 pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineCtrl.java |   87 ++++++++++++++-----------------------------
 1 files changed, 29 insertions(+), 58 deletions(-)

diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineCtrl.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineCtrl.java
index f319e04..5ed0602 100644
--- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineCtrl.java
+++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineCtrl.java
@@ -10,7 +10,6 @@
 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;
@@ -33,25 +32,15 @@
     /**
      * 淇濆瓨
      * @param line
-     * @param bindingResult
      * @return
      */
     @PostMapping(path="save")
     @SsoPowerAop(power = "10300005")
     @Log("淇濆瓨鐢熶骇绾�")
-    public BaseResponse<Boolean> save(@RequestBody @Valid PltProductionLine line,BindingResult bindingResult){
-        int count;
-        try {
-            if (bindingResult != null && bindingResult.hasErrors()) {
-                return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
-            }
-            line.disabled = false;
-            line.deleted = false;
-            count = sv.save(line);
-        }catch (Exception e){
-            log.error("淇濆瓨鐢熶骇绾垮紓甯�", e);
-            return BaseResponseUtils.buildException(e.getMessage());
-        }
+    public BaseResponse<Boolean> save(@RequestBody @Valid PltProductionLine line){
+        line.disabled = false;
+        line.deleted = false;
+        int count = sv.save(line);
         if (count <= 0) {
             return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
         } else {
@@ -59,27 +48,33 @@
         }
     }
 
-
     /**
      * 鏇存柊
      * @param line
-     * @param bindingResult
      * @return
      */
     @PostMapping(path="update")
     @SsoPowerAop(power = "10300005")
     @Log("鏇存柊鐢熶骇绾�")
-    public BaseResponse<Boolean> update(@RequestBody @Valid PltProductionLine line,BindingResult bindingResult){
-        int count;
-        try {
-            if (bindingResult != null && bindingResult.hasErrors()) {
-                return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
-            }
-            count = sv.update(line);
-        }catch (Exception e){
-            log.error("鏇存柊鐢熶骇绾垮紓甯�", e);
-            return BaseResponseUtils.buildException(e.getMessage());
+    public BaseResponse<Boolean> update(@RequestBody @Valid PltProductionLine line){
+        int count = sv.update(line);
+        if (count <= 0) {
+            return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
+        } else {
+            return BaseResponseUtils.buildSuccess(true);
         }
+    }
+
+    /**
+     * 鍚敤\绂佺敤鐢熶骇绾�
+     * @return
+     */
+    @PostMapping(path="disabled")
+    @SsoPowerAop(power = "10300005")
+    @Log("璁剧疆鐢熶骇绾跨姸鎬�")
+    //{id: "2", disabled: true}
+    public BaseResponse<Boolean> disabled(@RequestBody PltProductionLine line){
+        int count = sv.updateStatus(line);
         if (count <= 0) {
             return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
         } else {
@@ -96,21 +91,13 @@
     @SsoPowerAop(power = "10300005")
     @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 {
             return BaseResponseUtils.buildSuccess(true);
         }
     }
-
-
 
     /**
      * 鏍规嵁ID鏌ヨ
@@ -120,13 +107,8 @@
     @SsoPowerAop(power = "10300004") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
     @Log("鏍规嵁ID鏌ヨ鐢熶骇绾�")
     public BaseResponse<PltProductionLine> one(String id){
-        try{
-            PltProductionLine param=sv.selectById(id);
-            return BaseResponseUtils.buildSuccess(JSON.toJSON(param));
-        }catch (Exception e){
-            log.error("鏍规嵁ID鏌ヨ鐢熶骇绾垮紓甯�", e);
-            return BaseResponseUtils.buildException(e.getMessage());
-        }
+        PltProductionLine param=sv.selectById(id);
+        return BaseResponseUtils.buildSuccess(JSON.toJSON(param));
     }
 
     /**
@@ -138,13 +120,8 @@
     @SsoPowerAop(power = "10300004")
     @Log("鍒嗛〉鏌ヨ鐢熶骇绾�")
     public BaseResponse<QueryResultVo<List<PltProductionLine>>> some(@RequestBody QueryVo vo){
-        try {
-            QueryResultVo<List<PltProductionLine>> list = sv.selectSome(vo) ;
-            return BaseResponseUtils.buildSuccess(list);
-        }catch (Exception e){
-            log.error("鍒嗛〉鏌ヨ鐢熶骇绾垮紓甯�", e);
-            return BaseResponseUtils.buildException(e.getMessage());
-        }
+        QueryResultVo<List<PltProductionLine>> list = sv.selectSome(vo) ;
+        return BaseResponseUtils.buildSuccess(list);
     }
 
     /**
@@ -155,15 +132,9 @@
     @SsoPowerAop(power = "10300004")
     @Log("鏌ヨ鎵�鏈夌敓浜х嚎")
     public BaseResponse<List<PltProductionLine>> all(){
-        try {
-            List<PltProductionLine> list = sv.selectAll();
+        List<PltProductionLine> list = sv.selectAll();
 
-            return BaseResponseUtils.buildSuccess(list);
-        }catch (Exception e){
-            log.error("鏌ヨ鎵�鏈夌敓浜х嚎寮傚父", e);
-            return BaseResponseUtils.buildException(e.getMessage());
-        }
+        return BaseResponseUtils.buildSuccess(list);
     }
-
 }
 

--
Gitblit v1.8.0