|
|
@@ -14,14 +14,15 @@ import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ClientDO;
|
|
|
import cn.iocoder.yudao.module.system.dal.mysql.oauth2.OAuth2ClientMapper;
|
|
|
import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants;
|
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
-import jakarta.annotation.Resource;
|
|
|
import java.util.Collection;
|
|
|
+import java.util.List;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
|
|
@@ -72,12 +73,32 @@ public class OAuth2ClientServiceImpl implements OAuth2ClientService {
|
|
|
oauth2ClientMapper.deleteById(id);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @CacheEvict(cacheNames = RedisKeyConstants.OAUTH_CLIENT,
|
|
|
+ allEntries = true) // allEntries 清空所有缓存,因为 id 不是直接的缓存 key,不好清理
|
|
|
+ public void deleteOAuth2ClientList(List<Long> ids) {
|
|
|
+ if (CollUtil.isEmpty(ids)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 校验存在
|
|
|
+ validateOAuth2ClientBatchExists(ids);
|
|
|
+ // 批量删除
|
|
|
+ oauth2ClientMapper.deleteByIds(ids);
|
|
|
+ }
|
|
|
+
|
|
|
private void validateOAuth2ClientExists(Long id) {
|
|
|
if (oauth2ClientMapper.selectById(id) == null) {
|
|
|
throw exception(OAUTH2_CLIENT_NOT_EXISTS);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void validateOAuth2ClientBatchExists(List<Long> ids) {
|
|
|
+ List<OAuth2ClientDO> clients = oauth2ClientMapper.selectByIds(ids);
|
|
|
+ if (clients.size() != ids.size()) {
|
|
|
+ throw exception(OAUTH2_CLIENT_NOT_EXISTS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@VisibleForTesting
|
|
|
void validateClientIdExists(Long id, String clientId) {
|
|
|
OAuth2ClientDO client = oauth2ClientMapper.selectByClientId(clientId);
|