ru.foodtechlab.lib.auth.service.domain.token.usecases.ExpireAccessTokenByTimeUseCase Maven / Gradle / Ivy
package ru.foodtechlab.lib.auth.service.domain.token.usecases;
import com.rcore.domain.commons.usecase.UseCase;
import com.rcore.domain.commons.usecase.model.IdInputValues;
import com.rcore.domain.commons.usecase.model.SingletonEntityOutputValues;
import lombok.RequiredArgsConstructor;
import ru.foodtechlab.lib.auth.service.domain.token.entity.AccessTokenEntity;
import ru.foodtechlab.lib.auth.service.domain.token.exception.AccessTokenNotFoundException;
import ru.foodtechlab.lib.auth.service.domain.token.port.AccessTokenRepository;
import java.time.Instant;
@RequiredArgsConstructor
public class ExpireAccessTokenByTimeUseCase extends UseCase, SingletonEntityOutputValues> {
private final AccessTokenRepository accessTokenRepository;
@Override
public SingletonEntityOutputValues execute(IdInputValues inputValues) {
AccessTokenEntity accessTokenEntity = accessTokenRepository.findById(inputValues.getId())
.orElseThrow(AccessTokenNotFoundException::new);
accessTokenEntity.setExpireAt(Instant.now());
return SingletonEntityOutputValues.of(accessTokenRepository.save(accessTokenEntity));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy