| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | 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.cache.SysCache; |
| | | import com.vci.ubcs.system.entity.Strategy; |
| | |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.*; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.DigestUtils; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | import static com.vci.ubcs.common.constant.CommonConstant.DEFAULT_PARAM_PASSWORD; |
| | | |
| | |
| | | private final IUserOauthService userOauthService; |
| | | private final ISysClient sysClient; |
| | | private final BladeTenantProperties tenantProperties; |
| | | //拿到配置的超管id |
| | | @Value("${user-info.id}") |
| | | private String adminUserId; |
| | | @Value("${user-info.tenant-id}") |
| | | private String tenantId; |
| | | //拿到配置的超管 |
| | | private final NacosConfigCache nacosConfigCache; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | if (StringUtil.isBlank(user.getTenantId())) { |
| | | // user.setTenantId(BladeConstant.ADMIN_TENANT_ID); |
| | | // 默认设置为管理组下的用户 |
| | | user.setTenantId(this.tenantId); |
| | | user.setTenantId(nacosConfigCache.getAdminUserInfo().getTenantId()); |
| | | } |
| | | String tenantId = user.getTenantId(); |
| | | //Tenant tenant = SysCache.getTenant(tenantId); |
| | |
| | | List<User> users = baseMapper.selectUserPage(user, deptIdList, (AuthUtil.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? StringPool.EMPTY : AuthUtil.getTenantId())); |
| | | return users; |
| | | } |
| | | |
| | | @Override |
| | | public List<User> selectAllUser(){ |
| | | LambdaQueryWrapper<User> wrapper= Wrappers.lambdaQuery(); |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importUser(List<UserExcel> data, Boolean isCovered) { |
| | | ArrayList<User> addUsers = new ArrayList<>(); |
| | | data.forEach(userExcel -> { |
| | | User user = Objects.requireNonNull(BeanUtil.copy(userExcel, User.class)); |
| | | // 设置用户平台 |
| | |
| | | // 获取默认密码配置 |
| | | String initPassword = ParamCache.getValue(DEFAULT_PARAM_PASSWORD); |
| | | user.setPassword(initPassword); |
| | | this.submit(user); |
| | | addUsers.add(user); |
| | | //this.submit(user); |
| | | }); |
| | | this.submitList(addUsers); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public Long checkRenAndExpr(Long userId) { |
| | | //超级管理员直接返回不需要提醒密码修改 |
| | | if(adminUserId.equals(userId)){ |
| | | if(nacosConfigCache.getAdminUserInfo().getUserId().equals(userId)){ |
| | | return 0L; |
| | | } |
| | | QueryWrapper<User> wrapper = Wrappers.<User>query().eq("ID", userId); |
| | | User dbUser = this.getOne(wrapper); |
| | | //获取到密码修改时间 |
| | | Date pwdUpdateTime = this.getOne(wrapper).getPwdUpdateTime(); |
| | | Date pwdUpdateTime = Func.isNotEmpty(dbUser) ? dbUser.getPwdUpdateTime():new Date(); |
| | | Long pwdupdateday = 0L; |
| | | if(!Func.isEmpty(pwdUpdateTime)){ |
| | | pwdupdateday = dateToDay(pwdUpdateTime); |
| | |
| | | public List<Map<String,String>> getByRoleUserList(BladeUser user, String roleName) { |
| | | // 考虑到一个用户可以拥有多种角色权限,而用户关联角色权限是用role_id字段用逗号分隔角色id的,直接采用子查询来in查询不能实现,所以先查询角色id |
| | | R<String> roleIds = sysClient.getRoleIds(user.getTenantId(), roleName); |
| | | if(roleIds.getCode() != 200){ |
| | | if(!roleIds.isSuccess()){ |
| | | throw new ServiceException("系统服务feign接口调用错误!"); |
| | | } |
| | | if(Func.isBlank(roleIds.getData())){ |