|
|
@@ -13,8 +13,6 @@ import com.tuoheng.admin.service.ITenantService; |
|
|
|
import com.tuoheng.common.common.BaseServiceImpl; |
|
|
|
import com.tuoheng.common.config.CommonConfig; |
|
|
|
import com.tuoheng.common.utils.*; |
|
|
|
import com.tuoheng.system.entity.User; |
|
|
|
import com.tuoheng.system.mapper.UserMapper; |
|
|
|
import com.tuoheng.system.utils.ShiroUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@@ -37,8 +35,6 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private TenantMapper tenantMapper; |
|
|
|
@Autowired |
|
|
|
private UserMapper userMapper; |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取租户列表 |
|
|
@@ -83,8 +79,17 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp |
|
|
|
.eq(Tenant::getName, tenantDto.getName()) |
|
|
|
.eq(Tenant::getMark, 1)); |
|
|
|
if (count > 0) { |
|
|
|
return JsonResult.error("系统中已经存在相同的租户编码"); |
|
|
|
return JsonResult.error("系统中已经存在相同的租户名称"); |
|
|
|
} |
|
|
|
|
|
|
|
// 验证租户超管账号是否存在 |
|
|
|
Integer count2 = tenantMapper.selectCount(new LambdaQueryWrapper<Tenant>() |
|
|
|
.eq(Tenant::getUsername, tenantDto.getUsername()) |
|
|
|
.eq(Tenant::getMark, 1)); |
|
|
|
if (count2 > 0) { |
|
|
|
return JsonResult.error("系统中已经存在相同的租户账号"); |
|
|
|
} |
|
|
|
|
|
|
|
// 参数转换 |
|
|
|
Tenant tenant = new Tenant(); |
|
|
|
BeanUtils.copyProperties(tenantDto, tenant); |
|
|
@@ -97,8 +102,8 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp |
|
|
|
tenant.setLogo(tenantDto.getLogo().replaceAll(CommonConfig.imageURL, "")); |
|
|
|
} |
|
|
|
// 新建租户数据 |
|
|
|
int count2 = tenantMapper.insert(tenant); |
|
|
|
if (count2 == 0) { |
|
|
|
int count3 = tenantMapper.insert(tenant); |
|
|
|
if (count3 == 0) { |
|
|
|
return JsonResult.error("租户创建失败"); |
|
|
|
} |
|
|
|
|
|
|
@@ -132,14 +137,24 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp |
|
|
|
if (StringUtils.isNull(tenant)) { |
|
|
|
return JsonResult.error("租户信息不存在"); |
|
|
|
} |
|
|
|
// 验证账号 |
|
|
|
// 验证租户名称 |
|
|
|
Integer count = tenantMapper.selectCount(new LambdaQueryWrapper<Tenant>() |
|
|
|
.ne(Tenant::getId, tenant.getId()) |
|
|
|
.eq(Tenant::getName, tenantDto.getName()) |
|
|
|
.eq(Tenant::getMark, 1)); |
|
|
|
if (count > 0) { |
|
|
|
return JsonResult.error("系统中已经存在相同的租户编码"); |
|
|
|
return JsonResult.error("系统中已经存在相同的租户名称"); |
|
|
|
} |
|
|
|
|
|
|
|
// 验证租户账号 |
|
|
|
Integer count2 = tenantMapper.selectCount(new LambdaQueryWrapper<Tenant>() |
|
|
|
.ne(Tenant::getId, tenant.getId()) |
|
|
|
.eq(Tenant::getUsername, tenantDto.getUsername()) |
|
|
|
.eq(Tenant::getMark, 1)); |
|
|
|
if (count2 > 0) { |
|
|
|
return JsonResult.error("系统中已经存在相同的租户账号"); |
|
|
|
} |
|
|
|
|
|
|
|
BeanUtils.copyProperties(tenantDto, tenant); |
|
|
|
tenant.setUpdateUser(ShiroUtils.getUserId()); |
|
|
|
tenant.setUpdateTime(DateUtils.now()); |
|
|
@@ -148,8 +163,8 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp |
|
|
|
tenant.setLogo(tenantDto.getLogo().replaceAll(CommonConfig.imageURL, "")); |
|
|
|
} |
|
|
|
// 更新租户信息 |
|
|
|
int count2 = tenantMapper.updateById(tenant); |
|
|
|
if (count2 == 0) { |
|
|
|
int count3 = tenantMapper.updateById(tenant); |
|
|
|
if (count3 == 0) { |
|
|
|
return JsonResult.error("更新租户信息失败"); |
|
|
|
} |
|
|
|
|