|  |  | 
 |  |  | import com.dy.common.webUtil.BaseResponseUtils; | 
 |  |  | import com.dy.common.webUtil.QueryResultVo; | 
 |  |  | import com.dy.common.webUtil.ResultCodeMsg; | 
 |  |  | import com.dy.pipIrrBase.result.SystemResultCode; | 
 |  |  | import com.dy.pipIrrGlobal.pojoBa.BaUser; | 
 |  |  | import com.dy.pipIrrGlobal.util.Constant; | 
 |  |  | import com.dy.pipIrrGlobal.voBa.VoUserInfo; | 
 |  |  | import com.mysql.cj.util.StringUtils; | 
 |  |  | 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; | 
 |  |  | 
 |  |  |     private void setSv(UserSv sv) { | 
 |  |  |         this.sv = sv; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 客户端请求得到默认密码 | 
 |  |  | 
 |  |  |                             schema = @Schema(implementation = BaUser.class))} | 
 |  |  |             ) | 
 |  |  |     }) | 
 |  |  |     @PostMapping(path = "some", consumes = MediaType.APPLICATION_JSON_VALUE) | 
 |  |  |     @SsoAop("-1") | 
 |  |  |     public BaseResponse<QueryResultVo<List<BaUser>>> some(@RequestBody @Parameter(description = "查询form表单json数据", required = true) @Valid QueryVo vo) { | 
 |  |  |     @GetMapping(path = "some") | 
 |  |  |     //@PostMapping(path = "some", consumes = MediaType.APPLICATION_JSON_VALUE) | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<QueryResultVo<List<VoUserInfo>>> some(QueryVo vo) { | 
 |  |  |         try { | 
 |  |  |             QueryResultVo<List<BaUser>> res = this.sv.selectSome(vo); | 
 |  |  |             return BaseResponseUtils.buildSuccess(res); | 
 |  |  |             QueryResultVo<List<VoUserInfo>> res = this.sv.selectSome(vo); | 
 |  |  |             if(res.itemTotal == 0) { | 
 |  |  |                 return BaseResponseUtils.buildFail(SystemResultCode.THE_USER_NOT_EXIST.getMessage()); | 
 |  |  |             }else { | 
 |  |  |                 return BaseResponseUtils.buildSuccess(res); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             log.error("查询用户异常", e); | 
 |  |  |             return BaseResponseUtils.buildException(e.getMessage()); | 
 |  |  | 
 |  |  |                             schema = @Schema(implementation = BaUser.class))} | 
 |  |  |             ) | 
 |  |  |     }) | 
 |  |  |     @GetMapping(path = "one", consumes = MediaType.TEXT_PLAIN_VALUE) | 
 |  |  |     @SsoAop("-1") | 
 |  |  |     public BaseResponse<BaUser> one(@Parameter(description = "实体id", required = true) String id) { | 
 |  |  |     //@GetMapping(path = "one", consumes = MediaType.TEXT_PLAIN_VALUE) | 
 |  |  |     @GetMapping(path = "one") | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<BaUser> one(String id) { | 
 |  |  |         return BaseResponseUtils.buildSuccess(this.sv.selectById(Long.parseLong(id))); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |             ) | 
 |  |  |     }) | 
 |  |  |     @PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE) | 
 |  |  |     @SsoAop("-1")//@SsoAop(power = "-1") | 
 |  |  |     public BaseResponse<Boolean> save(@RequestBody @Parameter(description = "form表单json数据", required = true) @Valid BaUser po, @Parameter(hidden = true) BindingResult bindingResult) { | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<Boolean> save(@RequestBody @Valid BaUser po, BindingResult bindingResult) { | 
 |  |  |         if (bindingResult != null && bindingResult.hasErrors()) { | 
 |  |  |             return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); | 
 |  |  |         } | 
 |  |  |         po.id = null; | 
 |  |  |         int count; | 
 |  |  |         Long userId; | 
 |  |  |         try { | 
 |  |  |             po.supperAdmin = Constant.no.byteValue() ; | 
 |  |  |             po.disabled = Disabled.NO;//默认不禁用 | 
 |  |  | 
 |  |  |             } else { | 
 |  |  |                 po.password = MD5.encrypt(defaultPassword); | 
 |  |  |             } | 
 |  |  |             count = this.sv.save(po); | 
 |  |  |             this.sv.setRoles(po.id, po.roleIds); | 
 |  |  |             userId = this.sv.save(po); | 
 |  |  |             this.sv.setRoles(userId, po.roleIds); | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             log.error("保存用户异常", e); | 
 |  |  |             return BaseResponseUtils.buildException(e.getMessage()); | 
 |  |  |         } | 
 |  |  |         if (count <= 0) { | 
 |  |  |         if (userId <= 0) { | 
 |  |  |             return BaseResponseUtils.buildFail("数据库存储失败"); | 
 |  |  |         } else { | 
 |  |  |             return BaseResponseUtils.buildSuccess(true); | 
 |  |  | 
 |  |  |             ) | 
 |  |  |     }) | 
 |  |  |     @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE) | 
 |  |  |     @SsoAop("-1")//@SsoAop(power = "-1") | 
 |  |  |     public BaseResponse<Boolean> update(@RequestBody @Parameter(description = "form表单json数据", required = true) @Valid BaUser po, @Parameter(hidden = true) BindingResult bindingResult) { | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<Boolean> update(@RequestBody @Valid BaUser po, BindingResult bindingResult) { | 
 |  |  |         if (bindingResult != null && bindingResult.hasErrors()) { | 
 |  |  |             return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); | 
 |  |  |         } | 
 |  |  | 
 |  |  |             po.supperAdmin = null;//设置为null,不做更新 | 
 |  |  |             po.deleted = null;//设置为null,不做更新 | 
 |  |  |             po.orgTag = null;//设置为null,不做更新 | 
 |  |  |             po.password =  MD5.encrypt(po.password);//进行加密 | 
 |  |  |             count = this.sv.update(po); | 
 |  |  |             this.sv.setRoles(po.id, po.roleIds); | 
 |  |  |         } catch (Exception e) { | 
 |  |  | 
 |  |  |                             schema = @Schema(implementation = Boolean.class))} | 
 |  |  |             ) | 
 |  |  |     }) | 
 |  |  |     @GetMapping(path = "changePassword", consumes = MediaType.TEXT_PLAIN_VALUE) | 
 |  |  |     @SsoAop("-1")//@SsoAop(power = "-1") | 
 |  |  |     public BaseResponse<Boolean> changePassword(@Parameter(description = "实体id", required = true) String id, | 
 |  |  |                                                 @Parameter(description = "旧密码", required = true) String oldPassword, | 
 |  |  |                                                 @Parameter(description = "新密码", required = true) String newPassword) throws Exception { | 
 |  |  |     //@GetMapping(path = "changePassword", consumes = MediaType.TEXT_PLAIN_VALUE) | 
 |  |  |     @GetMapping(path = "changePassword") | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<Boolean> changePassword(String id, String oldPassword, String newPassword) throws Exception { | 
 |  |  |         if (id == null) { | 
 |  |  |             return BaseResponseUtils.buildFail("id不能为空"); | 
 |  |  |         } | 
 |  |  | 
 |  |  |             ) | 
 |  |  |     }) | 
 |  |  |     @PostMapping(path = "resetPassword", consumes = MediaType.APPLICATION_JSON_VALUE) | 
 |  |  |     @SsoAop("-1")//@SsoAop(power = "-1") | 
 |  |  |     public BaseResponse<Boolean> resetPassword(@RequestBody @Parameter(description = "form表单json数据", required = true) ResetPasswordVo vo) throws Exception { | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<Boolean> resetPassword(@RequestBody  ResetPasswordVo vo) throws Exception { | 
 |  |  |         if (vo.id == null) { | 
 |  |  |             return BaseResponseUtils.buildFail("id不能为空"); | 
 |  |  |         } | 
 |  |  | 
 |  |  |             ) | 
 |  |  |     }) | 
 |  |  |     @GetMapping(path = "resetPasswordByDefault", consumes = MediaType.TEXT_PLAIN_VALUE) | 
 |  |  |     @SsoAop("-1")//@SsoAop(power = "-1") | 
 |  |  |     public BaseResponse<Boolean> resetPasswordByDefault(@Parameter(description = "实体id", required = true) String id) throws Exception { | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<Boolean> resetPasswordByDefault(String id) throws Exception { | 
 |  |  |         if (id == null) { | 
 |  |  |             return BaseResponseUtils.buildFail("id不能为空"); | 
 |  |  |         } | 
 |  |  | 
 |  |  |             ) | 
 |  |  |     }) | 
 |  |  |     @GetMapping(path = "resetPasswordByRandom", consumes = MediaType.TEXT_PLAIN_VALUE) | 
 |  |  |     @SsoAop("-1")//@SsoAop(power = "-1") | 
 |  |  |     public BaseResponse<String> resetPasswordByRandom(@Parameter(description = "实体id", required = true) String id) throws Exception { | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<String> resetPasswordByRandom(String id) throws Exception { | 
 |  |  |         if (id == null) { | 
 |  |  |             return BaseResponseUtils.buildFail("id不能为空"); | 
 |  |  |         } | 
 |  |  | 
 |  |  |             ) | 
 |  |  |     }) | 
 |  |  |     @GetMapping(path = "setRoles", consumes = MediaType.TEXT_PLAIN_VALUE) | 
 |  |  |     @SsoAop("-1")//@SsoAop(power = "-1") | 
 |  |  |     public BaseResponse<Boolean> setRoles(@Parameter(description = "实体id", required = true) String id, | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<Boolean> setRoles(String id, | 
 |  |  |                                           @Parameter(description = "角色id数组") String[] roleIds) { | 
 |  |  |         Long[] roleId_lg = null; | 
 |  |  |         if (roleIds != null && roleIds.length > 0) { | 
 |  |  | 
 |  |  |                             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) String id) { | 
 |  |  |     //@GetMapping(path = "delete", consumes = MediaType.TEXT_PLAIN_VALUE) | 
 |  |  |     @GetMapping(path = "delete") | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<Boolean> delete(String id) { | 
 |  |  |         if (id == null) { | 
 |  |  |             return BaseResponseUtils.buildFail("id不能为空"); | 
 |  |  |         } | 
 |  |  | 
 |  |  |             return BaseResponseUtils.buildException(e.getMessage()); | 
 |  |  |         } | 
 |  |  |         if (count <= 0) { | 
 |  |  |             return BaseResponseUtils.buildFail("数据库存储失败"); | 
 |  |  |             return BaseResponseUtils.buildFail(SystemResultCode.USER_NOT_EXIST.getMessage()); | 
 |  |  |         } else { | 
 |  |  |             return BaseResponseUtils.buildSuccess(true); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 根据用户编号获取用户信息 | 
 |  |  |      * @param userId 用户编号 | 
 |  |  |      * @return 用户信息列表 | 
 |  |  |      */ | 
 |  |  |     @Operation(summary = "获得全部用户信息", description = "返回全部用户信息数据") | 
 |  |  |     @ApiResponses(value = { | 
 |  |  |             @ApiResponse( | 
 |  |  |                     responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, | 
 |  |  |                     description = "返回全部用户数据(BaseResponse.content:QueryResultVo[{}])", | 
 |  |  |                     content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, | 
 |  |  |                             schema = @Schema(implementation = BaUser.class))} | 
 |  |  |             ) | 
 |  |  |     }) | 
 |  |  |     @GetMapping("/getUserInfos/{userId}") | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<QueryResultVo<VoUserInfo>> getUserInfos(@PathVariable("userId") Long userId) { | 
 |  |  |         try { | 
 |  |  |             VoUserInfo res = this.sv.getUserInfos(userId); | 
 |  |  |             if(res == null) { | 
 |  |  |                 return BaseResponseUtils.buildException(SystemResultCode.THE_USER_NOT_EXIST.getMessage()); | 
 |  |  |             } | 
 |  |  |             System.out.println("   :" + res); | 
 |  |  |             return BaseResponseUtils.buildSuccess(res); | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             log.error("查询用户信息异常", e); | 
 |  |  |             return BaseResponseUtils.buildException(e.getMessage()); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | } |