|  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  |                             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); | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 客户端请求得到所有角色数据 | 
 |  |  |      * 客户端请求得到一页角色数据 | 
 |  |  |      * @return 所有角色数据 | 
 |  |  |      */ | 
 |  |  |     @Operation(summary = "获得一页角色", description = "返回一页角色数据") | 
 |  |  | 
 |  |  |                             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); | 
 |  |  | 
 |  |  |                             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)); | 
 |  |  | 
 |  |  |                             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()); | 
 |  |  |         } | 
 |  |  | 
 |  |  |                             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()); | 
 |  |  |         } | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 设置角色权限 | 
 |  |  |      * @param id 角色ID | 
 |  |  |      * @return 是否成功 | 
 |  |  |      */ | 
 |  |  |     @Operation(summary = "设置角色权限", description = "提交角色ID,及所选择的权限ID集合(数组)") | 
 |  |  |     @ApiResponses(value = { | 
 |  |  |             @ApiResponse( | 
 |  |  |                     responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, | 
 |  |  |                     description = "操作结果:true:成功,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 |