xyz.erupt.upms.model.data_proxy.EruptOpenApiDataProxy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of erupt-upms Show documentation
Show all versions of erupt-upms Show documentation
User Permissions Management
The newest version!
package xyz.erupt.upms.model.data_proxy;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import xyz.erupt.annotation.fun.DataProxy;
import xyz.erupt.annotation.fun.OperationHandler;
import xyz.erupt.jpa.dao.EruptDao;
import xyz.erupt.linq.lambda.LambdaSee;
import xyz.erupt.upms.model.EruptOpenApi;
import xyz.erupt.upms.service.EruptUserService;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* @author YuePeng
* date 2024/8/11 15:37
*/
@Component
public class EruptOpenApiDataProxy implements DataProxy, OperationHandler {
@Resource
private EruptUserService eruptUserService;
@Resource
private EruptDao eruptDao;
@Override
public void beforeAdd(EruptOpenApi eruptOpenApi) {
eruptOpenApi.setAppid(RandomStringUtils.randomAlphanumeric(16).toLowerCase());
eruptOpenApi.setSecret(RandomStringUtils.randomAlphanumeric(24).toUpperCase());
}
@Override
public void afterUpdate(EruptOpenApi eruptOpenApi) {
if (!eruptOpenApi.getStatus()) {
this.logoutToken(eruptOpenApi);
eruptOpenApi.setCurrentToken(null);
}
}
@Override
public void afterDelete(EruptOpenApi eruptOpenApi) {
this.logoutToken(eruptOpenApi);
}
@Override
public void afterFetch(Collection