限制最多3个幼儿园管理员角色
This commit is contained in:
parent
3675d38c5a
commit
66a0bab855
@ -184,6 +184,23 @@ public class SysUserController extends BaseController {
|
||||
} else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
|
||||
//判断当前学校有多少个幼儿园管理员 需求至多3个幼儿园管理员
|
||||
Long[] roleIds = user.getRoleIds();
|
||||
int iCount = 0;
|
||||
if (roleIds.length > 0) {
|
||||
System.out.println(roleIds.length);
|
||||
for (int i = 0; i < roleIds.length; i++) {
|
||||
if (roleIds[i] == 100) {
|
||||
iCount = userService.countUserSchoolAdminRoleByDeptId(user.getDeptId(), roleIds[i]);
|
||||
if (iCount >= 3) {
|
||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,当前学校管理员角色最多设置3人");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
user.setPhonenumber(user.getUserName());
|
||||
user.setEmail(user.getUserName() + "@benyi.com");
|
||||
user.setCreateBy(SecurityUtils.getUsername());
|
||||
@ -215,6 +232,36 @@ public class SysUserController extends BaseController {
|
||||
} else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
|
||||
//先判断前端的roleids是否有变化
|
||||
boolean isPd=true;
|
||||
if (schoolCommon.isSchool() == true) {
|
||||
List<Integer> roleIdsOld = roleService.selectYeyRoleListByUserId(user.getUserId());
|
||||
if(roleIdsOld!=null&&roleIdsOld.size()>0){
|
||||
for (int i=0;i<roleIdsOld.size();i++){
|
||||
if(roleIdsOld.get(i)==100){
|
||||
isPd=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isPd){
|
||||
//判断当前学校有多少个幼儿园管理员 需求至多3个幼儿园管理员
|
||||
Long[] roleIds = user.getRoleIds();
|
||||
int iCount = 0;
|
||||
if (roleIds.length > 0) {
|
||||
System.out.println(roleIds.length);
|
||||
for (int i = 0; i < roleIds.length; i++) {
|
||||
if (roleIds[i] == 100) {
|
||||
iCount = userService.countUserSchoolAdminRoleByDeptId(user.getDeptId(), roleIds[i]);
|
||||
if (iCount >= 3) {
|
||||
return AjaxResult.error("用户'" + user.getUserName() + "'修改失败,当前学校管理员角色最多设置3人");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
user.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(userService.updateUser(user));
|
||||
}
|
||||
|
@ -13,6 +13,14 @@ import com.ruoyi.project.system.domain.SysUser;
|
||||
*/
|
||||
public interface SysUserMapper
|
||||
{
|
||||
/**
|
||||
* 通过角色ID查询角色使用数量
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int countUserSchoolAdminRoleByDeptId(Long deptId,Long roleId);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
|
@ -10,6 +10,15 @@ import com.ruoyi.project.system.domain.SysUser;
|
||||
*/
|
||||
public interface ISysUserService
|
||||
{
|
||||
|
||||
/**
|
||||
* 通过角色ID查询角色使用数量
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int countUserSchoolAdminRoleByDeptId(Long deptId,Long roleId);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
|
@ -48,6 +48,16 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
/**
|
||||
* 通过角色ID查询角色使用数量
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int countUserSchoolAdminRoleByDeptId(Long deptId, Long roleId) {
|
||||
return userMapper.countUserSchoolAdminRoleByDeptId(deptId, roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
|
@ -45,6 +45,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="dataScope" column="data_scope" />
|
||||
<result property="status" column="role_status" />
|
||||
</resultMap>
|
||||
|
||||
<select id="countUserSchoolAdminRoleByDeptId" resultType="Integer">
|
||||
select count(1) from sys_user u left join sys_user_role r on u.user_id=r.user_id
|
||||
where dept_id=#{deptId} and role_id=#{roleId}
|
||||
</select>
|
||||
|
||||
<sql id="selectUserVo">
|
||||
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
|
||||
|
Loading…
x
Reference in New Issue
Block a user