|
@@ -1,6 +1,7 @@
|
|
|
package com.usky.system.service.impl;
|
|
package com.usky.system.service.impl;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.usky.common.core.exception.BusinessException;
|
|
import com.usky.common.core.exception.BusinessException;
|
|
@@ -13,6 +14,7 @@ import com.usky.system.mapper.SysUserTenantMapper;
|
|
|
import com.usky.system.service.SysTenantService;
|
|
import com.usky.system.service.SysTenantService;
|
|
|
import com.usky.system.service.SysUserTenantService;
|
|
import com.usky.system.service.SysUserTenantService;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
|
|
+import com.usky.system.service.vo.TenantPlatformVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -94,6 +96,15 @@ public class SysUserTenantServiceImpl extends AbstractCrudService<SysUserTenantM
|
|
|
queryWrapper1.in(SysTenant::getId, tenantIdList)
|
|
queryWrapper1.in(SysTenant::getId, tenantIdList)
|
|
|
.eq(SysTenant::getStatus, 0);
|
|
.eq(SysTenant::getStatus, 0);
|
|
|
tenantList = sysTenantService.list(queryWrapper1);
|
|
tenantList = sysTenantService.list(queryWrapper1);
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(tenantList)) {
|
|
|
|
|
+ for (int j = 0; j < userTenants.size(); j++) {
|
|
|
|
|
+ for (int k = 0; k < tenantList.size(); k++) {
|
|
|
|
|
+ if (userTenants.get(j).getTenantId().equals(tenantList.get(k).getId())){
|
|
|
|
|
+ tenantList.get(k).setIsDefault(userTenants.get(j).getIsDefault());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
return tenantList;
|
|
return tenantList;
|
|
|
}
|
|
}
|
|
@@ -107,4 +118,29 @@ public class SysUserTenantServiceImpl extends AbstractCrudService<SysUserTenantM
|
|
|
List<SysUserTenant> userTenants = this.list(queryWrapper);
|
|
List<SysUserTenant> userTenants = this.list(queryWrapper);
|
|
|
return userTenants.get(0).getIsDefault();
|
|
return userTenants.get(0).getIsDefault();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public Integer getIsDefaultByUser(Long userId) {
|
|
|
|
|
+ LambdaQueryWrapper<SysUserTenant> queryWrapper = Wrappers.lambdaQuery();
|
|
|
|
|
+ queryWrapper.eq(SysUserTenant::getUserId, userId)
|
|
|
|
|
+ .eq(SysUserTenant::getIsDefault, 1);
|
|
|
|
|
+ List<SysUserTenant> userTenants = this.list(queryWrapper);
|
|
|
|
|
+ return userTenants.get(0).getTenantId();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public void updateUserTenant(SysUserTenant userTenant) {
|
|
|
|
|
+ LambdaUpdateWrapper<SysUserTenant> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ updateWrapper.set(SysUserTenant::getIsDefault, 0)
|
|
|
|
|
+ .eq(SysUserTenant::getUserId, userTenant.getUserId())
|
|
|
|
|
+ .eq(SysUserTenant::getIsDefault, 1);
|
|
|
|
|
+ this.update(updateWrapper);
|
|
|
|
|
+ LambdaUpdateWrapper<SysUserTenant> updateWrapper1 = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ updateWrapper1.set(SysUserTenant::getIsDefault, 1)
|
|
|
|
|
+ .eq(SysUserTenant::getUserId, userTenant.getUserId())
|
|
|
|
|
+ .eq(SysUserTenant::getTenantId, userTenant.getTenantId());
|
|
|
|
|
+ this.update(updateWrapper1);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|