From 91f1c973ae463e3994c8e9bb62ce1545b04642f2 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期五, 14 六月 2024 11:07:01 +0800 Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV --- pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java | 98 +++++++++++++++++++++++++++++-------------------- 1 files changed, 58 insertions(+), 40 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 64e007f..389bf86 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 @@ -68,7 +68,11 @@ public BaseResponse<QueryResultVo<List<VoDivide>>> getDivides(QueryVo vo){ try { QueryResultVo<List<VoDivide>> res = divideSv.getDivides(vo); - return BaseResponseUtils.buildSuccess(res); + if(res.itemTotal != null && res.itemTotal > 0) { + return BaseResponseUtils.buildSuccess(res); + }else { + return BaseResponseUtils.buildFail(ProjectResultCode.NO_DIVIDES.getMessage()); + } } catch (Exception e) { log.error("鑾峰彇寮�鍗¤褰曞紓甯�", e); return BaseResponseUtils.buildException(e.getMessage()) ; @@ -94,7 +98,11 @@ public BaseResponse<PrDivide> getOneDivide(@PathVariable("id") Long id){ try { PrDivide res = divideSv.getOneDivide(id); - return BaseResponseUtils.buildSuccess(res); + if(res != null) { + return BaseResponseUtils.buildSuccess(res); + }else { + return BaseResponseUtils.buildFail(ProjectResultCode.NO_DIVIDES.getMessage()); + } } catch (Exception e) { log.error("鏌ヨ鍐滄埛寮傚父", e); return BaseResponseUtils.buildException(e.getMessage()) ; @@ -119,30 +127,33 @@ @PostMapping(path = "add", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() - public BaseResponse<Boolean> add(@RequestBody @Valid PrDivide po, BindingResult bindingResult){ + public BaseResponse<Boolean> add(@RequestBody @Valid DtoDivide po, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(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.buildFail("鍖哄垝淇℃伅鏈夎"); + } + 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); - po.setDeleted((byte)0); - Integer rec = Optional.ofNullable(divideSv.addDivide(po)).orElse(0); + 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()); } @@ -151,7 +162,7 @@ /** * 鏍规嵁鍒嗘按鎴縄D閫昏緫鍒犻櫎鍒嗘按鎴� - * @param id + * @param map * @return */ @Operation(summary = "鍒犻櫎涓�涓垎姘存埧", description = "鍒犻櫎涓�涓垎姘存埧鏁版嵁") @@ -164,14 +175,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.buildFail(ProjectResultCode.DELETE_DIVIDE_FAIL.getMessage()); + return BaseResponseUtils.buildSuccess(true); } catch (Exception e) { log.error("鍒犻櫎鍒嗘按鎴垮紓甯�", e); @@ -197,32 +213,34 @@ @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()); } // 鎺ユ敹鏉戠紪鍙凤紙涓婚敭锛� - 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.buildFail("鍖哄垝淇℃伅鏈夎"); + } + 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("鍒嗘按鎴夸慨鏀瑰け璐�"); } -- Gitblit v1.8.0