|
@@ -88,6 +88,8 @@ public class SysUserController extends BaseController {
|
|
|
private BaseUserService baseUserService;
|
|
|
@Autowired
|
|
|
private ISysDictTypeService dictTypeService;
|
|
|
+ @Value("${base.defaultPassword:yn5aq5Mt.106.tky}")
|
|
|
+ private String defaultPassword;
|
|
|
// /**
|
|
|
// * 获取用户列表
|
|
|
// */
|
|
@@ -176,11 +178,17 @@ public class SysUserController extends BaseController {
|
|
|
@PreAuthorize("@ss.hasPermi('system:user:import')")
|
|
|
@PostMapping("/importData")
|
|
|
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
|
|
|
+ String password=null;
|
|
|
ExcelUtil<SysUsers> util = new ExcelUtil<SysUsers>(SysUsers.class);
|
|
|
List<SysUsers> userList = util.importExcel(file.getInputStream());
|
|
|
String userId = getUserId();
|
|
|
List<SysDictData> data = dictTypeService.selectDictDataByType("default_password");
|
|
|
- String message = userService.importUser(userList, updateSupport, userId,data.get(0).getDictValue());
|
|
|
+ if(!ObjectUtils.isEmpty(data.get(0).getDictValue())){
|
|
|
+ password=data.get(0).getDictValue();
|
|
|
+ }else {
|
|
|
+ password=defaultPassword;
|
|
|
+ }
|
|
|
+ String message = userService.importUser(userList, updateSupport, userId,password);
|
|
|
return success(message);
|
|
|
}
|
|
|
|
|
@@ -236,13 +244,19 @@ public class SysUserController extends BaseController {
|
|
|
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
|
|
@PostMapping("/add")
|
|
|
public AjaxResult add(@Validated @RequestBody SysUser user) {
|
|
|
+ String password=null;
|
|
|
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user))) {
|
|
|
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
|
|
}
|
|
|
user.setCreateBy(getUserId());
|
|
|
user.setUpdateBy(getUserId());
|
|
|
List<SysDictData> data = dictTypeService.selectDictDataByType("default_password");
|
|
|
- user.setPassword(SecurityUtils.encryptPassword(data.get(0).getDictValue()));
|
|
|
+ if(!ObjectUtils.isEmpty(data.get(0).getDictValue())){
|
|
|
+ password=data.get(0).getDictValue();
|
|
|
+ }else {
|
|
|
+ password=defaultPassword;
|
|
|
+ }
|
|
|
+ user.setPassword(SecurityUtils.encryptPassword(password));
|
|
|
return toAjax(userService.saveUser(user));
|
|
|
}
|
|
|
|
|
@@ -341,10 +355,16 @@ public class SysUserController extends BaseController {
|
|
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
@GetMapping("/resetPwd/{id}")
|
|
|
public AjaxResult resetPwd(@PathVariable(value = "id") Long id) {
|
|
|
+ String password=null;
|
|
|
SysUser user = new SysUser();
|
|
|
user.setId(id);
|
|
|
List<SysDictData> data = dictTypeService.selectDictDataByType("default_password");
|
|
|
- user.setPassword(SecurityUtils.encryptPassword(data.get(0).getDictValue()));
|
|
|
+ if(!ObjectUtils.isEmpty(data.get(0).getDictValue())){
|
|
|
+ password=data.get(0).getDictValue();
|
|
|
+ }else {
|
|
|
+ password=defaultPassword;
|
|
|
+ }
|
|
|
+ user.setPassword(SecurityUtils.encryptPassword(password));
|
|
|
user.setUpdateBy(getUsername());
|
|
|
return toAjax(userService.resetPwd(user));
|
|
|
}
|