cn.herodotus.engine.oauth2.data.jpa.service.HerodotusAuthorizationConsentService Maven / Gradle / Ivy
Show all versions of oauth2-sdk-data-jpa Show documentation
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2020-2030 郑庚伟 ZHENGGENGWEI (码匠君), Licensed under the AGPL License
*
* This file is part of Dante Engine.
*
* Dante Engine is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Dante Engine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
package cn.herodotus.engine.oauth2.data.jpa.service;
import cn.herodotus.engine.data.core.repository.BaseRepository;
import cn.herodotus.engine.data.core.service.BaseService;
import cn.herodotus.engine.oauth2.data.jpa.entity.HerodotusAuthorizationConsent;
import cn.herodotus.engine.oauth2.data.jpa.generator.HerodotusAuthorizationConsentId;
import cn.herodotus.engine.oauth2.data.jpa.repository.HerodotusAuthorizationConsentRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Optional;
/**
* Description: HerodotusAuthorizationConsentService
*
* 这里命名没有按照统一的习惯,主要是为了防止与 spring-authorization-server 已有类的同名而导致Bean注入失败
*
* @author : gengwei.zheng
* @date : 2022/2/25 21:02
*/
@Service
public class HerodotusAuthorizationConsentService extends BaseService {
private static final Logger log = LoggerFactory.getLogger(HerodotusAuthorizationConsentService.class);
private final HerodotusAuthorizationConsentRepository authorizationConsentRepository;
@Autowired
public HerodotusAuthorizationConsentService(HerodotusAuthorizationConsentRepository authorizationConsentRepository) {
this.authorizationConsentRepository = authorizationConsentRepository;
}
@Override
public BaseRepository getRepository() {
return this.authorizationConsentRepository;
}
public Optional findByRegisteredClientIdAndPrincipalName(String registeredClientId, String principalName) {
Optional result = this.authorizationConsentRepository.findByRegisteredClientIdAndPrincipalName(registeredClientId, principalName);
log.trace("[Herodotus] |- HerodotusAuthorizationConsent Service findByRegisteredClientIdAndPrincipalName.");
return result;
}
public void deleteByRegisteredClientIdAndPrincipalName(String registeredClientId, String principalName) {
this.authorizationConsentRepository.deleteByRegisteredClientIdAndPrincipalName(registeredClientId, principalName);
log.trace("[Herodotus] |- HerodotusAuthorizationConsent Service deleteByRegisteredClientIdAndPrincipalName.");
}
}