| | |
| | | import cn.hutool.core.codec.Base64; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gkhy.exam.common.annotation.DataScope; |
| | | import com.gkhy.exam.common.api.CommonPage; |
| | | import com.gkhy.exam.common.constant.CacheConstant; |
| | | import com.gkhy.exam.common.constant.UserConstant; |
| | | import com.gkhy.exam.common.domain.entity.SysUser; |
| | | import com.gkhy.exam.common.enums.UserTypeEnum; |
| | | import com.gkhy.exam.common.exception.ApiException; |
| | | import com.gkhy.exam.common.utils.*; |
| | | import com.gkhy.exam.common.utils.PageUtils; |
| | | 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.mapper.SysUserMapper; |
| | | import com.gkhy.exam.system.service.SysConfigService; |
| | | import com.gkhy.exam.system.service.SysUserService; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.validation.Validator; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | @Override |
| | | public CommonPage<SysUser> selectUserList(SysUser user) { |
| | | SysUser currentUser=SecurityUtils.getLoginUser().getUser(); |
| | | Map<String,Object> paramsMap=new HashMap<>(); |
| | | paramsMap.put("userType",currentUser.getUserType()); |
| | | user.setParams(paramsMap); |
| | | if(!currentUser.getUserType().equals(UserTypeEnum.SYSTEM_USER.getCode())){ |
| | | user.setCompanyId(currentUser.getCompanyId()); |
| | | List<SysUser> users=new ArrayList<>(); |
| | | if(!currentUser.getUserType().equals(UserTypeEnum.WORKSHOP_USER.getCode())){ |
| | | if(!currentUser.getUserType().equals(UserTypeEnum.SYSTEM_USER.getCode())){ |
| | | user.setCompanyId(currentUser.getCompanyId()); |
| | | Map<String,Object> paramsMap=new HashMap<>(); |
| | | paramsMap.put("userType",currentUser.getUserType()); |
| | | user.setParams(paramsMap); |
| | | } |
| | | PageUtils.startPage(); |
| | | users=baseMapper.userList(user); |
| | | } |
| | | PageUtils.startPage(); |
| | | List<SysUser> users=baseMapper.userList(user); |
| | | return CommonPage.restPage(users); |
| | | } |
| | | /** |
| | | * 根据条件分页查询已分配用户角色列表 |
| | | * |
| | | * @param user 用户信息 |
| | | * @return 用户信息集合信息 |
| | | */ |
| | | @Override |
| | | @DataScope( userAlias = "u") |
| | | public List<SysUser> selectAllocatedList(SysUser user) |
| | | { |
| | | return baseMapper.selectAllocatedList(user); |
| | | } |
| | | |
| | | /** |
| | | * 根据条件分页查询未分配用户角色列表 |
| | | * |
| | | * @param user 用户信息 |
| | | * @return 用户信息集合信息 |
| | | */ |
| | | @Override |
| | | @DataScope( userAlias = "u") |
| | | public List<SysUser> selectUnallocatedList(SysUser user) |
| | | { |
| | | return baseMapper.selectUnallocatedList(user); |
| | | } |
| | | |
| | | |
| | |
| | | checkRequestData(user); |
| | | checkUserAllowed(user); |
| | | user.setUpdateBy(SecurityUtils.getUsername()); |
| | | user.setPassword(null); |
| | | int row=baseMapper.updateById(user); |
| | | if(row<1){ |
| | | throw new ApiException("更新用户信息失败"); |
| | |
| | | Integer currentUserType=currentUser.getUserType(); |
| | | Integer userType=user.getUserType(); |
| | | //校验权限,规则:上一级用户可以增加下一级用户类型的用户 |
| | | if(!currentUserType.equals(UserTypeEnum.SYSTEM_USER.getCode())){ |
| | | 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("管理员只能操作管理员、企业级和其他类型的用户"); |
| | | } |
| | | }else{ |
| | | if(userType.equals(UserTypeEnum.OTHER_USER.getCode())){ |
| | | throw new ApiException("没有权限操作或者更新上级用户类型的用户"); |
| | | } |