From de2f7fe7f23ac338b7d6997a74b3715e9b1a7cc7 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 16 十一月 2023 10:56:18 +0800
Subject: [PATCH] 1、行政区保存功能,修改自动加上行政区级别,及删除标志 2、单点登录中增加了获得所有组织机构的功能,及增加组织机构枚举类型 3、增加农户实体、农户类型实体、分水口实体等相关功能

---
 pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java |  125 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 119 insertions(+), 6 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java
index a274591..f28ab04 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java
@@ -1,6 +1,7 @@
 package com.dy.pipIrrBase.district;
 
 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.ResultCodeMsg;
@@ -18,10 +19,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.Arrays;
 import java.util.List;
@@ -56,10 +54,48 @@
     })
     @GetMapping(path = "allLevel")
     public BaseResponse<List<DistrictLevel>> allDistrictLevels(){
-        List<DistrictLevel> list = Arrays.asList(DistrictLevel.City, DistrictLevel.County, DistrictLevel.Town, DistrictLevel.Village, DistrictLevel.Group) ;
+        List<DistrictLevel> list = Arrays.asList(DistrictLevel.City, DistrictLevel.County, DistrictLevel.Town, DistrictLevel.Village) ;
         return BaseResponseUtils.buildSuccess(list);
     }
 
+    /**
+     * 瀹㈡埛绔姹傚緱鍒版墍鏈夎鏀垮尯鏁版嵁
+     * @return 鎵�鏈夎鏀垮尯鏁版嵁
+     */
+    @Operation(summary = "鑾峰緱鎵�鏈夎鏀垮尯", description = "杩斿洖鎵�鏈夎鏀垮尯鏁版嵁")
+    @ApiResponses(value = {
+            @ApiResponse(
+                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+                    description = "杩斿洖鎵�鏈夎鏀垮尯鏁版嵁锛圔aseResponse.content:[{}]锛�",
+                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+                            schema = @Schema(implementation = BaDistrict.class))}
+            )
+    })
+    @GetMapping(path = "all")
+    @SsoAop("-1")
+    public BaseResponse<List<BaDistrict>> all(){
+        List<BaDistrict> list = this.sv.selectAllByLevel(DistrictLevel.City.code) ;
+        return BaseResponseUtils.buildSuccess(list);
+    }
+
+    /**
+     * 寰楀埌涓�涓鏀垮尯鏁版嵁
+     * @return 涓�涓鏀垮尯鏁版嵁
+     */
+    @Operation(summary = "涓�涓鏀垮尯", description = "寰楀埌涓�涓鏀垮尯鏁版嵁")
+    @ApiResponses(value = {
+            @ApiResponse(
+                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+                    description = "杩斿洖涓�涓鏀垮尯鏁版嵁锛圔aseResponse.content:{}锛�",
+                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+                            schema = @Schema(implementation = BaDistrict.class))}
+            )
+    })
+    @GetMapping(path = "one")
+    @SsoAop("-1")
+    public BaseResponse<BaDistrict> one(@Parameter(description = "瀹炰綋id", required = true) Long id){
+        return BaseResponseUtils.buildSuccess(this.sv.selectById(id));
+    }
 
     /**
      * 淇濆瓨琛屾斂鍖�
@@ -70,7 +106,7 @@
     @ApiResponses(value = {
             @ApiResponse(
                     responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
-                    description = "淇濆瓨琛屾斂鍖鸿繑鍥烇細true锛氭垚鍔燂紝false锛氬け璐ワ紙鏁版嵁鍩虹被鐨刢ontent锛�",
+                    description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�",
                     content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                             schema = @Schema(implementation = Boolean.class))}
             )
@@ -84,13 +120,90 @@
         BaDistrict po = DistrictVoMapper.INSTANCT.convert(vo);
         int count;
         try {
+            BaDistrict supperPo = this.sv.selectById(po.supperId) ;
+            if(supperPo == null){
+                return BaseResponseUtils.buildFail("鍑洪敊锛屾湭寰楀埌涓婄骇琛屾斂鍖�") ;
+            }else{
+                po.level = DistrictLevel.get((byte)(supperPo.level.code + 1)) ;
+            }
+            po.deleted = Deleted.NO ;
             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 vo 淇濆瓨琛屾斂鍖篺orm琛ㄥ崟瀵硅薄
+     * @return 鏄惁鎴愬姛
+     */
+    @Operation(summary = "缂栬緫淇敼琛屾斂鍖�", description = "鎻愪氦琛屾斂鍖烘暟鎹紙form琛ㄥ崟锛夛紝杩涜淇敼")
+    @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.MULTIPART_FORM_DATA_VALUE)
+    @SsoAop("-1")//@SsoAop(power = "-1")
+    public BaseResponse<Boolean> update(@Parameter(description = "form琛ㄥ崟鏁版嵁", required = true) @Valid DistrictVo vo, @Parameter(hidden = true) BindingResult bindingResult){
+        if(bindingResult != null && bindingResult.hasErrors()){
+            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+        }
+        BaDistrict po = DistrictVoMapper.INSTANCT.convert(vo);
+        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 琛屾斂鍖篒D
+     * @return 鏄惁鎴愬姛
+     */
+    @Operation(summary = "鍒犻櫎琛屾斂鍖�", description = "鎻愪氦琛屾斂鍖篒D锛岃繘琛岄�昏緫鍒犻櫎")
+    @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