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/client/ClientCtrl.java |  187 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 187 insertions(+), 0 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/client/ClientCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/client/ClientCtrl.java
index e0bb7bd..24d5e8b 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/client/ClientCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/client/ClientCtrl.java
@@ -1,4 +1,191 @@
 package com.dy.pipIrrBase.client;
 
+
+import com.dy.common.aop.SsoAop;
+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.pipIrrGlobal.pojoBa.BaClient;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.responses.ApiResponses;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.validation.Valid;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Objects;
+
+@Slf4j
+@Tag(name = "鍐滄埛绠$悊", description = "鍐滄埛澧炲垹鏀规煡绛夋搷浣�")
+@RestController
+@RequestMapping(path="client")
+@SuppressWarnings("unchecked")//java鐗堟湰瓒婇珮锛屽娉涘瀷绾︽潫瓒婁弗锛屾墍浠ラ厤缃甋uppressWarnings("unchecked")
 public class ClientCtrl {
+
+    private ClientSv sv ;
+
+    @Autowired
+    private void setSv(ClientSv sv){
+        this.sv = sv ;
+    }
+
+    /**
+     * 瀹㈡埛绔姹傚緱鍒版墍鏈夊啘鎴锋暟鎹�
+     * @return 鎵�鏈夊啘鎴锋暟鎹�
+     */
+    @Operation(summary = "鑾峰緱涓�椤靛啘鎴�", description = "杩斿洖涓�椤靛啘鎴锋暟鎹�")
+    @ApiResponses(value = {
+            @ApiResponse(
+                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+                    description = "杩斿洖涓�椤靛啘鎴锋暟鎹紙BaseResponse.content:QueryResultVo[{}]锛�",
+                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+                            schema = @Schema(implementation = BaClient.class))}
+            )
+    })
+    @PostMapping(path = "some", consumes = MediaType.APPLICATION_JSON_VALUE)
+    @SsoAop("-1")
+    public BaseResponse<QueryResultVo<List<BaClient>>> some(@RequestBody @Parameter(description = "鏌ヨform琛ㄥ崟json鏁版嵁", required = true) QueryVo vo){
+        try {
+            QueryResultVo<List<BaClient>> res = this.sv.selectSome(vo) ;
+            return BaseResponseUtils.buildSuccess(res);
+        } catch (Exception e) {
+            log.error("鏌ヨ鍐滄埛寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage()) ;
+        }
+    }
+
+    /**
+     * 寰楀埌涓�涓啘鎴锋暟鎹�
+     * @return 涓�涓啘鎴锋暟鎹�
+     */
+    @Operation(summary = "涓�涓啘鎴�", description = "寰楀埌涓�涓啘鎴锋暟鎹�")
+    @ApiResponses(value = {
+            @ApiResponse(
+                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+                    description = "杩斿洖涓�涓啘鎴锋暟鎹紙BaseResponse.content:{}锛�",
+                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+                            schema = @Schema(implementation = BaClient.class))}
+            )
+    })
+    @GetMapping(path = "one", consumes = MediaType.TEXT_PLAIN_VALUE)
+    @SsoAop("-1")
+    public BaseResponse<BaClient> one(@Parameter(description = "瀹炰綋id", required = true) Long id){
+        return BaseResponseUtils.buildSuccess(this.sv.selectById(id));
+    }
+
+    /**
+     * 淇濆瓨鍐滄埛
+     * @param po 淇濆瓨鍐滄埛form琛ㄥ崟瀵硅薄
+     * @return 鏄惁鎴愬姛
+     */
+    @Operation(summary = "淇濆瓨鍐滄埛", description = "鎻愪氦鍐滄埛鏁版嵁锛坒orm琛ㄥ崟锛夛紝杩涜淇濆瓨")
+    @ApiResponses(value = {
+            @ApiResponse(
+                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+                    description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�",
+                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+                            schema = @Schema(implementation = Boolean.class))}
+            )
+    })
+    @PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE)
+    @SsoAop("-1")//@SsoAop(power = "-1")
+    public BaseResponse<Boolean> save(@RequestBody @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid BaClient po, @Parameter(hidden = true) BindingResult bindingResult){
+        if(bindingResult != null && bindingResult.hasErrors()){
+            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+        }
+        po.id = null ;
+        int count;
+        try {
+            count = this.sv.save(po);
+        } catch (Exception e) {
+            log.error("淇濆瓨鍐滄埛寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage()) ;
+        }
+        if(count <= 0){
+            return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ;
+        }else{
+            return BaseResponseUtils.buildSuccess(true) ;
+        }
+    }
+
+    /**
+     * 缂栬緫淇敼鍐滄埛
+     * @param po 淇濆瓨鍐滄埛form琛ㄥ崟瀵硅薄
+     * @return 鏄惁鎴愬姛
+     */
+    @Operation(summary = "缂栬緫淇敼鍐滄埛", description = "鎻愪氦鍐滄埛鏁版嵁锛坒orm琛ㄥ崟锛夛紝杩涜淇敼")
+    @ApiResponses(value = {
+            @ApiResponse(
+                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+                    description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�",
+                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+                            schema = @Schema(implementation = Boolean.class))}
+            )
+    })
+    @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
+    @SsoAop("-1")//@SsoAop(power = "-1")
+    public BaseResponse<Boolean> update(@RequestBody @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid BaClient po, @Parameter(hidden = true) BindingResult bindingResult){
+        if(bindingResult != null && bindingResult.hasErrors()){
+            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+        }
+        if(po.id == null){
+            return BaseResponseUtils.buildFail("鏃犳暟鎹疄浣揑D") ;
+        }
+        int count;
+        try {
+            count = this.sv.update(po);
+        } catch (Exception e) {
+            log.error("淇濆瓨鍐滄埛寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage()) ;
+        }
+        if(count <= 0){
+            return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ;
+        }else{
+            return BaseResponseUtils.buildSuccess(true) ;
+        }
+    }
+
+
+    /**
+     * 鍒犻櫎鍐滄埛
+     * @param id 鍐滄埛ID
+     * @return 鏄惁鎴愬姛
+     */
+    @Operation(summary = "鍒犻櫎鍐滄埛", description = "鎻愪氦鍐滄埛ID锛岃繘琛岄�昏緫鍒犻櫎")
+    @ApiResponses(value = {
+            @ApiResponse(
+                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+                    description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�",
+                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+                            schema = @Schema(implementation = Boolean.class))}
+            )
+    })
+    @GetMapping(path = "delete", consumes = MediaType.TEXT_PLAIN_VALUE)
+    @SsoAop("-1")//@SsoAop(power = "-1")
+    public BaseResponse<Boolean> delete(@Parameter(description = "瀹炰綋id", required = true) Long id){
+        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("鏁版嵁搴撳瓨鍌ㄥけ璐�") ;
+        }else{
+            return BaseResponseUtils.buildSuccess(true) ;
+        }
+    }
 }

--
Gitblit v1.8.0