| | |
| | | package com.gkhy.web.controller.system; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/system/user/profile") |
| | | @Api(tags = "基础信息修改") |
| | | public class SysProfileController extends BaseController |
| | | { |
| | | @Autowired |
| | |
| | | */ |
| | | @Log(title = "个人信息", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/updatePwd") |
| | | public AjaxResult updatePwd(String oldPassword, String newPassword) |
| | | @ApiOperation(value = "修改密码") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "query", name = "oldPassword", dataType = "String", required = true, value = "原密码"), |
| | | @ApiImplicitParam(paramType = "query", name = "newPassword", dataType = "String", required = true, value = "新密码") |
| | | }) |
| | | public AjaxResult updatePwd(@RequestParam("oldPassword") String oldPassword, @RequestParam("newPassword")String newPassword) |
| | | { |
| | | LoginUser loginUser = getLoginUser(); |
| | | String userName = loginUser.getUsername(); |
| | |
| | | { |
| | | return error("新密码不能与旧密码相同"); |
| | | } |
| | | // 检查新密码复杂性 |
| | | if (!isValidPassword(newPassword)) { |
| | | return error("新密码必须包含数字和字母,并且可以包含特殊符号,长度至少为8个字符"); |
| | | } |
| | | |
| | | newPassword = SecurityUtils.encryptPassword(newPassword); |
| | | if (userService.resetUserPwd(userName, newPassword) > 0) |
| | | { |
| | |
| | | return error("修改密码异常,请联系管理员"); |
| | | } |
| | | |
| | | // 添加密码复杂性检查方法 |
| | | private static boolean isValidPassword(String password) { |
| | | // 正则表达式检查密码是否包含数字和字母,并且长度至少为8个字符 |
| | | //String passwordPattern = "^(?=.*[0-9])(?=.*[a-zA-Z]).{8,}$"; |
| | | String passwordPattern = "^(?=.*[0-9])(?=.*[a-zA-Z])[a-zA-Z0-9@#$%^&+=]{8,}$"; |
| | | return password.matches(passwordPattern); |
| | | } |
| | | /** |
| | | * 头像上传 |
| | | */ |