|
|
@@ -7,6 +7,7 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import cn.tr.core.annotation.TenantIgnore;
|
|
|
import cn.tr.core.exception.ServiceException;
|
|
|
import cn.tr.core.exception.TRExcCode;
|
|
|
+import cn.tr.core.strategy.LoginUserStrategy;
|
|
|
import cn.tr.core.utils.PswUtils;
|
|
|
import cn.tr.core.utils.RoleUtil;
|
|
|
import cn.tr.module.api.ExcelApi;
|
|
|
@@ -16,8 +17,10 @@ import cn.tr.module.sys.log.dto.SysOperationLogExcelDTO;
|
|
|
import cn.tr.module.sys.user.dto.*;
|
|
|
import cn.tr.module.sys.user.mapper.SysUserMapper;
|
|
|
import cn.tr.module.sys.user.po.SysOrgPO;
|
|
|
+import cn.tr.module.sys.user.po.SysUserTenantPO;
|
|
|
import cn.tr.module.sys.user.repository.SysOrgRepository;
|
|
|
import cn.tr.module.sys.user.repository.SysUserRepository;
|
|
|
+import cn.tr.module.sys.user.repository.SysUserTenantRepository;
|
|
|
import cn.tr.module.sys.user.service.*;
|
|
|
import cn.tr.module.sys.user.po.SysUserPO;
|
|
|
import cn.tr.module.sys.user.vo.SysUserVO;
|
|
|
@@ -71,26 +74,17 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserRepository, SysUserPO
|
|
|
@Lazy
|
|
|
private SysOrgRepository orgRepository;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysUserTenantRepository userTenantRepository;
|
|
|
+
|
|
|
@Override
|
|
|
public List<SysUserVO> stdSelectSysUserList(SysUserListQueryDTO query) {
|
|
|
return baseMapper.stdSelectList(query);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public SysUserDTO selectSysUserById(String id) {
|
|
|
- SysUserDTO result = SysUserMapper.INSTANCE.toUserDTO(baseMapper.selectById(id));
|
|
|
- if (result == null) {
|
|
|
- return result;
|
|
|
- }
|
|
|
- result.setRoleIds(userRoleService.findRoleIdsByUserId(id));
|
|
|
- result.setPortalIds(userPortalService.findPortalsByUserId(id).stream()
|
|
|
- .map(SysUserPortalListDTO::getId).collect(Collectors.toSet()));
|
|
|
- result.setPostIds(userPositionService.findPositionIdsByUserId(id));
|
|
|
- SysOrgPO sysOrgPO = orgRepository.selectById(result.getOrgId());
|
|
|
- if(ObjectUtil.isNotNull(sysOrgPO)){
|
|
|
- result.setOrgPathName(sysOrgPO.getNodePath());
|
|
|
- }
|
|
|
- return result;
|
|
|
+ public SysUserVO selectSysUserById(String id) {
|
|
|
+ return baseMapper.stdSelectById(id);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -154,13 +148,13 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserRepository, SysUserPO
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public int deleteSysUserByIds(Collection<String> ids) {
|
|
|
- if (CollectionUtil.isEmpty(ids)) {
|
|
|
- throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001, "请选择要删除的数据");
|
|
|
+ public int deleteSysUserByIds(Collection<String> ids,String tenantId) {
|
|
|
+ if(CollectionUtil.isEmpty(ids)||StrUtil.isEmpty(tenantId)){
|
|
|
+ return 0;
|
|
|
}
|
|
|
- int result = baseMapper.deleteBatchIds(ids);
|
|
|
- sysUserService.delUserIdAndNickNameCache();
|
|
|
- return result;
|
|
|
+ return userTenantRepository.delete(new LambdaQueryWrapper<SysUserTenantPO>()
|
|
|
+ .in(SysUserTenantPO::getUserId, ids)
|
|
|
+ .eq(SysUserTenantPO::getTenantId, tenantId));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -221,6 +215,22 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserRepository, SysUserPO
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void freeze(SysUserFreezeOrThawDTO source) {
|
|
|
+ if (CollectionUtil.isEmpty(source.getUserIds())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ baseMapper.freezeBatch(source.getUserIds(),source.getTenantId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void thaw(SysUserFreezeOrThawDTO source) {
|
|
|
+ if (CollectionUtil.isEmpty(source.getUserIds())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ baseMapper.thawBatch(source.getUserIds(),source.getTenantId());
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private void assignUserRole(String userId, Set<String> roleIds) {
|
|
|
userRoleService.assignUserRole(userId, roleIds);
|