| | |
| | | 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(); |
| | | 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); |
| | | if(!currentUser.getUserType().equals(UserTypeEnum.SYSTEM_USER.getCode())){ |
| | | user.setCompanyId(currentUser.getCompanyId()); |
| | | } |
| | | PageUtils.startPage(); |
| | | List<SysUser> users=baseMapper.userList(user); |
| | | users=baseMapper.userList(user); |
| | | } |
| | | return CommonPage.restPage(users); |
| | | } |
| | | |
| | |
| | | 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("没有权限操作或者更新上级用户类型的用户"); |
| | | } |