heheng
6 天以前 19871e8ac9606710b1009f5f86366fb445a7ace8
multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysUserServiceImpl.java
@@ -14,7 +14,9 @@
import com.gkhy.exam.common.utils.RedisUtils;
import com.gkhy.exam.common.utils.SecurityUtils;
import com.gkhy.exam.common.utils.StringUtils;
import com.gkhy.exam.system.domain.SysUserRole;
import com.gkhy.exam.system.mapper.SysUserMapper;
import com.gkhy.exam.system.mapper.SysUserRoleMapper;
import com.gkhy.exam.system.service.SysConfigService;
import com.gkhy.exam.system.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -45,6 +47,8 @@
    private SysConfigService configService;
    @Autowired
    private Validator validator;
    @Autowired
    private SysUserRoleMapper userRoleMapper;
    @Override
    public CommonPage<SysUser> selectUserList(SysUser user) {
@@ -131,6 +135,13 @@
        user.setCreateBy(SecurityUtils.getUsername());
        user.setPassword(SecurityUtils.encryptPassword(Base64.decodeStr(user.getPassword())));
        int row=baseMapper.insert(user);
        List<SysUserRole> userRoleList = new ArrayList<>();
        SysUserRole sysUserRole = new SysUserRole();
        sysUserRole.setUserId(user.getId());
        sysUserRole.setRoleId(2L);
        userRoleList.add(sysUserRole);
        userRoleMapper.batchUserRole(userRoleList);
        if(row<1){
            throw new ApiException("新增用户失败");
        }
@@ -217,8 +228,11 @@
        Integer userType=user.getUserType();
        //校验权限,规则:上一级用户可以增加下一级用户类型的用户
        if(currentUserType.equals(UserTypeEnum.SYSTEM_USER.getCode())){
            if( !userType.equals(UserTypeEnum.SYSTEM_USER.getCode())&&!userType.equals(UserTypeEnum.OTHER_USER.getCode()) &&!userType.equals(UserTypeEnum.COMPANY_USER.getCode())){
                throw new ApiException("管理员只能操作管理员、企业级和其他类型的用户");
//            if( !userType.equals(UserTypeEnum.SYSTEM_USER.getCode())&&!userType.equals(UserTypeEnum.OTHER_USER.getCode()) &&!userType.equals(UserTypeEnum.COMPANY_USER.getCode())){
//                throw new ApiException("管理员只能操作管理员、企业级和其他类型的用户");
//            }
            if (user.getId().toString().equals("1")){
                throw new ApiException("管理员用户不能被删除");
            }
        }else{
            if(userType.equals(UserTypeEnum.OTHER_USER.getCode())){