| | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import com.vci.ubcs.system.cache.DictCache; |
| | | import com.vci.ubcs.system.cache.NacosConfigCache; |
| | | import com.vci.ubcs.system.cache.ParamCache; |
| | |
| | | import com.vci.ubcs.system.user.cache.UserCache; |
| | | import com.vci.ubcs.system.user.entity.*; |
| | | import com.vci.ubcs.system.user.enums.UserEnum; |
| | | import com.vci.ubcs.system.user.enums.UserStatus; |
| | | import com.vci.ubcs.system.user.excel.UserExcel; |
| | | import com.vci.ubcs.system.user.mapper.UserMapper; |
| | | import com.vci.ubcs.system.user.service.IUserDeptService; |
| | |
| | | private final IUserOauthService userOauthService; |
| | | private final ISysClient sysClient; |
| | | private final BladeTenantProperties tenantProperties; |
| | | //拿到配置的超管 |
| | | private final NacosConfigCache nacosConfigCache; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean submit(User user) { |
| | | if (StringUtil.isBlank(user.getTenantId())) { |
| | | // user.setTenantId(nacosConfigCache.getAdminUserInfo().getTenantId()); |
| | | // 默认设置为管理组下的用户 |
| | | user.setTenantId(nacosConfigCache.getAdminUserInfo().getTenantId()); |
| | | user.setTenantId(NacosConfigCache.getAdminUserInfo().getTenantId()); |
| | | } |
| | | String tenantId = user.getTenantId(); |
| | | //Tenant tenant = SysCache.getTenant(tenantId); |
| | | if (Func.isNotEmpty(user.getPassword())) { |
| | | user.setPassword(DigestUtil.encrypt(user.getPassword())); |
| | | } |
| | | if(Func.isEmpty(user.getUserStatus())){ |
| | | user.setUserStatus(UserStatus.Enable.getValue()); |
| | | } |
| | | Long userCount = baseMapper.selectCount(Wrappers.<User>query().lambda().eq(User::getTenantId, tenantId).eq(User::getAccount, user.getAccount())); |
| | | if (userCount > 0L && Func.isEmpty(user.getId())) { |
| | |
| | | Boolean flag = true; |
| | | for (User user : users){ |
| | | if (StringUtil.isBlank(user.getTenantId())) { |
| | | user.setTenantId(nacosConfigCache.getAdminUserInfo().getTenantId()); |
| | | user.setTenantId(NacosConfigCache.getAdminUserInfo().getTenantId()); |
| | | } |
| | | String tenantId = user.getTenantId(); |
| | | if (Func.isNotEmpty(user.getPassword())) { |
| | |
| | | return updateById(user); |
| | | } |
| | | |
| | | /** |
| | | * 根据旧账号,修改为新账号名 |
| | | * @param oldAccount |
| | | * @param newAccount |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean updateByAccount(String oldAccount,String newAccount) { |
| | | User user = this.userByAccount(AuthUtil.getTenantId(), oldAccount); |
| | | if(Func.isEmpty(user)){ |
| | | return true; |
| | | } |
| | | user.setAccount(newAccount); |
| | | return this.updateUser(user); |
| | | } |
| | | |
| | | /** |
| | | * 据账号,修改为用户状态 |
| | | * @param accounts |
| | | * @param status |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean updateStatusByAccount(String accounts, String status) { |
| | | LambdaUpdateWrapper<User> updateWrapper = Wrappers.<User>update() |
| | | .lambda().in(User::getAccount, accounts) |
| | | .set(User::getUserStatus, status); |
| | | return this.update(updateWrapper); |
| | | } |
| | | |
| | | private boolean submitUserDept(User user) { |
| | | List<Long> deptIdList = Func.toLongList(user.getDeptId()); |
| | | List<UserDept> userDeptList = new ArrayList<>(); |
| | |
| | | @Override |
| | | public List<User> selectAllUser(User user, Long deptId){ |
| | | List<Long> deptIdList = SysCache.getDeptChildIds(deptId); |
| | | List<User> users = baseMapper.selectUserPage(user, deptIdList, (AuthUtil.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId()) ? StringPool.EMPTY : AuthUtil.getTenantId())); |
| | | List<User> users = baseMapper.selectUserPage(user, deptIdList, (VciBaseUtil.checkAdminTenant() ? StringPool.EMPTY : AuthUtil.getTenantId())); |
| | | return users; |
| | | } |
| | | |
| | |
| | | @Override |
| | | public Long checkRenAndExpr(Long userId) { |
| | | //超级管理员直接返回不需要提醒密码修改 |
| | | if(nacosConfigCache.getAdminUserInfo().getUserId().equals(userId)){ |
| | | if(NacosConfigCache.getAdminUserInfo().getUserId().equals(userId)){ |
| | | return 0L; |
| | | } |
| | | QueryWrapper<User> wrapper = Wrappers.<User>query().eq("ID", userId); |