From 9c32918e2d2db0dcc8b3a3af2be72831252019d9 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期六, 08 二月 2025 09:28:02 +0800
Subject: [PATCH] 涉嫌偷水功能完善代码
---
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java | 106 +++++++++++++++++++++++++++++++---------------------
1 files changed, 63 insertions(+), 43 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java
index 5483b23..830de5b 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java
@@ -10,6 +10,7 @@
import com.dy.pipIrrGlobal.pojoBa.BaClient;
import com.dy.pipIrrGlobal.pojoPr.PrDivide;
import com.dy.pipIrrGlobal.voPr.VoDivide;
+import com.dy.pipIrrGlobal.voPr.VoDivideDetails;
import com.dy.pipIrrGlobal.voSe.VoActiveCard;
import com.dy.pipIrrProject.result.ProjectResultCode;
import io.swagger.v3.oas.annotations.Operation;
@@ -67,8 +68,13 @@
@SsoAop()
public BaseResponse<QueryResultVo<List<VoDivide>>> getDivides(QueryVo vo){
try {
- QueryResultVo<List<VoDivide>> res = divideSv.getDivides(vo);
- return BaseResponseUtils.buildSuccess(res);
+ //QueryResultVo<List<VoDivide>> res = divideSv.getDivides(vo);
+ //if(res.itemTotal != null && res.itemTotal > 0) {
+ // return BaseResponseUtils.buildSuccess(res);
+ //}else {
+ // return BaseResponseUtils.buildSuccess(ProjectResultCode.NO_DIVIDES.getMessage());
+ //}
+ return BaseResponseUtils.buildSuccess(divideSv.getDivides(vo));
} catch (Exception e) {
log.error("鑾峰彇寮�鍗¤褰曞紓甯�", e);
return BaseResponseUtils.buildException(e.getMessage()) ;
@@ -91,10 +97,16 @@
})
@GetMapping(path = "/getone/{id}")
@SsoAop()
- public BaseResponse<PrDivide> getOneDivide(@PathVariable("id") Long id){
+ //public BaseResponse<PrDivide> getOneDivide(@PathVariable("id") Long id){
+ public BaseResponse<VoDivideDetails> getOneDivide(@PathVariable("id") Long id){
try {
- PrDivide res = divideSv.getOneDivide(id);
- return BaseResponseUtils.buildSuccess(res);
+ //PrDivide res = divideSv.getOneDivide(id);
+ //if(res != null) {
+ // return BaseResponseUtils.buildSuccess(res);
+ //}else {
+ // return BaseResponseUtils.buildErrorMsg(ProjectResultCode.NO_DIVIDES.getMessage());
+ //}
+ return BaseResponseUtils.buildSuccess(divideSv.getDivideDetails(id));
} catch (Exception e) {
log.error("鏌ヨ鍐滄埛寮傚父", e);
return BaseResponseUtils.buildException(e.getMessage()) ;
@@ -121,39 +133,40 @@
@SsoAop()
public BaseResponse<Boolean> add(@RequestBody @Valid DtoDivide po, BindingResult bindingResult){
if(bindingResult != null && bindingResult.hasErrors()){
- return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
// 鎺ユ敹鏉戠紪鍙凤紙涓婚敭锛�
Long villageId = po.getVillageId();
- /**
- * 鑾峰彇5绾ц鏀垮尯鍒掍俊鎭�
- */
- Map map_districts = Optional.ofNullable(divideSv.getDistrictsByVillageId(villageId)).orElse(new HashMap());
- if(map_districts.size() <= 0) {
- return BaseResponseUtils.buildFail("鍖哄垝淇℃伅鏈夎");
- }
-
PrDivide prDivide = DtoToDividePojo.INSTANCT.po2vo(po);
- Long countryId = Long.parseLong(map_districts.get("countryId").toString());
- Long townId = Long.parseLong(map_districts.get("townId").toString());
- prDivide.setCountyid(countryId);
- prDivide.setTownid(townId);
+ if (villageId!=null){
+ /**
+ * 鑾峰彇5绾ц鏀垮尯鍒掍俊鎭�
+ */
+ Map map_districts = Optional.ofNullable(divideSv.getDistrictsByVillageId(villageId)).orElse(new HashMap());
+ if(map_districts.size() <= 0) {
+ return BaseResponseUtils.buildErrorMsg("鍖哄垝淇℃伅鏈夎");
+ }
+ Long countryId = Long.parseLong(map_districts.get("countryId").toString());
+ Long townId = Long.parseLong(map_districts.get("townId").toString());
+ prDivide.setCountyid(countryId);
+ prDivide.setTownid(townId);
+ }
Date operateTime = new Date();
prDivide.setOperatedt(operateTime);
prDivide.setDeleted((byte)0);
Integer rec = Optional.ofNullable(divideSv.addDivide(prDivide)).orElse(0);
if(rec == 0) {
- return BaseResponseUtils.buildFail(ProjectResultCode.DIVIDE_FAIL.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.DIVIDE_FAIL.getMessage());
}
return BaseResponseUtils.buildSuccess(true) ;
}
/**
* 鏍规嵁鍒嗘按鎴縄D閫昏緫鍒犻櫎鍒嗘按鎴�
- * @param id
+ * @param map
* @return
*/
@Operation(summary = "鍒犻櫎涓�涓垎姘存埧", description = "鍒犻櫎涓�涓垎姘存埧鏁版嵁")
@@ -166,14 +179,19 @@
)
})
- @GetMapping(path = "/delone/{id}")
+ //@GetMapping(path = "/delone/{id}")
+ @PostMapping(path = "delete", consumes = MediaType.APPLICATION_JSON_VALUE)
@SsoAop()
- public BaseResponse<Boolean> deleteDivideById(@PathVariable("id") Long id){
+ public BaseResponse<Boolean> deleteDivideById(@RequestBody Map map){
+ Long id = Optional.ofNullable(Long.parseLong(map.get("id").toString())).orElse(0L);
+ if(id == 0)
+ return BaseResponseUtils.buildException(ProjectResultCode.DELETE_DIVIDE_FAIL.getMessage());
+
try {
Integer res = Optional.ofNullable(divideSv.deleteDivideById(id)).orElse(0);
- if(res == 0) {
- return BaseResponseUtils.buildFail("鍒嗘按鎴垮垹闄ゅけ璐�");
- }
+ if(res == 0)
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.DELETE_DIVIDE_FAIL.getMessage());
+
return BaseResponseUtils.buildSuccess(true);
} catch (Exception e) {
log.error("鍒犻櫎鍒嗘按鎴垮紓甯�", e);
@@ -199,34 +217,36 @@
@PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
@Transactional(rollbackFor = Exception.class)
@SsoAop()
- public BaseResponse<Boolean> update(@RequestBody @Valid PrDivide po, BindingResult bindingResult){
+ public BaseResponse<Boolean> update(@RequestBody @Valid DtoDivide po, BindingResult bindingResult){
if(bindingResult != null && bindingResult.hasErrors()){
- return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
// 鎺ユ敹鏉戠紪鍙凤紙涓婚敭锛�
- Long villageId = po.getVillageid();
+ Long villageId = po.getVillageId();
- /**
- * 鑾峰彇5绾ц鏀垮尯鍒掍俊鎭�
- */
- Map map_districts = Optional.ofNullable(divideSv.getDistrictsByVillageId(villageId)).orElse(new HashMap());
- if(map_districts.size() <= 0) {
- return BaseResponseUtils.buildFail("鍖哄垝淇℃伅鏈夎");
+ PrDivide prDivide = DtoToDividePojo.INSTANCT.po2vo(po);
+
+ if (villageId!=null){
+ /**
+ * 鑾峰彇5绾ц鏀垮尯鍒掍俊鎭�
+ */
+ Map map_districts = Optional.ofNullable(divideSv.getDistrictsByVillageId(villageId)).orElse(new HashMap());
+ if(map_districts.size() <= 0) {
+ return BaseResponseUtils.buildErrorMsg("鍖哄垝淇℃伅鏈夎");
+ }
+ Long countryId = Long.parseLong(map_districts.get("countryId").toString());
+ Long townId = Long.parseLong(map_districts.get("townId").toString());
+ prDivide.setCountyid(countryId);
+ prDivide.setTownid(townId);
}
- Long countryId = Long.parseLong(map_districts.get("countryId").toString());
- Long townId = Long.parseLong(map_districts.get("townId").toString());
-
- po.setCountyid(countryId);
- po.setTownid(townId);
-
Date operateTime = new Date();
- po.setOperatedt(operateTime);
+ prDivide.setOperatedt(operateTime);
- Integer rec = Optional.ofNullable(divideSv.updateByPrimaryKey(po)).orElse(0);
+ Integer rec = Optional.ofNullable(divideSv.updateByPrimaryKey(prDivide)).orElse(0);
if(rec == 0) {
- return BaseResponseUtils.buildFail("鍒嗘按鎴夸慨鏀瑰け璐�");
+ return BaseResponseUtils.buildErrorMsg("鍒嗘按鎴夸慨鏀瑰け璐�");
}
return BaseResponseUtils.buildSuccess(true) ;
}
--
Gitblit v1.8.0