mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-15 03:25:06 +08:00
!446 配合周建进行测试所提bug的后端修改
Merge pull request !446 from clockdotnet/master_pr
This commit is contained in:
@ -103,6 +103,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode TENANT_DISABLE = new ErrorCode(1002015001, "名字为【{}】的租户已被禁用");
|
||||
ErrorCode TENANT_EXPIRE = new ErrorCode(1002015002, "名字为【{}】的租户已过期");
|
||||
ErrorCode TENANT_CAN_NOT_UPDATE_SYSTEM = new ErrorCode(1002015003, "系统租户不能进行修改、删除等操作!");
|
||||
ErrorCode TENANT_NAME_DUPLICATE = new ErrorCode(1002015004, "已经存在该名称的租户");
|
||||
|
||||
// ========== 租户套餐 1002016000 ==========
|
||||
ErrorCode TENANT_PACKAGE_NOT_EXISTS = new ErrorCode(1002016000, "租户套餐不存在");
|
||||
|
@ -38,6 +38,12 @@ public interface TenantMapper extends BaseMapperX<TenantDO> {
|
||||
.orderByDesc(TenantDO::getId));
|
||||
}
|
||||
|
||||
default Long selectCountByName(String name, Long id) {
|
||||
return selectCount(new LambdaQueryWrapperX<TenantDO>()
|
||||
.eqIfPresent(TenantDO::getName, name)
|
||||
.neIfPresent(TenantDO::getId, id));
|
||||
}
|
||||
|
||||
default TenantDO selectByName(String name) {
|
||||
return selectOne(TenantDO::getName, name);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
||||
import cn.iocoder.yudao.module.system.service.tenant.handler.TenantInfoHandler;
|
||||
import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler;
|
||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
@ -97,6 +98,9 @@ public class TenantServiceImpl implements TenantService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createTenant(TenantCreateReqVO createReqVO) {
|
||||
// 校验租户名称是否重复
|
||||
validTenantName(createReqVO.getName(), null);
|
||||
|
||||
// 校验套餐被禁用
|
||||
TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(createReqVO.getPackageId());
|
||||
|
||||
@ -139,6 +143,10 @@ public class TenantServiceImpl implements TenantService {
|
||||
public void updateTenant(TenantUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
TenantDO tenant = validateUpdateTenant(updateReqVO.getId());
|
||||
|
||||
// 校验租户名称是否重复
|
||||
validTenantName(updateReqVO.getName(), updateReqVO.getId());
|
||||
|
||||
// 校验套餐被禁用
|
||||
TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(updateReqVO.getPackageId());
|
||||
|
||||
@ -151,6 +159,12 @@ public class TenantServiceImpl implements TenantService {
|
||||
}
|
||||
}
|
||||
|
||||
protected void validTenantName(String tenantName, Long id) {
|
||||
if (tenantMapper.selectCountByName(tenantName, id) > 0) {
|
||||
throw exception(TENANT_NAME_DUPLICATE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateTenantRoleMenu(Long tenantId, Set<Long> menuIds) {
|
||||
|
Reference in New Issue
Block a user