|
|
@ -5,7 +5,11 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
|
import cn.hutool.extra.pinyin.PinyinUtil;
|
|
|
|
import cn.hutool.extra.pinyin.PinyinUtil;
|
|
|
|
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
|
|
|
|
|
|
|
import com.ruoyi.system.domain.UserCheckDTO;
|
|
|
|
|
|
|
|
import com.ruoyi.system.service.*;
|
|
|
|
import com.ruoyi.web.controller.manager.UserRecordManager;
|
|
|
|
import com.ruoyi.web.controller.manager.UserRecordManager;
|
|
|
|
|
|
|
|
import lombok.val;
|
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
@ -31,10 +35,6 @@ import com.ruoyi.common.utils.StringUtils;
|
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
|
import com.ruoyi.framework.shiro.service.SysPasswordService;
|
|
|
|
import com.ruoyi.framework.shiro.service.SysPasswordService;
|
|
|
|
import com.ruoyi.framework.shiro.util.AuthorizationUtils;
|
|
|
|
import com.ruoyi.framework.shiro.util.AuthorizationUtils;
|
|
|
|
import com.ruoyi.system.service.ISysDeptService;
|
|
|
|
|
|
|
|
import com.ruoyi.system.service.ISysPostService;
|
|
|
|
|
|
|
|
import com.ruoyi.system.service.ISysRoleService;
|
|
|
|
|
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 用户信息
|
|
|
|
* 用户信息
|
|
|
@ -65,6 +65,9 @@ public class SysUserController extends BaseController {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private UserRecordManager userRecordManager;
|
|
|
|
private UserRecordManager userRecordManager;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ISysDictDataService dictDataService;
|
|
|
|
|
|
|
|
|
|
|
|
@RequiresPermissions("system:user:view")
|
|
|
|
@RequiresPermissions("system:user:view")
|
|
|
|
@GetMapping()
|
|
|
|
@GetMapping()
|
|
|
|
public String user() {
|
|
|
|
public String user() {
|
|
|
@ -134,6 +137,15 @@ public class SysUserController extends BaseController {
|
|
|
|
} else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
|
|
|
|
} else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
|
|
|
|
return error("新增用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
|
|
|
|
return error("新增用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
List<SysDictData> smType = dictDataService.selectDictDataByType("sys_role_key");
|
|
|
|
|
|
|
|
UserCheckDTO userCheckDTO = new UserCheckDTO();
|
|
|
|
|
|
|
|
userCheckDTO.setDeptId(user.getDeptId());
|
|
|
|
|
|
|
|
userCheckDTO.setRoleId(user.getRoleIds()[0]);
|
|
|
|
|
|
|
|
userCheckDTO.setRoleKey(smType.get(0).getDictValue());
|
|
|
|
|
|
|
|
int total = userService.checkUser(userCheckDTO);
|
|
|
|
|
|
|
|
if(total>=1){
|
|
|
|
|
|
|
|
return error("新增用户'" + user.getLoginName() + "'在当前部门该角色下账号已存在,不能重复新增");
|
|
|
|
|
|
|
|
}
|
|
|
|
user.setSalt(ShiroUtils.randomSalt());
|
|
|
|
user.setSalt(ShiroUtils.randomSalt());
|
|
|
|
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
|
|
|
|
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
|
|
|
|
user.setCreateBy(getLoginName());
|
|
|
|
user.setCreateBy(getLoginName());
|
|
|
@ -357,4 +369,11 @@ public class SysUserController extends BaseController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/checkUser")
|
|
|
|
|
|
|
|
@ResponseBody
|
|
|
|
|
|
|
|
public AjaxResult checkUser(UserCheckDTO userCheckDTO) {
|
|
|
|
|
|
|
|
return success(userService.checkUser(userCheckDTO));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|