mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-22 02:50:00 +08:00
add SysTenantServiceImpl#checkCompanyNameUnique 租户公司名称唯一校验 ;
This commit is contained in:
parent
09780d5817
commit
26eb3328ab
@ -91,6 +91,9 @@ public class SysTenantController extends BaseController {
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysTenantBo bo) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(sysTenantService.checkCompanyNameUnique(bo))) {
|
||||
throw new ServiceException("新增租户'" + bo.getCompanyName() + "'失败,公司名称已存在");
|
||||
}
|
||||
SysUserBo userBo = new SysUserBo();
|
||||
userBo.setUserName(bo.getUsername());
|
||||
// 判断用户名是否重复
|
||||
@ -109,6 +112,9 @@ public class SysTenantController extends BaseController {
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysTenantBo bo) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(sysTenantService.checkCompanyNameUnique(bo))) {
|
||||
throw new ServiceException("修改租户'" + bo.getCompanyName() + "'失败,公司名称已存在");
|
||||
}
|
||||
return toAjax(sysTenantService.updateByBo(bo));
|
||||
}
|
||||
|
||||
|
||||
@ -55,6 +55,11 @@ public interface ISysTenantService {
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 校验公司名称是否唯一
|
||||
*/
|
||||
String checkCompanyNameUnique(SysTenantBo bo);
|
||||
|
||||
/**
|
||||
* 校验账号余额
|
||||
*/
|
||||
|
||||
@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.core.constant.CacheNames;
|
||||
import com.ruoyi.common.core.constant.Constants;
|
||||
import com.ruoyi.common.core.constant.TenantConstants;
|
||||
import com.ruoyi.common.core.constant.UserConstants;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import com.ruoyi.common.core.utils.SpringUtils;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
@ -281,6 +282,20 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验公司名称是否唯一
|
||||
*/
|
||||
@Override
|
||||
public String checkCompanyNameUnique(SysTenantBo bo) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysTenant>()
|
||||
.eq(SysTenant::getCompanyName, bo.getCompanyName())
|
||||
.ne(ObjectUtil.isNotNull(bo.getTenantId()), SysTenant::getTenantId, bo.getTenantId()));
|
||||
if (exist) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验账号余额
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user