From 0aff5bb92375038af4d634c7fbe1459b979b45a3 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期一, 27 十一月 2023 20:01:37 +0800 Subject: [PATCH] 修改枚举类型转json问题 --- pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/role/RoleCtrl.java | 62 +++++++++++++++++++++++------- 1 files changed, 47 insertions(+), 15 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/role/RoleCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/role/RoleCtrl.java index 9cc6bd7..0e1704e 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/role/RoleCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/role/RoleCtrl.java @@ -20,10 +20,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; @@ -55,11 +52,11 @@ schema = @Schema(implementation = BaRole.class))} ) }) - @PostMapping(path = "all") + @GetMapping(path = "all") @SsoAop("-1") - public BaseResponse<QueryResultVo<List<BaRole>>> all(QueryVo vo){ + public BaseResponse<QueryResultVo<List<BaRole>>> all(){ try { - QueryResultVo<List<BaRole>> res = this.sv.selectAll(vo) ; + QueryResultVo<List<BaRole>> res = this.sv.selectAll() ; return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { log.error("鏌ヨ瑙掕壊寮傚父", e); @@ -68,7 +65,7 @@ } /** - * 瀹㈡埛绔姹傚緱鍒版墍鏈夎鑹叉暟鎹� + * 瀹㈡埛绔姹傚緱鍒颁竴椤佃鑹叉暟鎹� * @return 鎵�鏈夎鑹叉暟鎹� */ @Operation(summary = "鑾峰緱涓�椤佃鑹�", description = "杩斿洖涓�椤佃鑹叉暟鎹�") @@ -80,9 +77,9 @@ schema = @Schema(implementation = BaRole.class))} ) }) - @PostMapping(path = "some") + @PostMapping(path = "some", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop("-1") - public BaseResponse<QueryResultVo<List<BaRole>>> some(QueryVo vo){ + public BaseResponse<QueryResultVo<List<BaRole>>> some(@RequestBody @Parameter(description = "鏌ヨform琛ㄥ崟json鏁版嵁", required = true) @Valid QueryVo vo){ try { QueryResultVo<List<BaRole>> res = this.sv.selectSome(vo) ; return BaseResponseUtils.buildSuccess(res); @@ -105,7 +102,7 @@ schema = @Schema(implementation = BaRole.class))} ) }) - @GetMapping(path = "one") + @GetMapping(path = "one", consumes = MediaType.TEXT_PLAIN_VALUE) @SsoAop("-1") public BaseResponse<BaRole> one(@Parameter(description = "瀹炰綋id", required = true) Long id){ return BaseResponseUtils.buildSuccess(this.sv.selectById(id)); @@ -125,9 +122,9 @@ schema = @Schema(implementation = Boolean.class))} ) }) - @PostMapping(path = "save", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop("-1")//@SsoAop(power = "-1") - public BaseResponse<Boolean> save(@Parameter(description = "form琛ㄥ崟鏁版嵁", required = true) @Valid BaRole po, @Parameter(hidden = true) BindingResult bindingResult){ + public BaseResponse<Boolean> save(@RequestBody @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid BaRole po, @Parameter(hidden = true) BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } @@ -161,9 +158,9 @@ schema = @Schema(implementation = Boolean.class))} ) }) - @PostMapping(path = "update", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop("-1")//@SsoAop(power = "-1") - public BaseResponse<Boolean> update(@Parameter(description = "form琛ㄥ崟鏁版嵁", required = true) @Valid BaRole po, @Parameter(hidden = true) BindingResult bindingResult){ + public BaseResponse<Boolean> update(@RequestBody @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid BaRole po, @Parameter(hidden = true) BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } @@ -186,6 +183,41 @@ } + + /** + * 璁剧疆瑙掕壊鏉冮檺 + * @param id 瑙掕壊ID + * @return 鏄惁鎴愬姛 + */ + @Operation(summary = "璁剧疆瑙掕壊鏉冮檺", description = "鎻愪氦瑙掕壊ID锛屽強鎵�閫夋嫨鐨勬潈闄怚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 = "setPrivs", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop("-1")//@SsoAop(power = "-1") + public BaseResponse<Boolean> setPrivileges(@Parameter(description = "瀹炰綋id", required = true) Long id, + @Parameter(description = "鏉冮檺id鏁扮粍") Long[] privIds){ + Long[] privIds_lg = null ; + if(privIds != null && privIds.length > 0){ + privIds_lg = new Long[privIds.length] ; + int index = 0 ; + for(Long privId : privIds){ + privIds_lg[index++] = privId ; + } + } + try { + this.sv.setRoles(id, privIds_lg); + } catch (Exception e) { + log.error("淇濆瓨鐢ㄦ埛寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + return BaseResponseUtils.buildSuccess(true) ; + } /** * 鍒犻櫎瑙掕壊 * @param id 瑙掕壊ID -- Gitblit v1.8.0