|
@@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.usky.common.core.exception.BusinessException;
|
|
|
import com.usky.system.RemoteDeptService;
|
|
|
import com.usky.system.domain.SysTenant;
|
|
|
+import com.usky.system.domain.SysUserRole;
|
|
|
import com.usky.system.domain.SysUserTenant;
|
|
|
+import com.usky.system.mapper.SysUserRoleMapper;
|
|
|
import com.usky.system.mapper.SysUserTenantMapper;
|
|
|
import com.usky.system.service.SysTenantService;
|
|
|
import com.usky.system.service.SysUserTenantService;
|
|
@@ -33,6 +35,9 @@ public class SysUserTenantServiceImpl extends AbstractCrudService<SysUserTenantM
|
|
|
@Autowired
|
|
|
private SysTenantService sysTenantService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysUserRoleMapper sysUserRoleMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 企业邀请用户
|
|
|
*
|
|
@@ -42,9 +47,16 @@ public class SysUserTenantServiceImpl extends AbstractCrudService<SysUserTenantM
|
|
|
@Transactional
|
|
|
public void insertInviteUser(SysUserTenant sysUserTenant) {
|
|
|
int userCount = baseMapper.checkUserIdUnique(sysUserTenant.getTenantId(), sysUserTenant.getUserId());
|
|
|
- if (userCount > 0){
|
|
|
+ if (userCount > 0) {
|
|
|
throw new BusinessException("用户已绑定,无法重复绑定!");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
+ // SysUserRole sysUserRole = sysUserRoleMapper.selectOne(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, sysUserTenant.getUserId()).eq(SysUserRole::getTenantId, sysUserTenant.getTenantId()));
|
|
|
+ // if (sysUserRole == null) {
|
|
|
+ // SysUserRole sysUserRole1 = new SysUserRole();
|
|
|
+ // sysUserRole1.setUserId(sysUserTenant.getUserId());
|
|
|
+ // sysUserRole1.setTenantId(sysUserTenant.getTenantId());
|
|
|
+ // sysUserRoleMapper.insert(sysUserRole1);
|
|
|
+ // }
|
|
|
this.save(sysUserTenant);
|
|
|
}
|
|
|
}
|
|
@@ -57,8 +69,10 @@ public class SysUserTenantServiceImpl extends AbstractCrudService<SysUserTenantM
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public void deleteUserTenant(Integer tenantId,Long userId) {
|
|
|
+ public void deleteUserTenant(Integer tenantId, Long userId) {
|
|
|
baseMapper.deleteUserTenant(tenantId, userId);
|
|
|
+ Long[] userIds = new Long[]{userId};
|
|
|
+ sysUserRoleMapper.deleteUserRole(userIds, tenantId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -66,19 +80,19 @@ public class SysUserTenantServiceImpl extends AbstractCrudService<SysUserTenantM
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public List<SysTenant> getTenantByUser(Long userId){
|
|
|
+ public List<SysTenant> getTenantByUser(Long userId) {
|
|
|
LambdaQueryWrapper<SysUserTenant> queryWrapper = Wrappers.lambdaQuery();
|
|
|
- queryWrapper.eq(SysUserTenant::getUserId,userId);
|
|
|
+ queryWrapper.eq(SysUserTenant::getUserId, userId);
|
|
|
List<SysUserTenant> userTenants = this.list(queryWrapper);
|
|
|
List<Integer> tenantIdList = new ArrayList<>();
|
|
|
List<SysTenant> tenantList = new ArrayList<>();
|
|
|
LambdaQueryWrapper<SysTenant> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
- if (CollectionUtils.isNotEmpty(userTenants)){
|
|
|
+ if (CollectionUtils.isNotEmpty(userTenants)) {
|
|
|
for (int i = 0; i < userTenants.size(); i++) {
|
|
|
tenantIdList.add(userTenants.get(i).getTenantId());
|
|
|
}
|
|
|
- queryWrapper1.in(SysTenant::getId,tenantIdList)
|
|
|
- .eq(SysTenant::getStatus,0);
|
|
|
+ queryWrapper1.in(SysTenant::getId, tenantIdList)
|
|
|
+ .eq(SysTenant::getStatus, 0);
|
|
|
tenantList = sysTenantService.list(queryWrapper1);
|
|
|
}
|
|
|
return tenantList;
|
|
@@ -86,10 +100,10 @@ public class SysUserTenantServiceImpl extends AbstractCrudService<SysUserTenantM
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public Boolean getIdByUser(Integer tenantId,Long userId){
|
|
|
+ public Boolean getIdByUser(Integer tenantId, Long userId) {
|
|
|
LambdaQueryWrapper<SysUserTenant> queryWrapper = Wrappers.lambdaQuery();
|
|
|
- queryWrapper.eq(SysUserTenant::getUserId,userId)
|
|
|
- .eq(SysUserTenant::getTenantId,tenantId);
|
|
|
+ queryWrapper.eq(SysUserTenant::getUserId, userId)
|
|
|
+ .eq(SysUserTenant::getTenantId, tenantId);
|
|
|
List<SysUserTenant> userTenants = this.list(queryWrapper);
|
|
|
return userTenants.get(0).getIsDefault();
|
|
|
}
|