From f2be4ed3f71f85f15f2c6bb6ab1d0263c1bd5f3a Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期六, 11 十一月 2023 22:13:47 +0800
Subject: [PATCH] 1、完善一些代码 2、实现了片区管理 3、增加了apache的BeanUtils实现对象转Map

---
 pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java |   98 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 93 insertions(+), 5 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 3377625..deaf5a7 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
@@ -68,15 +68,33 @@
     @ApiResponses(value = {
             @ApiResponse(
                     responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
-                    description = "杩斿洖鎵�鏈夎鏀垮尯鏁版嵁锛圔aseResponse鏄熀绫伙級",
+                    description = "杩斿洖鎵�鏈夎鏀垮尯鏁版嵁锛圔aseResponse.content:[{}]锛�",
                     content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                             schema = @Schema(implementation = BaDistrict.class))}
             )
     })
-    @GetMapping(path = "allDistricts")
-    public BaseResponse<List<BaDistrict>> allDistricts(){
-        List<BaDistrict> list = this.sv.getAll(DistrictLevel.City.code) ;
+    @GetMapping(path = "all")
+    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")
+    public BaseResponse<BaDistrict> one(@Parameter(description = "瀹炰綋id", required = true) Long id){
+        return BaseResponseUtils.buildSuccess(this.sv.selectById(id));
     }
 
     /**
@@ -88,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))}
             )
@@ -113,4 +131,74 @@
             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