| | |
| | | package com.gkhy.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import com.gkhy.common.annotation.Log; |
| | | import com.gkhy.common.core.controller.BaseController; |
| | | import com.gkhy.common.core.domain.AjaxResult; |
| | |
| | | import com.gkhy.system.service.ISysPostService; |
| | | import com.gkhy.system.service.ISysRoleService; |
| | | import com.gkhy.system.service.ISysUserService; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 用户信息 |
| | |
| | | return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); |
| | | } |
| | | user.setCreateBy(getUsername()); |
| | | // 检查新密码复杂性 |
| | | if (!isValidPassword(user.getPassword())) { |
| | | return error("新密码必须包含数字和字母,并且可以包含特殊符号,长度至少为8个字符"); |
| | | } |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | return toAjax(userService.insertUser(user)); |
| | | } |
| | |
| | | { |
| | | userService.checkUserAllowed(user); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | | // 检查新密码复杂性 |
| | | if (!isValidPassword(user.getPassword())) { |
| | | return error("新密码必须包含数字和字母,并且可以包含特殊符号,长度至少为8个字符"); |
| | | } |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | user.setUpdateBy(getUsername()); |
| | | return toAjax(userService.resetPwd(user)); |
| | |
| | | { |
| | | return success(deptService.selectDeptTreeList(dept)); |
| | | } |
| | | |
| | | 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); |
| | | } |
| | | } |