From 2938172b377e5ed7a55e5dde4a218244445e8a6e Mon Sep 17 00:00:00 2001 From: wuzeyu <1223318623@qq.com> Date: 星期三, 15 五月 2024 17:10:12 +0800 Subject: [PATCH] 田间灌溉项目管理 修改项目信息接口 修改项目状态接口 --- pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectCtrl.java | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 109 insertions(+), 4 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectCtrl.java index 409ed4e..ddcbe74 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectCtrl.java @@ -24,9 +24,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; +import java.lang.reflect.Array; +import java.util.*; /** * @author :WuZeYu @@ -77,6 +76,20 @@ return BaseResponseUtils.buildSuccess(true); } + /** + * 閫昏緫鍒犻櫎椤圭洰 + * @param map + * @return + */ + @Operation(summary = "閫昏緫鍒犻櫎椤圭洰", description = "閫昏緫鍒犻櫎椤圭洰") + @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 = "delete", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() @@ -84,7 +97,7 @@ if (map == null || map.size() <= 0) { BaseResponseUtils.buildFail(IrrigateResultCode.PLEASE_INPUT_PROJECT_ID.getMessage()); } - Long projectId = Long.parseLong(map.get("projectId").toString()); + Long projectId = Long.parseLong(map.get("id").toString()); try { Integer rows = projectSv.deleteProject(projectId); if (rows == 0) { @@ -96,4 +109,96 @@ } return BaseResponseUtils.buildSuccess(true); } + + /** + * 鎵归噺鍒犻櫎 + * @param projectIds + * @return + */ + @PostMapping(path = "delete_batch", consumes = MediaType.APPLICATION_JSON_VALUE) + @Transactional(rollbackFor = Exception.class) + @SsoAop() + public BaseResponse<Boolean> delete_batch(@RequestBody List<Long> projectIds) { + if (projectIds == null || projectIds.size() <= 0) { + BaseResponseUtils.buildFail(IrrigateResultCode.PLEASE_INPUT_PROJECT_ID.getMessage()); + } + for (int i = 0; i < projectIds.size(); i++) { + Long projectId = projectIds.get(i); + try { + Integer rows = projectSv.deleteProject(projectId); + if (rows == 0) { + return BaseResponseUtils.buildFail(IrrigateResultCode.DELETE_PROJECT_FAIL.getMessage()); + } + } catch (Exception e) { + log.error("鍒犻櫎椤圭洰寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + } + return BaseResponseUtils.buildSuccess(true); + } + + /** + * 淇敼椤圭洰淇℃伅 + * @param po + * @param bindingResult + * @return + */ + @Operation(summary = "淇敼椤圭洰淇℃伅", description = "淇敼椤圭洰淇℃伅") + @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) + @Transactional(rollbackFor = Exception.class) + @SsoAop() + public BaseResponse<Boolean> update(@RequestBody @Valid IrProject po, BindingResult bindingResult){ + if (bindingResult != null && bindingResult.hasErrors()) { + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + try { + Integer rec = Optional.ofNullable(projectSv.updateProject(po)).orElse(0); + if (rec == 0) { + return BaseResponseUtils.buildFail(IrrigateResultCode.UPDATE_PROJECT_FAIL.getMessage()); + } + } catch (Exception e) { + log.error("淇敼椤圭洰寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + return BaseResponseUtils.buildSuccess(true); + } + + /** + * 淇敼椤圭洰鐘舵�� + * @param po + * @param + * @return + */ + @Operation(summary = "淇敼椤圭洰鐘舵��", description = "淇敼椤圭洰鐘舵��") + @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_state", consumes = MediaType.APPLICATION_JSON_VALUE) + @Transactional(rollbackFor = Exception.class) + @SsoAop() + public BaseResponse<Boolean> update_state(@RequestBody IrProject po){ + try { + Integer rec = Optional.ofNullable(projectSv.updateProjectState(po)).orElse(0); + if (rec == 0) { + return BaseResponseUtils.buildFail(IrrigateResultCode.UPDATE_PROJECT_FAIL.getMessage()); + } + } catch (Exception e) { + log.error("淇敼椤圭洰寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + return BaseResponseUtils.buildSuccess(true); + } } -- Gitblit v1.8.0