From d76ee745d82d0525f88d9eeebed23961130ccccd Mon Sep 17 00:00:00 2001 From: Administrator <zhubaomin> Date: 星期二, 09 一月 2024 15:22:57 +0800 Subject: [PATCH] 2024-01-09 朱宝民 重构农户查询接口 --- pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/block/BlockCtrl.java | 59 ++++++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 42 insertions(+), 17 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/block/BlockCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/block/BlockCtrl.java index 3b356a9..0e864db 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/block/BlockCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/block/BlockCtrl.java @@ -7,7 +7,6 @@ import com.dy.common.webUtil.ResultCodeMsg; import com.dy.pipIrrGlobal.pojoBa.BaBlock; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -18,10 +17,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.List; import java.util.Objects; @@ -44,6 +40,31 @@ * 瀹㈡埛绔姹傚緱鍒版墍鏈夌墖鍖烘暟鎹� * @return 鎵�鏈夌墖鍖烘暟鎹� */ + @Operation(summary = "鑾峰緱鍏ㄩ儴鐗囧尯", description = "杩斿洖鍏ㄩ儴鐗囧尯鏁版嵁") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "杩斿洖鍏ㄩ儴鐗囧尯鏁版嵁锛圔aseResponse.content:QueryResultVo[{}]锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = BaBlock.class))} + ) + }) + @GetMapping(path = "all") + @SsoAop() + public BaseResponse<QueryResultVo<List<BaBlock>>> all(){ + try { + QueryResultVo<List<BaBlock>> res = this.sv.selectAll() ; + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鏌ヨ鐗囧尯寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + /** + * 瀹㈡埛绔姹傚緱鍒版墍鏈夌墖鍖烘暟鎹� + * @return 鎵�鏈夌墖鍖烘暟鎹� + */ @Operation(summary = "鑾峰緱涓�椤电墖鍖�", description = "杩斿洖涓�椤电墖鍖烘暟鎹�") @ApiResponses(value = { @ApiResponse( @@ -53,8 +74,9 @@ schema = @Schema(implementation = BaBlock.class))} ) }) - @PostMapping(path = "some") - public BaseResponse<QueryResultVo<List<BaBlock>>> some(QueryVo vo){ + @PostMapping(path = "some", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<QueryResultVo<List<BaBlock>>> some(@RequestBody QueryVo vo){ try { QueryResultVo<List<BaBlock>> res = this.sv.selectSome(vo) ; return BaseResponseUtils.buildSuccess(res); @@ -77,8 +99,10 @@ schema = @Schema(implementation = BaBlock.class))} ) }) + //@GetMapping(path = "one", consumes = MediaType.TEXT_PLAIN_VALUE) @GetMapping(path = "one") - public BaseResponse<BaBlock> one(@Parameter(description = "瀹炰綋id", required = true) Long id){ + @SsoAop() + public BaseResponse<BaBlock> one(Long id){ return BaseResponseUtils.buildSuccess(this.sv.selectById(id)); } @@ -96,9 +120,9 @@ schema = @Schema(implementation = Boolean.class))} ) }) - @PostMapping(path = "save", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - @SsoAop("-1")//@SsoAop(power = "-1") - public BaseResponse<Boolean> save(@Parameter(description = "form琛ㄥ崟鏁版嵁", required = true) @Valid BaBlock po, @Parameter(hidden = true) BindingResult bindingResult){ + @PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<Boolean> save(@RequestBody @Valid BaBlock po, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } @@ -131,9 +155,9 @@ 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 BaBlock po, @Parameter(hidden = true) BindingResult bindingResult){ + @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<Boolean> update(@RequestBody @Valid BaBlock po, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } @@ -169,9 +193,10 @@ 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){ + //@GetMapping(path = "delete", consumes = MediaType.TEXT_PLAIN_VALUE) + @GetMapping(path = "delete") + @SsoAop() + public BaseResponse<Boolean> delete(Long id){ if(id == null){ return BaseResponseUtils.buildFail("id涓嶈兘涓虹┖") ; } -- Gitblit v1.8.0