From 437713ee567f25c04f094057a1908b6dc54eeefd Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 16 十一月 2023 16:57:29 +0800
Subject: [PATCH] 1、农户类型管理 2、农户管理

---
 pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/clientType/ClientTypeCtrl.java |   47 +++++++++++++++++++++++------------------------
 1 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/clientType/ClientTypeCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/clientType/ClientTypeCtrl.java
index 6621c38..f93d252 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/clientType/ClientTypeCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/clientType/ClientTypeCtrl.java
@@ -2,14 +2,11 @@
 
 
 import com.dy.common.aop.SsoAop;
-import com.dy.common.mybatis.envm.Deleted;
 import com.dy.common.webUtil.BaseResponse;
 import com.dy.common.webUtil.BaseResponseUtils;
 import com.dy.common.webUtil.QueryResultVo;
 import com.dy.common.webUtil.ResultCodeMsg;
-import com.dy.pipIrrBase.role.RoleSv;
 import com.dy.pipIrrBase.user.QueryVo;
-import com.dy.pipIrrGlobal.pojoBa.BaClientType;
 import com.dy.pipIrrGlobal.pojoBa.BaClientType;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
@@ -23,10 +20,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.validation.BindingResult;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 import java.util.Objects;
@@ -83,9 +77,9 @@
                             schema = @Schema(implementation = BaClientType.class))}
             )
     })
-    @PostMapping(path = "some", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
+    @PostMapping(path = "some", consumes = MediaType.APPLICATION_JSON_VALUE)
     @SsoAop("-1")
-    public BaseResponse<QueryResultVo<List<BaClientType>>> some(@Parameter(description = "鏌ヨform琛ㄥ崟鏁版嵁", required = true) @Valid QueryVo vo){
+    public BaseResponse<QueryResultVo<List<BaClientType>>> some(@RequestBody @Parameter(description = "鏌ヨform琛ㄥ崟json鏁版嵁", required = true) @Valid QueryVo vo){
         try {
             QueryResultVo<List<BaClientType>> res = this.sv.selectSome(vo) ;
             return BaseResponseUtils.buildSuccess(res);
@@ -108,7 +102,7 @@
                             schema = @Schema(implementation = BaClientType.class))}
             )
     })
-    @GetMapping(path = "one")
+    @GetMapping(path = "one", consumes = MediaType.TEXT_PLAIN_VALUE)
     @SsoAop("-1")
     public BaseResponse<BaClientType> one(@Parameter(description = "瀹炰綋id", required = true) Long id){
         return BaseResponseUtils.buildSuccess(this.sv.selectById(id));
@@ -128,9 +122,9 @@
                             schema = @Schema(implementation = Boolean.class))}
             )
     })
-    @PostMapping(path = "save", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
+    @PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE)
     @SsoAop("-1")//@SsoAop(power = "-1")
-    public BaseResponse<Boolean> save(@Parameter(description = "form琛ㄥ崟鏁版嵁", required = true) @Valid BaClientType po, @Parameter(hidden = true) BindingResult bindingResult){
+    public BaseResponse<Boolean> save(@RequestBody @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid BaClientType po, @Parameter(hidden = true) BindingResult bindingResult){
         if(bindingResult != null && bindingResult.hasErrors()){
             return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
         }
@@ -163,9 +157,9 @@
                             schema = @Schema(implementation = Boolean.class))}
             )
     })
-    @PostMapping(path = "update", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
+    @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
     @SsoAop("-1")//@SsoAop(power = "-1")
-    public BaseResponse<Boolean> update(@Parameter(description = "form琛ㄥ崟鏁版嵁", required = true) @Valid BaClientType po, @Parameter(hidden = true) BindingResult bindingResult){
+    public BaseResponse<Boolean> update(@RequestBody @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid BaClientType po, @Parameter(hidden = true) BindingResult bindingResult){
         if(bindingResult != null && bindingResult.hasErrors()){
             return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
         }
@@ -207,17 +201,22 @@
         if(id == null){
             return BaseResponseUtils.buildFail("id涓嶈兘涓虹┖") ;
         }
-        int count;
-        try {
-            count = this.sv.delete(id);
-        } catch (Exception e) {
-            log.error("淇濆瓨鍐滄埛绫诲瀷寮傚父", e);
-            return BaseResponseUtils.buildException(e.getMessage()) ;
-        }
-        if(count <= 0){
-            return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ;
+        Long clientCount = this.sv.selectClientByType(id) ;
+        if(clientCount > 0){
+            return BaseResponseUtils.buildFail("鍒犻櫎澶辫触锛屽瓨鍦�" + clientCount + "涓啘鎴峰綊灞炴绫诲瀷锛岃绫诲瀷涓嶈兘琚垹闄�") ;
         }else{
-            return BaseResponseUtils.buildSuccess(true) ;
+            int count;
+            try {
+                count = this.sv.delete(id);
+            } catch (Exception e) {
+                log.error("淇濆瓨鍐滄埛绫诲瀷寮傚父", e);
+                return BaseResponseUtils.buildException(e.getMessage()) ;
+            }
+            if(count <= 0){
+                return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ;
+            }else{
+                return BaseResponseUtils.buildSuccess(true) ;
+            }
         }
     }
 

--
Gitblit v1.8.0