mirror of
https://gitee.com/myxzgzs/boyue-vue-pro.git
synced 2025-08-08 16:32:46 +08:00
review:【System 系统管理】批量删除接口
This commit is contained in:
parent
1c0c6710bb
commit
d7dbb4817b
@ -175,8 +175,6 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
#end
|
#end
|
||||||
public void delete${simpleClassName}ListByIds(List<${primaryColumn.javaType}> ids) {
|
public void delete${simpleClassName}ListByIds(List<${primaryColumn.javaType}> ids) {
|
||||||
// 校验存在
|
|
||||||
validate${simpleClassName}Exists(ids);
|
|
||||||
// 删除
|
// 删除
|
||||||
${classNameVar}Mapper.deleteByIds(ids);
|
${classNameVar}Mapper.deleteByIds(ids);
|
||||||
## 特殊:主子表专属逻辑
|
## 特殊:主子表专属逻辑
|
||||||
@ -193,12 +191,6 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
|
|||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validate${simpleClassName}Exists(List<${primaryColumn.javaType}> ids) {
|
|
||||||
List<${table.className}DO> list = ${classNameVar}Mapper.selectByIds(ids);
|
|
||||||
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
|
||||||
throw exception(${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#end
|
#end
|
||||||
|
|
||||||
private void validate${simpleClassName}Exists(${primaryColumn.javaType} id) {
|
private void validate${simpleClassName}Exists(${primaryColumn.javaType} id) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.mail;
|
package cn.iocoder.yudao.module.system.service.mail;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountPageReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountPageReqVO;
|
||||||
@ -71,20 +70,17 @@ public class MailAccountServiceImpl implements MailAccountService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CacheEvict(value = RedisKeyConstants.MAIL_ACCOUNT, allEntries = true)
|
@CacheEvict(value = RedisKeyConstants.MAIL_ACCOUNT,
|
||||||
|
allEntries = true) // allEntries 清空所有缓存,因为 Spring Cache 不支持按照 ids 批量删除
|
||||||
public void deleteMailAccountList(List<Long> ids) {
|
public void deleteMailAccountList(List<Long> ids) {
|
||||||
if (CollUtil.isEmpty(ids)) {
|
// 1. 校验是否存在关联模版
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 校验是否存在
|
|
||||||
validateMailAccountsExists(ids);
|
|
||||||
// 校验是否存在关联模版
|
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
if (mailTemplateService.getMailTemplateCountByAccountId(id) > 0) {
|
if (mailTemplateService.getMailTemplateCountByAccountId(id) > 0) {
|
||||||
throw exception(MAIL_ACCOUNT_RELATE_TEMPLATE_EXISTS);
|
throw exception(MAIL_ACCOUNT_RELATE_TEMPLATE_EXISTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 批量删除
|
|
||||||
|
// 2. 批量删除
|
||||||
mailAccountMapper.deleteByIds(ids);
|
mailAccountMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,17 +90,6 @@ public class MailAccountServiceImpl implements MailAccountService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateMailAccountsExists(List<Long> ids) {
|
|
||||||
if (CollUtil.isEmpty(ids)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 校验存在
|
|
||||||
List<MailAccountDO> accounts = mailAccountMapper.selectByIds(ids);
|
|
||||||
if (CollUtil.isEmpty(accounts) || accounts.size() != ids.size()) {
|
|
||||||
throw exception(MAIL_ACCOUNT_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MailAccountDO getMailAccount(Long id) {
|
public MailAccountDO getMailAccount(Long id) {
|
||||||
return mailAccountMapper.selectById(id);
|
return mailAccountMapper.selectById(id);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.mail;
|
package cn.iocoder.yudao.module.system.service.mail;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.hutool.core.util.ReUtil;
|
import cn.hutool.core.util.ReUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
@ -102,12 +101,6 @@ public class MailTemplateServiceImpl implements MailTemplateService {
|
|||||||
@CacheEvict(cacheNames = RedisKeyConstants.MAIL_TEMPLATE,
|
@CacheEvict(cacheNames = RedisKeyConstants.MAIL_TEMPLATE,
|
||||||
allEntries = true) // allEntries 清空所有缓存,因为 id 不是直接的缓存 code,不好清理
|
allEntries = true) // allEntries 清空所有缓存,因为 id 不是直接的缓存 code,不好清理
|
||||||
public void deleteMailTemplateList(List<Long> ids) {
|
public void deleteMailTemplateList(List<Long> ids) {
|
||||||
if (CollUtil.isEmpty(ids)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 校验存在
|
|
||||||
validateMailTemplatesExists(ids);
|
|
||||||
// 批量删除
|
|
||||||
mailTemplateMapper.deleteByIds(ids);
|
mailTemplateMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,17 +110,6 @@ public class MailTemplateServiceImpl implements MailTemplateService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateMailTemplatesExists(List<Long> ids) {
|
|
||||||
if (CollUtil.isEmpty(ids)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 校验存在
|
|
||||||
List<MailTemplateDO> templates = mailTemplateMapper.selectByIds(ids);
|
|
||||||
if (CollUtil.isEmpty(templates) || templates.size() != ids.size()) {
|
|
||||||
throw exception(MAIL_TEMPLATE_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MailTemplateDO getMailTemplate(Long id) {return mailTemplateMapper.selectById(id);}
|
public MailTemplateDO getMailTemplate(Long id) {return mailTemplateMapper.selectById(id);}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.notice;
|
package cn.iocoder.yudao.module.system.service.notice;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticePageReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticePageReqVO;
|
||||||
@ -53,9 +52,6 @@ public class NoticeServiceImpl implements NoticeService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteNoticeList(List<Long> ids) {
|
public void deleteNoticeList(List<Long> ids) {
|
||||||
// 校验是否存在
|
|
||||||
validateNoticesExists(ids);
|
|
||||||
// 批量删除通知公告
|
|
||||||
noticeMapper.deleteByIds(ids);
|
noticeMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,15 +76,4 @@ public class NoticeServiceImpl implements NoticeService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateNoticesExists(List<Long> ids) {
|
|
||||||
if (CollUtil.isEmpty(ids)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 校验存在
|
|
||||||
List<NoticeDO> notices = noticeMapper.selectByIds(ids);
|
|
||||||
if (CollUtil.isEmpty(notices) || notices.size() != ids.size()) {
|
|
||||||
throw exception(NOTICE_NOT_FOUND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.notify;
|
package cn.iocoder.yudao.module.system.service.notify;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.util.ReUtil;
|
import cn.hutool.core.util.ReUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
@ -90,23 +89,9 @@ public class NotifyTemplateServiceImpl implements NotifyTemplateService {
|
|||||||
@CacheEvict(cacheNames = RedisKeyConstants.NOTIFY_TEMPLATE,
|
@CacheEvict(cacheNames = RedisKeyConstants.NOTIFY_TEMPLATE,
|
||||||
allEntries = true) // allEntries 清空所有缓存,因为 id 不是直接的缓存 code,不好清理
|
allEntries = true) // allEntries 清空所有缓存,因为 id 不是直接的缓存 code,不好清理
|
||||||
public void deleteNotifyTemplateList(List<Long> ids) {
|
public void deleteNotifyTemplateList(List<Long> ids) {
|
||||||
// 校验存在
|
|
||||||
validateNotifyTemplatesExists(ids);
|
|
||||||
// 批量删除
|
|
||||||
notifyTemplateMapper.deleteByIds(ids);
|
notifyTemplateMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateNotifyTemplatesExists(List<Long> ids) {
|
|
||||||
if (CollUtil.isEmpty(ids)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 校验存在
|
|
||||||
List<NotifyTemplateDO> templates = notifyTemplateMapper.selectByIds(ids);
|
|
||||||
if (CollUtil.isEmpty(templates) || templates.size() != ids.size()) {
|
|
||||||
throw exception(NOTIFY_TEMPLATE_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateNotifyTemplateExists(Long id) {
|
private void validateNotifyTemplateExists(Long id) {
|
||||||
if (notifyTemplateMapper.selectById(id) == null) {
|
if (notifyTemplateMapper.selectById(id) == null) {
|
||||||
throw exception(NOTIFY_TEMPLATE_NOT_EXISTS);
|
throw exception(NOTIFY_TEMPLATE_NOT_EXISTS);
|
||||||
|
@ -77,12 +77,6 @@ public class OAuth2ClientServiceImpl implements OAuth2ClientService {
|
|||||||
@CacheEvict(cacheNames = RedisKeyConstants.OAUTH_CLIENT,
|
@CacheEvict(cacheNames = RedisKeyConstants.OAUTH_CLIENT,
|
||||||
allEntries = true) // allEntries 清空所有缓存,因为 id 不是直接的缓存 key,不好清理
|
allEntries = true) // allEntries 清空所有缓存,因为 id 不是直接的缓存 key,不好清理
|
||||||
public void deleteOAuth2ClientList(List<Long> ids) {
|
public void deleteOAuth2ClientList(List<Long> ids) {
|
||||||
if (CollUtil.isEmpty(ids)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 校验存在
|
|
||||||
validateOAuth2ClientBatchExists(ids);
|
|
||||||
// 批量删除
|
|
||||||
oauth2ClientMapper.deleteByIds(ids);
|
oauth2ClientMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,13 +86,6 @@ public class OAuth2ClientServiceImpl implements OAuth2ClientService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateOAuth2ClientBatchExists(List<Long> ids) {
|
|
||||||
List<OAuth2ClientDO> clients = oauth2ClientMapper.selectByIds(ids);
|
|
||||||
if (clients.size() != ids.size()) {
|
|
||||||
throw exception(OAUTH2_CLIENT_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void validateClientIdExists(Long id, String clientId) {
|
void validateClientIdExists(Long id, String clientId) {
|
||||||
OAuth2ClientDO client = oauth2ClientMapper.selectByClientId(clientId);
|
OAuth2ClientDO client = oauth2ClientMapper.selectByClientId(clientId);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.sms;
|
package cn.iocoder.yudao.module.system.service.sms;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO;
|
||||||
@ -68,18 +67,14 @@ public class SmsChannelServiceImpl implements SmsChannelService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteSmsChannelList(List<Long> ids) {
|
public void deleteSmsChannelList(List<Long> ids) {
|
||||||
if (CollUtil.isEmpty(ids)) {
|
// 1. 校验是否有在使用该账号的模版
|
||||||
return;
|
ids.forEach(id -> {
|
||||||
}
|
|
||||||
// 校验存在
|
|
||||||
validateSmsChannelBatchExists(ids);
|
|
||||||
// 校验是否有在使用该账号的模版
|
|
||||||
for (Long id : ids) {
|
|
||||||
if (smsTemplateService.getSmsTemplateCountByChannelId(id) > 0) {
|
if (smsTemplateService.getSmsTemplateCountByChannelId(id) > 0) {
|
||||||
throw exception(SMS_CHANNEL_HAS_CHILDREN);
|
throw exception(SMS_CHANNEL_HAS_CHILDREN);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
// 批量删除
|
|
||||||
|
// 2. 批量删除
|
||||||
smsChannelMapper.deleteByIds(ids);
|
smsChannelMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,13 +86,6 @@ public class SmsChannelServiceImpl implements SmsChannelService {
|
|||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateSmsChannelBatchExists(List<Long> ids) {
|
|
||||||
List<SmsChannelDO> channels = smsChannelMapper.selectByIds(ids);
|
|
||||||
if (channels.size() != ids.size()) {
|
|
||||||
throw exception(SMS_CHANNEL_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SmsChannelDO getSmsChannel(Long id) {
|
public SmsChannelDO getSmsChannel(Long id) {
|
||||||
return smsChannelMapper.selectById(id);
|
return smsChannelMapper.selectById(id);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.sms;
|
package cn.iocoder.yudao.module.system.service.sms;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.util.ReUtil;
|
import cn.hutool.core.util.ReUtil;
|
||||||
@ -105,12 +104,6 @@ public class SmsTemplateServiceImpl implements SmsTemplateService {
|
|||||||
@CacheEvict(cacheNames = RedisKeyConstants.SMS_TEMPLATE,
|
@CacheEvict(cacheNames = RedisKeyConstants.SMS_TEMPLATE,
|
||||||
allEntries = true) // allEntries 清空所有缓存,因为 id 不是直接的缓存 code,不好清理
|
allEntries = true) // allEntries 清空所有缓存,因为 id 不是直接的缓存 code,不好清理
|
||||||
public void deleteSmsTemplateList(List<Long> ids) {
|
public void deleteSmsTemplateList(List<Long> ids) {
|
||||||
if (CollUtil.isEmpty(ids)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 校验存在
|
|
||||||
validateSmsTemplateListExists(ids);
|
|
||||||
// 批量删除
|
|
||||||
smsTemplateMapper.deleteByIds(ids);
|
smsTemplateMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,13 +113,6 @@ public class SmsTemplateServiceImpl implements SmsTemplateService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateSmsTemplateListExists(List<Long> ids) {
|
|
||||||
List<SmsTemplateDO> templates = smsTemplateMapper.selectByIds(ids);
|
|
||||||
if (templates.size() != ids.size()) {
|
|
||||||
throw exception(SMS_TEMPLATE_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SmsTemplateDO getSmsTemplate(Long id) {
|
public SmsTemplateDO getSmsTemplate(Long id) {
|
||||||
return smsTemplateMapper.selectById(id);
|
return smsTemplateMapper.selectById(id);
|
||||||
|
@ -468,12 +468,6 @@ public class SocialClientServiceImpl implements SocialClientService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteSocialClientList(List<Long> ids) {
|
public void deleteSocialClientList(List<Long> ids) {
|
||||||
if (CollUtil.isEmpty(ids)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 校验存在
|
|
||||||
validateSocialClientBatchExists(ids);
|
|
||||||
// 批量删除
|
|
||||||
socialClientMapper.deleteByIds(ids);
|
socialClientMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,13 +477,6 @@ public class SocialClientServiceImpl implements SocialClientService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateSocialClientBatchExists(List<Long> ids) {
|
|
||||||
List<SocialClientDO> clients = socialClientMapper.selectByIds(ids);
|
|
||||||
if (clients.size() != ids.size()) {
|
|
||||||
throw exception(SOCIAL_CLIENT_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验社交应用是否重复,需要保证 userType + socialType 唯一
|
* 校验社交应用是否重复,需要保证 userType + socialType 唯一
|
||||||
* 原因是,不同端(userType)选择某个社交登录(socialType)时,需要通过 {@link #buildAuthRequest(Integer, Integer)} 构建对应的请求
|
* 原因是,不同端(userType)选择某个社交登录(socialType)时,需要通过 {@link #buildAuthRequest(Integer, Integer)} 构建对应的请求
|
||||||
|
@ -78,14 +78,14 @@ public class TenantPackageServiceImpl implements TenantPackageService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteTenantPackageList(List<Long> ids) {
|
public void deleteTenantPackageList(List<Long> ids) {
|
||||||
if (CollUtil.isEmpty(ids)) {
|
// 1. 校验是否有租户正在使用该套餐
|
||||||
return;
|
for (Long id : ids) {
|
||||||
|
if (tenantService.getTenantCountByPackageId(id) > 0) {
|
||||||
|
throw exception(TENANT_PACKAGE_USED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 校验存在
|
|
||||||
ids.forEach(this::validateTenantPackageExists);
|
// 2. 批量删除
|
||||||
// 校验正在使用
|
|
||||||
validateTenantUsedBatch(ids);
|
|
||||||
// 批量删除
|
|
||||||
tenantPackageMapper.deleteByIds(ids);
|
tenantPackageMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,20 +103,6 @@ public class TenantPackageServiceImpl implements TenantPackageService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验租户套餐是否被使用 - 批量
|
|
||||||
*
|
|
||||||
* @param ids 租户套餐编号数组
|
|
||||||
*/
|
|
||||||
private void validateTenantUsedBatch(List<Long> ids) {
|
|
||||||
// 查询是否有租户正在使用该套餐
|
|
||||||
for (Long id : ids) {
|
|
||||||
if (tenantService.getTenantCountByPackageId(id) > 0) {
|
|
||||||
throw exception(TENANT_PACKAGE_USED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TenantPackageDO getTenantPackage(Long id) {
|
public TenantPackageDO getTenantPackage(Long id) {
|
||||||
return tenantPackageMapper.selectById(id);
|
return tenantPackageMapper.selectById(id);
|
||||||
|
@ -227,12 +227,10 @@ public class TenantServiceImpl implements TenantService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteTenantList(List<Long> ids) {
|
public void deleteTenantList(List<Long> ids) {
|
||||||
if (CollUtil.isEmpty(ids)) {
|
// 1. 校验存在
|
||||||
return;
|
ids.forEach(this::validateUpdateTenant);
|
||||||
}
|
|
||||||
// 校验存在
|
// 2. 批量删除
|
||||||
validateUpdateTenantBatch(ids);
|
|
||||||
// 批量删除
|
|
||||||
tenantMapper.deleteByIds(ids);
|
tenantMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,26 +246,6 @@ public class TenantServiceImpl implements TenantService {
|
|||||||
return tenant;
|
return tenant;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验租户是否可以更新 - 批量
|
|
||||||
*
|
|
||||||
* @param ids 租户编号数组
|
|
||||||
*/
|
|
||||||
private void validateUpdateTenantBatch(List<Long> ids) {
|
|
||||||
// 查询租户
|
|
||||||
List<TenantDO> tenants = tenantMapper.selectByIds(ids);
|
|
||||||
if (tenants.size() != ids.size()) {
|
|
||||||
throw exception(TENANT_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 校验是否有系统内置租户
|
|
||||||
tenants.forEach(tenant -> {
|
|
||||||
if (isSystemTenant(tenant)) {
|
|
||||||
throw exception(TENANT_CAN_NOT_UPDATE_SYSTEM);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TenantDO getTenant(Long id) {
|
public TenantDO getTenant(Long id) {
|
||||||
return tenantMapper.selectById(id);
|
return tenantMapper.selectById(id);
|
||||||
|
@ -251,19 +251,10 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteUserList(List<Long> ids) {
|
public void deleteUserList(List<Long> ids) {
|
||||||
if (CollUtil.isEmpty(ids)) {
|
// 1. 批量删除用户
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 1. 校验用户存在
|
|
||||||
List<AdminUserDO> users = userMapper.selectByIds(ids);
|
|
||||||
if (CollUtil.isEmpty(users)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 批量删除用户
|
|
||||||
userMapper.deleteByIds(ids);
|
userMapper.deleteByIds(ids);
|
||||||
|
|
||||||
// 3. 批量删除用户关联数据
|
// 2. 批量删除用户关联数据
|
||||||
ids.forEach(id -> {
|
ids.forEach(id -> {
|
||||||
permissionService.processUserDeleted(id);
|
permissionService.processUserDeleted(id);
|
||||||
userPostMapper.deleteByUserId(id);
|
userPostMapper.deleteByUserId(id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user