From f03475cd4b539503a0a565eee238aec5bf3cc26f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=8A=B9=EC=A7=84?= Date: Mon, 4 Nov 2024 17:46:42 +0900 Subject: [PATCH] feat: delete blockchain and batch --- .../backend/aspect/CronjobAuthAspect.java | 42 ---- .../backend/batch/AdminApiToken.java | 29 --- .../backend/batch/GitRepoClientJobConfig.java | 102 ---------- .../batch/GitRepoMemberBatchClient.java | 188 ------------------ .../backend/batch/GitRepoMemberWriter.java | 21 -- .../backend/batch/GitRepoReader.java | 31 --- .../backend/batch/JobScheduler.java | 32 --- .../batch/dto/GitRepoBatchRequest.java | 13 -- .../batch/dto/GitRepoBatchResponse.java | 16 -- .../config/blockchain/BlockchainConfig.java | 76 ------- .../blockchain/BlockchainProperties.java | 26 --- .../config/cronjob/CronjobProperties.java | 20 -- .../config/properties/PropertiesConfig.java | 4 - .../backend/cronjob/CronJobController.java | 35 ---- .../blockchain/client/KlaytnFaucetClient.java | 72 ------- .../controller/BlockchainController.java | 28 --- .../advice/BlockchainErrorAdvice.java | 21 -- .../blockchain/dto/kafka/BlockchainEvent.java | 18 -- .../dto/kafka/BlockchainKafkaResponse.java | 17 -- .../dto/kafka/SmartContractKafkaRequest.java | 16 -- .../dto/kafka/SmartContractKafkaResponse.java | 16 -- .../dto/request/ContractRequest.java | 19 -- .../dto/response/BlockchainResponse.java | 24 --- .../dto/response/BlockchainResponses.java | 14 -- .../domain/blockchain/entity/Blockchain.java | 81 -------- .../blockchain/entity/ContributeType.java | 17 -- .../domain/blockchain/entity/History.java | 57 ------ .../exception/BlockchainException.java | 13 -- .../blockchain/mapper/BlockchainMapper.java | 52 ----- .../messagequeue/BlockchainConsumer.java | 37 ---- .../messagequeue/BlockchainProducer.java | 24 --- .../repository/BlockchainRepository.java | 24 --- .../repository/JpaBlockchainRepository.java | 21 -- .../blockchain/service/BlockchainService.java | 100 ---------- .../service/SmartContractService.java | 64 ------ .../codereview/service/CodeReviewService.java | 16 +- .../domain/commit/service/CommitService.java | 16 +- .../domain/issue/service/IssueService.java | 16 +- .../domain/member/entity/ContributeType.java | 8 + .../backend/domain/member/entity/Member.java | 13 -- .../service/MemberContributionService.java | 11 +- .../domain/member/service/MemberFacade.java | 5 - .../domain/member/service/MemberService.java | 25 +-- .../service/PullRequestService.java | 16 +- .../template/service/ContributionService.java | 53 +---- .../backend/batch/WebClientJobBatchTest.java | 75 ------- .../controller/BlockchainControllerTest.java | 74 ------- .../service/BlockchainServiceTest.java | 101 ---------- .../commit/service/CommitServiceTest.java | 4 +- .../member/service/MemberServiceTest.java | 21 -- .../blockchain/entity/BlockchainFixture.java | 8 +- 51 files changed, 32 insertions(+), 1800 deletions(-) delete mode 100644 backend/src/main/java/com/dragonguard/backend/aspect/CronjobAuthAspect.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/batch/AdminApiToken.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/batch/GitRepoClientJobConfig.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/batch/GitRepoMemberBatchClient.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/batch/GitRepoMemberWriter.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/batch/GitRepoReader.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/batch/JobScheduler.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/batch/dto/GitRepoBatchRequest.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/batch/dto/GitRepoBatchResponse.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/config/blockchain/BlockchainConfig.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/config/blockchain/BlockchainProperties.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/config/cronjob/CronjobProperties.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/cronjob/CronJobController.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/client/KlaytnFaucetClient.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/controller/BlockchainController.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/controller/advice/BlockchainErrorAdvice.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/kafka/BlockchainEvent.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/kafka/BlockchainKafkaResponse.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/kafka/SmartContractKafkaRequest.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/kafka/SmartContractKafkaResponse.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/request/ContractRequest.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/response/BlockchainResponse.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/response/BlockchainResponses.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/entity/Blockchain.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/entity/ContributeType.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/entity/History.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/exception/BlockchainException.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/mapper/BlockchainMapper.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/messagequeue/BlockchainConsumer.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/messagequeue/BlockchainProducer.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/repository/BlockchainRepository.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/repository/JpaBlockchainRepository.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/service/BlockchainService.java delete mode 100644 backend/src/main/java/com/dragonguard/backend/domain/blockchain/service/SmartContractService.java create mode 100644 backend/src/main/java/com/dragonguard/backend/domain/member/entity/ContributeType.java delete mode 100644 backend/src/test/java/com/dragonguard/backend/batch/WebClientJobBatchTest.java delete mode 100644 backend/src/test/java/com/dragonguard/backend/domain/blockchain/controller/BlockchainControllerTest.java delete mode 100644 backend/src/test/java/com/dragonguard/backend/domain/blockchain/service/BlockchainServiceTest.java diff --git a/backend/src/main/java/com/dragonguard/backend/aspect/CronjobAuthAspect.java b/backend/src/main/java/com/dragonguard/backend/aspect/CronjobAuthAspect.java deleted file mode 100644 index 525554900..000000000 --- a/backend/src/main/java/com/dragonguard/backend/aspect/CronjobAuthAspect.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.dragonguard.backend.aspect; - -import com.dragonguard.backend.config.cronjob.CronjobProperties; -import com.dragonguard.backend.global.exception.CronjobException; - -import lombok.RequiredArgsConstructor; - -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.springframework.stereotype.Component; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - -import javax.servlet.http.HttpServletRequest; - -/** - * @author 김승진 - * @description cronjob 인증을 위한 aop - */ -@Aspect -@Component -@RequiredArgsConstructor -public class CronjobAuthAspect { - - private final CronjobProperties cronjobProperties; - - @Around("execution(* com.dragonguard.backend.cronjob.CronJobController*.*(..))") - public Object adminLoginCheck(final ProceedingJoinPoint proceedingJoinPoint) throws Throwable { - final HttpServletRequest req = - ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()) - .getRequest(); - - final String header = req.getHeader(cronjobProperties.getHeader()); - - if (!header.equals(cronjobProperties.getAuth())) { - throw new CronjobException(); - } - - return proceedingJoinPoint.proceed(); - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/batch/AdminApiToken.java b/backend/src/main/java/com/dragonguard/backend/batch/AdminApiToken.java deleted file mode 100644 index 7a0710039..000000000 --- a/backend/src/main/java/com/dragonguard/backend/batch/AdminApiToken.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.dragonguard.backend.batch; - -import lombok.RequiredArgsConstructor; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * @author 김승진 - * @description 배치처리에 필요한 API 토큰을 설정하는 클래스 - */ -@Component -@RequiredArgsConstructor -public class AdminApiToken { - @Value("#{'${admin-tokens}'.split(',')}") - private List adminTokens; - - private Integer index = 0; - - public synchronized String getApiToken() { - if (index < adminTokens.size()) { - return adminTokens.get(index++); - } - index = 0; - return adminTokens.get(index++); - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/batch/GitRepoClientJobConfig.java b/backend/src/main/java/com/dragonguard/backend/batch/GitRepoClientJobConfig.java deleted file mode 100644 index 5c2221bc0..000000000 --- a/backend/src/main/java/com/dragonguard/backend/batch/GitRepoClientJobConfig.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.dragonguard.backend.batch; - -import com.dragonguard.backend.batch.dto.GitRepoBatchRequest; -import com.dragonguard.backend.domain.gitrepo.entity.GitRepo; -import com.dragonguard.backend.domain.gitrepo.exception.WebClientRetryException; -import com.dragonguard.backend.domain.gitrepomember.entity.GitRepoMember; -import com.dragonguard.backend.global.exception.ClientBadRequestException; -import com.dragonguard.backend.global.exception.WebClientException; -import com.dragonguard.backend.global.template.client.GithubClient; - -import lombok.RequiredArgsConstructor; - -import org.springframework.batch.core.Job; -import org.springframework.batch.core.Step; -import org.springframework.batch.core.configuration.annotation.*; -import org.springframework.batch.item.ItemReader; -import org.springframework.batch.item.function.FunctionItemProcessor; -import org.springframework.batch.item.support.CompositeItemProcessor; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.reactive.function.client.WebClientResponseException; - -import reactor.core.publisher.Mono; - -import java.util.Arrays; -import java.util.List; - -/** - * @author 김승진 - * @description GitRepo 관련 배치 처리의 단위인 Job을 명시하는 클래스 - */ -@Configuration -@EnableBatchProcessing -@RequiredArgsConstructor -public class GitRepoClientJobConfig { - private static final int CHUNK_SIZE = 1; - private static final int RETRY_LIMIT = 2; - private static final String CLIENT_JOB = "clientJob"; - private static final String STEP_NAME = "step"; - private final GithubClient>> - gitRepoMemberBatchClient; - private final JobBuilderFactory jobBuilderFactory; - private final StepBuilderFactory stepBuilderFactory; - private final AdminApiToken adminApiToken; - private final GitRepoMemberWriter gitRepoMemberWriter; - private final GitRepoReader gitRepoReader; - - @Bean - public Job clientJob() { - return jobBuilderFactory.get(CLIENT_JOB).start(step()).preventRestart().build(); - } - - @Bean - @JobScope - public Step step() { - return stepBuilderFactory - .get(STEP_NAME) - .>chunk(CHUNK_SIZE) - .reader(reader()) - .processor(compositeProcessor()) - .faultTolerant() - .retry(WebClientException.class) - .retry(WebClientResponseException.class) - .retry(ClientBadRequestException.class) - .retryLimit(RETRY_LIMIT) - .noRollback(WebClientRetryException.class) - .writer(writer()) - .build(); - } - - @Bean - public CompositeItemProcessor> compositeProcessor() { - CompositeItemProcessor> processor = - new CompositeItemProcessor<>(); - processor.setDelegates(Arrays.asList(clientProcessor(), monoProcessor())); - return processor; - } - - @Bean - public FunctionItemProcessor>> clientProcessor() { - return new FunctionItemProcessor<>( - gitRepo -> - gitRepoMemberBatchClient.requestToGithub( - new GitRepoBatchRequest(adminApiToken.getApiToken(), gitRepo))); - } - - @Bean - public FunctionItemProcessor>, List> monoProcessor() { - return new FunctionItemProcessor<>(mono -> mono.blockOptional().orElseGet(List::of)); - } - - @Bean - public GitRepoMemberWriter writer() { - return gitRepoMemberWriter; - } - - @Bean - @StepScope - public ItemReader reader() { - return gitRepoReader; - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/batch/GitRepoMemberBatchClient.java b/backend/src/main/java/com/dragonguard/backend/batch/GitRepoMemberBatchClient.java deleted file mode 100644 index 1174249ef..000000000 --- a/backend/src/main/java/com/dragonguard/backend/batch/GitRepoMemberBatchClient.java +++ /dev/null @@ -1,188 +0,0 @@ -package com.dragonguard.backend.batch; - -import com.dragonguard.backend.batch.dto.GitRepoBatchRequest; -import com.dragonguard.backend.domain.gitrepo.dto.client.GitRepoMemberClientResponse; -import com.dragonguard.backend.domain.gitrepo.dto.client.Week; -import com.dragonguard.backend.domain.gitrepo.exception.WebClientRetryException; -import com.dragonguard.backend.domain.gitrepo.repository.GitRepoRepository; -import com.dragonguard.backend.domain.gitrepomember.entity.GitRepoMember; -import com.dragonguard.backend.domain.gitrepomember.mapper.GitRepoMemberMapper; -import com.dragonguard.backend.domain.member.entity.AuthStep; -import com.dragonguard.backend.domain.member.entity.Member; -import com.dragonguard.backend.domain.member.entity.Role; -import com.dragonguard.backend.domain.member.mapper.MemberMapper; -import com.dragonguard.backend.domain.member.repository.MemberRepository; -import com.dragonguard.backend.global.exception.EntityNotFoundException; -import com.dragonguard.backend.global.exception.WebClientException; -import com.dragonguard.backend.global.template.client.GithubClient; - -import lombok.RequiredArgsConstructor; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; -import org.springframework.web.reactive.function.client.WebClient; - -import reactor.core.publisher.Mono; -import reactor.util.retry.Retry; - -import java.nio.charset.StandardCharsets; -import java.time.Duration; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - -@Component -@RequiredArgsConstructor -public class GitRepoMemberBatchClient - implements GithubClient>> { - private static final String PATH_FORMAT = "repos/%s/stats/contributors"; - private static final int MAX_ATTEMPTS = 10; - private static final int DURATION_OF_MILLIS = 1500; - private final WebClient webClient; - private final GitRepoMemberMapper gitRepoMemberMapper; - private final MemberMapper memberMapper; - private final GitRepoRepository gitRepoRepository; - private final MemberRepository memberRepository; - - @Override - public Mono> requestToGithub(final GitRepoBatchRequest request) { - return webClient - .get() - .uri( - uriBuilder -> - uriBuilder - .path( - String.format( - PATH_FORMAT, - request.getGitRepo().getName())) - .build()) - .headers(headers -> headers.setBearerAuth(request.getGithubToken())) - .accept(MediaType.APPLICATION_JSON) - .acceptCharset(StandardCharsets.UTF_8) - .retrieve() - .onStatus( - hs -> hs.equals(HttpStatus.ACCEPTED), - response -> Mono.error(WebClientException::new)) - .bodyToFlux(GitRepoMemberClientResponse.class) - .collectList() - .flatMap(this::validateResponse) - .retryWhen( - Retry.fixedDelay(MAX_ATTEMPTS, Duration.ofMillis(DURATION_OF_MILLIS)) - .filter(WebClientException.class::isInstance) - .onRetryExhaustedThrow( - ((retryBackoffSpec, retrySignal) -> - new WebClientRetryException()))) - .onErrorReturn(WebClientRetryException.class, List.of()) - .mapNotNull(result -> getGitRepoMembers(request, result)) - .filter(Objects::nonNull); - } - - private List getGitRepoMembers( - final GitRepoBatchRequest request, final List result) { - final Set gitRepoMembers = request.getGitRepo().getGitRepoMembers(); - return result.stream() - .map(r -> getGitRepoMember(request, r, gitRepoMembers)) - .filter(Optional::isPresent) - .map(Optional::get) - .collect(Collectors.toList()); - } - - private Optional getGitRepoMember( - final GitRepoBatchRequest request, - final GitRepoMemberClientResponse r, - final Set gitRepoMembers) { - if (Objects.isNull(r.getAuthor()) || !StringUtils.hasText(r.getAuthor().getLogin())) { - return Optional.empty(); - } - final List weeks = r.getWeeks(); - - final GitRepoMember newGitRepoMember = getNewGitRepoMember(request, r, gitRepoMembers); - - if (Objects.isNull(newGitRepoMember)) { - return Optional.empty(); - } - - newGitRepoMember.updateGitRepoContribution( - r.getTotal(), - weeks.stream().mapToInt(Week::getA).sum(), - weeks.stream().mapToInt(Week::getD).sum()); - - return Optional.of(newGitRepoMember); - } - - private GitRepoMember getNewGitRepoMember( - final GitRepoBatchRequest request, - final GitRepoMemberClientResponse r, - final Set gitRepoMembers) { - return Optional.ofNullable( - gitRepoMembers.stream() - .filter( - grm -> - grm.getMember() - .getGithubId() - .equals(r.getAuthor().getLogin())) - .findFirst() - .orElseGet(() -> getGitRepoMember(request, r))) - .orElseGet( - () -> - gitRepoMembers.stream() - .filter( - grm -> - grm != null - && grm.getMember() - .getGithubId() - .equals( - r.getAuthor() - .getLogin())) - .findFirst() - .orElse(null)); - } - - private Mono> validateResponse( - final List response) { - if (isResponseEmpty(response)) { - return Mono.error(WebClientException::new); - } - return Mono.just(response); - } - - private boolean isResponseEmpty(final List response) { - return response == null - || response.isEmpty() - || response.stream() - .anyMatch( - g -> - g.getTotal() == null - || g.getWeeks() == null - || g.getWeeks().isEmpty() - || g.getAuthor() == null - || g.getAuthor().getLogin() == null - || g.getAuthor().getAvatarUrl() == null); - } - - private GitRepoMember getGitRepoMember( - final GitRepoBatchRequest request, final GitRepoMemberClientResponse r) { - final String githubId = r.getAuthor().getLogin(); - if (memberRepository.existsByGithubId(githubId)) { - Member member = - memberRepository - .findByGithubIdWithGitRepoMember(githubId) - .orElseThrow(EntityNotFoundException::new); - return gitRepoMemberMapper.toEntity(member, request.getGitRepo()); - } - return gitRepoMemberMapper.toEntity( - memberRepository - .findByGithubIdWithGitRepoMember(githubId) - .orElseGet( - () -> - memberMapper.toEntity( - githubId, Role.ROLE_USER, AuthStep.NONE)), - gitRepoRepository - .findByIdWithGitRepoMember(request.getGitRepo().getId()) - .orElseThrow(EntityNotFoundException::new)); - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/batch/GitRepoMemberWriter.java b/backend/src/main/java/com/dragonguard/backend/batch/GitRepoMemberWriter.java deleted file mode 100644 index 02de6577d..000000000 --- a/backend/src/main/java/com/dragonguard/backend/batch/GitRepoMemberWriter.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.dragonguard.backend.batch; - -import com.dragonguard.backend.domain.gitrepomember.entity.GitRepoMember; -import com.dragonguard.backend.domain.member.repository.MemberRepository; -import java.util.List; -import lombok.RequiredArgsConstructor; -import org.springframework.batch.item.ItemWriter; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -@Component -@RequiredArgsConstructor -public class GitRepoMemberWriter implements ItemWriter> { - private final MemberRepository memberRepository; - - @Override - @Transactional - public void write(final List> items) { - items.stream().flatMap(List::stream).forEach(i -> memberRepository.save(i.getMember())); - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/batch/GitRepoReader.java b/backend/src/main/java/com/dragonguard/backend/batch/GitRepoReader.java deleted file mode 100644 index f32c7eb08..000000000 --- a/backend/src/main/java/com/dragonguard/backend/batch/GitRepoReader.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.dragonguard.backend.batch; - -import com.dragonguard.backend.domain.gitrepo.entity.GitRepo; -import com.dragonguard.backend.domain.gitrepo.repository.GitRepoRepository; -import java.util.ArrayList; -import java.util.List; -import javax.annotation.PostConstruct; -import lombok.RequiredArgsConstructor; -import org.springframework.batch.item.ItemReader; -import org.springframework.context.annotation.Configuration; - -@Configuration -@RequiredArgsConstructor -public class GitRepoReader implements ItemReader { - private final GitRepoRepository gitRepoRepository; - private final List list = new ArrayList<>(); - private int nextIndex = 0; - - @PostConstruct - public void init() { - list.addAll(gitRepoRepository.findAll()); - } - - @Override - public synchronized GitRepo read() { - if (nextIndex < list.size()) { - return list.get(nextIndex++); - } - return null; - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/batch/JobScheduler.java b/backend/src/main/java/com/dragonguard/backend/batch/JobScheduler.java deleted file mode 100644 index bcd708e81..000000000 --- a/backend/src/main/java/com/dragonguard/backend/batch/JobScheduler.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.dragonguard.backend.batch; - -import lombok.RequiredArgsConstructor; - -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobParameter; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.launch.JobLauncher; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.annotation.Scheduled; - -import java.time.LocalDateTime; -import java.util.HashMap; -import java.util.Map; - -/** - * @author 김승진 - * @description GitRepo 관련 배치 처리를 수행하는 클래스 - */ -@Configuration -@RequiredArgsConstructor -public class JobScheduler { - private static final String MAP_KEY_NOW = "now"; - private final JobLauncher jobLauncher; - private final Job clientJob; - - public void launchJob() throws Exception { - final Map jobParametersMap = new HashMap<>(); - jobParametersMap.put(MAP_KEY_NOW, new JobParameter(LocalDateTime.now().toString())); - jobLauncher.run(clientJob, new JobParameters(jobParametersMap)); - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/batch/dto/GitRepoBatchRequest.java b/backend/src/main/java/com/dragonguard/backend/batch/dto/GitRepoBatchRequest.java deleted file mode 100644 index af5ad211d..000000000 --- a/backend/src/main/java/com/dragonguard/backend/batch/dto/GitRepoBatchRequest.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.dragonguard.backend.batch.dto; - -import com.dragonguard.backend.domain.gitrepo.entity.GitRepo; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public class GitRepoBatchRequest { - private String githubToken; - private GitRepo gitRepo; -} diff --git a/backend/src/main/java/com/dragonguard/backend/batch/dto/GitRepoBatchResponse.java b/backend/src/main/java/com/dragonguard/backend/batch/dto/GitRepoBatchResponse.java deleted file mode 100644 index 3de8d0630..000000000 --- a/backend/src/main/java/com/dragonguard/backend/batch/dto/GitRepoBatchResponse.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.dragonguard.backend.batch.dto; - -import com.dragonguard.backend.domain.gitrepo.dto.client.Author; -import com.dragonguard.backend.domain.gitrepo.dto.client.Week; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor -@AllArgsConstructor -public class GitRepoBatchResponse { - private Integer total; - private Week[] weeks; - private Author author; -} diff --git a/backend/src/main/java/com/dragonguard/backend/config/blockchain/BlockchainConfig.java b/backend/src/main/java/com/dragonguard/backend/config/blockchain/BlockchainConfig.java deleted file mode 100644 index aa8f498ce..000000000 --- a/backend/src/main/java/com/dragonguard/backend/config/blockchain/BlockchainConfig.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.dragonguard.backend.config.blockchain; - -import com.dragonguard.backend.domain.blockchain.exception.BlockchainException; -import com.klaytn.caver.Caver; -import com.klaytn.caver.contract.Contract; -import com.klaytn.caver.contract.SendOptions; -import com.klaytn.caver.wallet.keyring.AbstractKeyring; -import com.klaytn.caver.wallet.keyring.KeyringFactory; - -import lombok.RequiredArgsConstructor; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.web3j.crypto.CipherException; - -import java.io.IOException; -import java.math.BigInteger; - -/** - * @author 김승진 - * @description 블록체인 관련 라이브러리 Caver-java 관련 클래스들을 Spring Bean으로 등록하는 설정 클래스 - */ -@Configuration -@RequiredArgsConstructor -public class BlockchainConfig { - private static final String BAOBAB_TESTNET = "https://api.baobab.klaytn.net:8651"; - private static final String TOKEN_NAME = "Gitter"; - private static final String TOKEN_SYMBOL = "GTR"; - private static final Long TOKEN_AMOUNT = 10000000000000L; - private static final Integer DEFAULT_GAS_VALUE = 4000000; - private final BlockchainProperties blockchainProperties; - - @Bean - public AbstractKeyring keyring() { - try { - return KeyringFactory.decrypt( - blockchainProperties.getKeyring(), blockchainProperties.getPassword()); - } catch (CipherException | IOException e) { - throw new BlockchainException(); - } - } - - @Bean - public Caver caver() { - return new Caver(BAOBAB_TESTNET); - } - - @Bean - public Contract contract() { - final Caver caver = caver(); - final AbstractKeyring keyring = keyring(); - caver.wallet.add(keyring); - try { - final Contract contract = caver.contract.create(blockchainProperties.getAbi()); - return contract.deploy( - sendOptions(), - blockchainProperties.getByteCode(), - TOKEN_NAME, - TOKEN_SYMBOL, - BigInteger.valueOf(TOKEN_AMOUNT)); - } catch (Exception e) { - throw new BlockchainException(); - } - } - - @Bean - public SendOptions sendOptions() { - final AbstractKeyring keyring = keyring(); - final SendOptions options = new SendOptions(); - options.setFrom(keyring.getAddress()); - options.setGas(BigInteger.valueOf(DEFAULT_GAS_VALUE)); - options.setFeeDelegation(true); - options.setFeePayer(keyring.getAddress()); - return options; - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/config/blockchain/BlockchainProperties.java b/backend/src/main/java/com/dragonguard/backend/config/blockchain/BlockchainProperties.java deleted file mode 100644 index b6e0c9d59..000000000 --- a/backend/src/main/java/com/dragonguard/backend/config/blockchain/BlockchainProperties.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.dragonguard.backend.config.blockchain; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.ConstructorBinding; - -/** - * @author 김승진 - * @description 블록체인 관련 application.yml의 환경변수를 받아오는 클래스 - */ -@Getter -@ConstructorBinding -@RequiredArgsConstructor -@ConfigurationProperties(prefix = "blockchain") -public class BlockchainProperties { - private final String byteCode; - private final String password; - private final String abi; - private final String keyring; - private final String contractAddress; - private final String walletAddress; - private final String klaytnApiUrl; - private final String userAgent; -} diff --git a/backend/src/main/java/com/dragonguard/backend/config/cronjob/CronjobProperties.java b/backend/src/main/java/com/dragonguard/backend/config/cronjob/CronjobProperties.java deleted file mode 100644 index 361a85d82..000000000 --- a/backend/src/main/java/com/dragonguard/backend/config/cronjob/CronjobProperties.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.dragonguard.backend.config.cronjob; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.ConstructorBinding; - -/** - * @author 김승진 - * @description cronjob 관련 application.yml의 환경변수를 받아오는 클래스 - */ -@Getter -@ConstructorBinding -@RequiredArgsConstructor -@ConfigurationProperties(prefix = "cronjob") -public class CronjobProperties { - private final String header; - private final String auth; -} diff --git a/backend/src/main/java/com/dragonguard/backend/config/properties/PropertiesConfig.java b/backend/src/main/java/com/dragonguard/backend/config/properties/PropertiesConfig.java index 5a3313d3c..c2839261a 100644 --- a/backend/src/main/java/com/dragonguard/backend/config/properties/PropertiesConfig.java +++ b/backend/src/main/java/com/dragonguard/backend/config/properties/PropertiesConfig.java @@ -1,7 +1,5 @@ package com.dragonguard.backend.config.properties; -import com.dragonguard.backend.config.blockchain.BlockchainProperties; -import com.dragonguard.backend.config.cronjob.CronjobProperties; import com.dragonguard.backend.config.redis.RedisProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -13,8 +11,6 @@ */ @Configuration @EnableConfigurationProperties({ - BlockchainProperties.class, RedisProperties.class, - CronjobProperties.class }) public class PropertiesConfig {} diff --git a/backend/src/main/java/com/dragonguard/backend/cronjob/CronJobController.java b/backend/src/main/java/com/dragonguard/backend/cronjob/CronJobController.java deleted file mode 100644 index e5c363aae..000000000 --- a/backend/src/main/java/com/dragonguard/backend/cronjob/CronJobController.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.dragonguard.backend.cronjob; - -import com.dragonguard.backend.batch.JobScheduler; -import com.dragonguard.backend.domain.blockchain.client.KlaytnFaucetClient; -import lombok.RequiredArgsConstructor; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author 김승진 - * @description k8s cronjob 컨트롤러 - */ - -@RestController -@RequiredArgsConstructor -@RequestMapping("/cronjob") -public class CronJobController { - - private final JobScheduler jobScheduler; - private final KlaytnFaucetClient klaytnFaucetClient; - - @PostMapping("/git-repos") - public ResponseEntity gitRepoBatch() throws Exception { - jobScheduler.launchJob(); - return ResponseEntity.ok().build(); - } - - @PostMapping("/klaytn-faucet") - public ResponseEntity requestKlaytnFaucet() { - klaytnFaucetClient.requestKlaytnFaucet(); - return ResponseEntity.ok().build(); - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/client/KlaytnFaucetClient.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/client/KlaytnFaucetClient.java deleted file mode 100644 index 0e909d5ef..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/client/KlaytnFaucetClient.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.client; - -import com.dragonguard.backend.config.blockchain.BlockchainProperties; - -import io.netty.handler.ssl.SslContext; -import io.netty.handler.ssl.SslContextBuilder; -import io.netty.handler.ssl.util.InsecureTrustManagerFactory; - -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.http.client.reactive.ReactorClientHttpConnector; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.util.DefaultUriBuilderFactory; - -import reactor.netty.http.client.HttpClient; - -import java.nio.charset.StandardCharsets; - -import javax.net.ssl.SSLException; - -/** - * @author 김승진 - * @description 24시간 마다 klaytn faucet 발급 api를 요청하는 클라이언트 클래스 - */ -@Component -public class KlaytnFaucetClient { - private static final String ADDRESS_PARAMETER = "address"; - private final BlockchainProperties blockchainProperties; - private final WebClient webClient; - - public KlaytnFaucetClient(final BlockchainProperties blockchainProperties) throws SSLException { - this.blockchainProperties = blockchainProperties; - this.webClient = webClient(); - } - - public void requestKlaytnFaucet() { - webClient - .post() - .uri( - uriBuilder -> - uriBuilder - .queryParam( - ADDRESS_PARAMETER, - blockchainProperties.getWalletAddress()) - .build()) - .headers(headers -> headers.setContentType(MediaType.APPLICATION_JSON)) - .accept(MediaType.APPLICATION_JSON) - .acceptCharset(StandardCharsets.UTF_8); - } - - private WebClient webClient() throws SSLException { - final DefaultUriBuilderFactory factory = - new DefaultUriBuilderFactory(blockchainProperties.getKlaytnApiUrl()); - factory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.VALUES_ONLY); - - final SslContext sslContext = - SslContextBuilder.forClient() - .trustManager(InsecureTrustManagerFactory.INSTANCE) - .build(); - - final HttpClient httpClient = HttpClient.create().secure(t -> t.sslContext(sslContext)); - - return WebClient.builder() - .uriBuilderFactory(factory) - .baseUrl(blockchainProperties.getKlaytnApiUrl()) - .defaultHeader(HttpHeaders.USER_AGENT, blockchainProperties.getUserAgent()) - .clientConnector(new ReactorClientHttpConnector(httpClient)) - .build(); - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/controller/BlockchainController.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/controller/BlockchainController.java deleted file mode 100644 index ed5b61c2c..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/controller/BlockchainController.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.controller; - -import com.dragonguard.backend.domain.blockchain.dto.response.BlockchainResponses; -import com.dragonguard.backend.domain.blockchain.service.BlockchainService; - -import lombok.RequiredArgsConstructor; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author 김승진 - * @description 블록체인 관련 요청을 처리하는 컨트롤러 - */ -@RestController -@RequiredArgsConstructor -@RequestMapping("/blockchain") -public class BlockchainController { - private final BlockchainService blockchainService; - - /** 블록체인 부여 내역을 조회하는 api */ - @GetMapping - public ResponseEntity getBlockchainInfo() { - return ResponseEntity.ok(blockchainService.getBlockchainList()); - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/controller/advice/BlockchainErrorAdvice.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/controller/advice/BlockchainErrorAdvice.java deleted file mode 100644 index 93b6d3ead..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/controller/advice/BlockchainErrorAdvice.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.controller.advice; - -import com.dragonguard.backend.domain.blockchain.exception.BlockchainException; -import com.dragonguard.backend.global.advice.ErrorResponse; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -/** - * @author 김승진 - * @description 블록체인 관련 요청에서 나올 수 있는 예외들을 처리하는 Controller Advice - */ -@RestControllerAdvice -public class BlockchainErrorAdvice { - @ExceptionHandler(BlockchainException.class) - public ResponseEntity blockchainException(final BlockchainException e) { - return ResponseEntity.status(HttpStatus.BAD_REQUEST) - .body(new ErrorResponse(e.getMessage())); - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/kafka/BlockchainEvent.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/kafka/BlockchainEvent.java deleted file mode 100644 index 1c17f7c25..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/kafka/BlockchainEvent.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.dto.kafka; - -import com.dragonguard.backend.domain.blockchain.entity.ContributeType; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.util.UUID; - -@Getter -@NoArgsConstructor -@AllArgsConstructor -public class BlockchainEvent { - private UUID memberId; - private Long amount; - private ContributeType contributeType; -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/kafka/BlockchainKafkaResponse.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/kafka/BlockchainKafkaResponse.java deleted file mode 100644 index b6b5b5785..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/kafka/BlockchainKafkaResponse.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.dto.kafka; - -import com.dragonguard.backend.domain.blockchain.entity.ContributeType; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.util.UUID; - -@Getter -@NoArgsConstructor -@AllArgsConstructor -public class BlockchainKafkaResponse { - private UUID memberId; - private Long amount; - private ContributeType contributeType; -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/kafka/SmartContractKafkaRequest.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/kafka/SmartContractKafkaRequest.java deleted file mode 100644 index cefe2da64..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/kafka/SmartContractKafkaRequest.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.dto.kafka; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.util.UUID; - -@Getter -@NoArgsConstructor -@AllArgsConstructor -public class SmartContractKafkaRequest { - private UUID memberId; - private Long amount; - private Long blockchainId; -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/kafka/SmartContractKafkaResponse.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/kafka/SmartContractKafkaResponse.java deleted file mode 100644 index a2ada0e30..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/kafka/SmartContractKafkaResponse.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.dto.kafka; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.util.UUID; - -@Getter -@NoArgsConstructor -@AllArgsConstructor -public class SmartContractKafkaResponse { - private UUID memberId; - private Long amount; - private Long blockchainId; -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/request/ContractRequest.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/request/ContractRequest.java deleted file mode 100644 index 3ea13a2f1..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/request/ContractRequest.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.dto.request; - -import java.math.BigInteger; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -/** - * @author 김승진 - * @description 블록체인 관련 요청 정보를 담는 dto - */ -@Getter -@NoArgsConstructor -@AllArgsConstructor -public class ContractRequest { - private String contributeType; - @Setter private BigInteger amount; -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/response/BlockchainResponse.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/response/BlockchainResponse.java deleted file mode 100644 index 5d904916a..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/response/BlockchainResponse.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.dto.response; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; - -import java.util.UUID; - -/** - * @author 김승진 - * @description 블록체인 관련 응답 정보를 담는 dto - */ -@Getter -@Builder -@AllArgsConstructor -public class BlockchainResponse { - private Long id; - private String contributeType; - private Long amount; - private String githubId; - private UUID memberId; - private String createdAt; - private String transactionHashUrl; -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/response/BlockchainResponses.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/response/BlockchainResponses.java deleted file mode 100644 index b632a6b52..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/dto/response/BlockchainResponses.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.dto.response; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.util.List; - -@Getter -@NoArgsConstructor -@AllArgsConstructor -public class BlockchainResponses { - private List data; -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/entity/Blockchain.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/entity/Blockchain.java deleted file mode 100644 index 08202ef3a..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/entity/Blockchain.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.entity; - -import com.dragonguard.backend.domain.member.entity.Member; -import com.dragonguard.backend.global.audit.AuditListener; -import com.dragonguard.backend.global.audit.Auditable; -import com.dragonguard.backend.global.audit.BaseTime; -import com.dragonguard.backend.global.audit.SoftDelete; - -import lombok.*; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; - -import javax.persistence.*; - -/** - * @author 김승진 - * @description 블록체인 정보를 담는 DB Entity - */ -@Getter -@Entity -@SoftDelete -@EntityListeners(AuditListener.class) -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class Blockchain implements Auditable { - - @Id @GeneratedValue private Long id; - - @Enumerated(EnumType.STRING) - private ContributeType contributeType; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(columnDefinition = "BINARY(16)") - private Member member; - - private String address; - - @OneToMany( - cascade = {CascadeType.MERGE, CascadeType.PERSIST}, - mappedBy = "blockchain") - private List histories = new ArrayList<>(); - - @Setter - @Embedded - @Column(nullable = false) - private BaseTime baseTime; - - @Builder - public Blockchain(final ContributeType contributeType, final Member member) { - this.contributeType = contributeType; - this.member = member; - this.address = member.getWalletAddress(); - organizeMember(); - } - - private void organizeMember() { - this.member.organizeBlockchain(this); - } - - public void addHistory(final BigInteger amount, final String transactionHash) { - this.histories.add(new History(transactionHash, amount, this)); - } - - public boolean isNewHistory(final long amount) { - return amount > 0 && getSumOfAmount() < amount; - } - - public long getSumOfAmount() { - return this.histories.stream() - .map(History::getAmount) - .mapToLong(BigInteger::longValue) - .sum(); - } - - public void deleteByMember() { - this.histories.forEach(History::delete); - this.histories = new ArrayList<>(); - this.delete(); - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/entity/ContributeType.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/entity/ContributeType.java deleted file mode 100644 index 1d2ab4d12..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/entity/ContributeType.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.entity; - -import lombok.RequiredArgsConstructor; - -/** - * @author 김승진 - * @description 기여 종류를 구별하는 enum - */ -@RequiredArgsConstructor -public enum ContributeType { - COMMIT("커밋"), - ISSUE("이슈"), - PULL_REQUEST("풀리퀘스트"), - CODE_REVIEW("코드리뷰"); - - private final String korean; -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/entity/History.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/entity/History.java deleted file mode 100644 index 96db14d70..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/entity/History.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.entity; - -import com.dragonguard.backend.global.audit.AuditListener; -import com.dragonguard.backend.global.audit.Auditable; -import com.dragonguard.backend.global.audit.BaseTime; -import com.dragonguard.backend.global.audit.SoftDelete; - -import lombok.*; - -import java.math.BigInteger; -import java.time.LocalDateTime; - -import javax.persistence.*; - -@Getter -@Entity -@SoftDelete -@EntityListeners(AuditListener.class) -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class History implements Auditable { - private static final String TRANSACTION_URL_FORMAT = - "https://baobab.scope.klaytn.com/tx/%s?tabId=tokenTransfer"; - private static final Long UPDATE_TIME_UNIT = 20L; - - @Id @GeneratedValue private Long id; - - private String transactionHash; - - private BigInteger amount; - - @JoinColumn - @ManyToOne(fetch = FetchType.LAZY) - private Blockchain blockchain; - - @Setter - @Embedded - @Column(nullable = false) - private BaseTime baseTime; - - @Builder - public History( - final String transactionHash, final BigInteger amount, final Blockchain blockchain) { - this.transactionHash = transactionHash; - this.amount = amount; - this.blockchain = blockchain; - } - - public String getTransactionHashUrl() { - return String.format(TRANSACTION_URL_FORMAT, this.transactionHash); - } - - public boolean isUpdatable() { - return this.baseTime - .getCreatedAt() - .isBefore(LocalDateTime.now().minusSeconds(UPDATE_TIME_UNIT)); - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/exception/BlockchainException.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/exception/BlockchainException.java deleted file mode 100644 index 3f990528b..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/exception/BlockchainException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.exception; - -/** - * @author 김승진 - * @description 블록체인 관련 오류 발생시 던질 예외 클래스 - */ -public class BlockchainException extends IllegalStateException { - private static final String MESSAGE = "블록체인 로직에 오류가 발생했습니다."; - - public BlockchainException() { - super(MESSAGE); - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/mapper/BlockchainMapper.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/mapper/BlockchainMapper.java deleted file mode 100644 index 8f103261e..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/mapper/BlockchainMapper.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.mapper; - -import com.dragonguard.backend.domain.blockchain.dto.response.BlockchainResponse; -import com.dragonguard.backend.domain.blockchain.entity.Blockchain; -import com.dragonguard.backend.domain.blockchain.entity.ContributeType; -import com.dragonguard.backend.domain.blockchain.entity.History; -import com.dragonguard.backend.domain.member.entity.Member; - -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; - -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; - -/** - * @author 김승진 - * @description 블록체인 Entity와 dto의 변환을 돕는 클래스 - */ -@Mapper( - componentModel = "spring", - imports = {ContributeType.class}) -public interface BlockchainMapper { - Blockchain toEntity(final Member member, final ContributeType contributeType); - - @Mapping(target = "amount", expression = "java(history.getAmount().longValue())") - @Mapping(target = "memberId", source = "history.blockchain.member.id") - @Mapping(target = "githubId", source = "history.blockchain.member.githubId") - @Mapping( - target = "createdAt", - expression = "java(history.getBaseTime().getCreatedAt().toString())") - @Mapping( - target = "contributeType", - expression = "java(history.getBlockchain().getContributeType().toString())") - @Mapping(target = "transactionHashUrl", expression = "java(history.getTransactionHashUrl())") - BlockchainResponse toResponse(final History history); - - default List toResponseList(final List histories) { - return histories.stream() - .sorted(Comparator.comparing(h -> h.getBaseTime().getCreatedAt())) - .map(this::toResponse) - .collect(Collectors.toList()); - } - - default List toBlockchainResponseList(final List blockchains) { - return toResponseList( - blockchains.stream() - .map(Blockchain::getHistories) - .flatMap(List::stream) - .collect(Collectors.toList())); - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/messagequeue/BlockchainConsumer.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/messagequeue/BlockchainConsumer.java deleted file mode 100644 index 09497846f..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/messagequeue/BlockchainConsumer.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.messagequeue; - -import com.dragonguard.backend.domain.blockchain.dto.kafka.BlockchainEvent; -import com.dragonguard.backend.domain.blockchain.service.BlockchainService; -import com.dragonguard.backend.domain.member.entity.Member; -import com.dragonguard.backend.global.template.kafka.EventConsumer; -import com.dragonguard.backend.global.template.service.EntityLoader; - -import lombok.RequiredArgsConstructor; - -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.event.TransactionalEventListener; - -import java.util.UUID; - -/** - * @author 김승진 - * @description 블록체인 토큰 생성 요청을 카프카로부터 받아오는 consumer - */ -@Component -@RequiredArgsConstructor -public class BlockchainConsumer implements EventConsumer { - private final EntityLoader memberService; - private final BlockchainService blockchainService; - - @Async - @Transactional(propagation = Propagation.REQUIRES_NEW) - @TransactionalEventListener - @Override - public void consume(final BlockchainEvent event) { - final Member member = memberService.loadEntity(event.getMemberId()); - blockchainService.setTransaction(member, event.getAmount(), event.getContributeType()); - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/messagequeue/BlockchainProducer.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/messagequeue/BlockchainProducer.java deleted file mode 100644 index 708b4e70a..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/messagequeue/BlockchainProducer.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.messagequeue; - -import com.dragonguard.backend.domain.blockchain.dto.kafka.BlockchainEvent; -import com.dragonguard.backend.global.template.kafka.EventProducer; - -import lombok.RequiredArgsConstructor; - -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.stereotype.Component; - -/** - * @author 김승진 - * @description 블록체인 토큰 생성 요청을 카프카로 보내는 Producer - */ -@Component -@RequiredArgsConstructor -public class BlockchainProducer implements EventProducer { - private final ApplicationEventPublisher eventPublisher; - - @Override - public void send(final BlockchainEvent event) { - eventPublisher.publishEvent(event); - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/repository/BlockchainRepository.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/repository/BlockchainRepository.java deleted file mode 100644 index 0d0998383..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/repository/BlockchainRepository.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.repository; - -import com.dragonguard.backend.domain.blockchain.entity.Blockchain; -import com.dragonguard.backend.domain.blockchain.entity.ContributeType; -import com.dragonguard.backend.domain.member.entity.Member; - -import java.util.List; -import java.util.Optional; -import java.util.UUID; - -/** - * @author 김승진 - * @description 블록체인 테이블의 DB 접근을 수행하는 로직을 가진 인터페이스 - */ -public interface BlockchainRepository { - Blockchain save(final Blockchain blockchain); - - Optional findById(final Long id); - - Optional findByMemberAndContributeType( - final Member member, final ContributeType contributeType); - - List findByMemberId(final UUID memberId); -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/repository/JpaBlockchainRepository.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/repository/JpaBlockchainRepository.java deleted file mode 100644 index 85374ea6e..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/repository/JpaBlockchainRepository.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.repository; - -import com.dragonguard.backend.domain.blockchain.entity.Blockchain; -import com.dragonguard.backend.domain.blockchain.entity.ContributeType; -import com.dragonguard.backend.domain.member.entity.Member; - -import org.springframework.data.jpa.repository.JpaRepository; - -import java.util.Optional; - -/** - * @author 김승진 - * @description 블록체인 관련 DB와의 CRUD를 담당하는 클래스 - */ -public interface JpaBlockchainRepository - extends JpaRepository, BlockchainRepository { - Optional findByMemberAndContributeType( - final Member member, final ContributeType contributeType); - - Optional findById(final Long id); -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/service/BlockchainService.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/service/BlockchainService.java deleted file mode 100644 index f897c0661..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/service/BlockchainService.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.service; - -import com.dragonguard.backend.domain.blockchain.dto.response.BlockchainResponse; -import com.dragonguard.backend.domain.blockchain.dto.response.BlockchainResponses; -import com.dragonguard.backend.domain.blockchain.entity.Blockchain; -import com.dragonguard.backend.domain.blockchain.entity.ContributeType; -import com.dragonguard.backend.domain.blockchain.mapper.BlockchainMapper; -import com.dragonguard.backend.domain.blockchain.repository.BlockchainRepository; -import com.dragonguard.backend.domain.member.entity.Member; -import com.dragonguard.backend.domain.member.service.AuthService; -import com.dragonguard.backend.global.annotation.TransactionService; -import com.dragonguard.backend.global.exception.EntityNotFoundException; -import com.dragonguard.backend.global.template.service.EntityLoader; - -import lombok.RequiredArgsConstructor; - -import org.springframework.transaction.annotation.Transactional; - -import java.math.BigInteger; -import java.util.List; -import java.util.UUID; - -/** - * @author 김승진 - * @description 블록체인 관련 DB 요청 및 SmartContractService의 함수들의 호출을 담당하는 클래스 - */ -@TransactionService -@RequiredArgsConstructor -public class BlockchainService implements EntityLoader { - private static final long NO_CONTRIBUTION = 0; - private final BlockchainRepository blockchainRepository; - private final SmartContractService smartContractService; - private final BlockchainMapper blockchainMapper; - private final AuthService authService; - - public void setTransaction( - final Member member, final long contribution, final ContributeType contributeType) { - if (contribution <= NO_CONTRIBUTION) { - return; - } - - final Blockchain blockchain = findByType(member, contributeType); - if (!blockchain.isNewHistory(contribution)) { - return; - } - - final String transactionHash = - sendSmartContract( - member.getWalletAddress(), - contribution - blockchain.getSumOfAmount(), - blockchain); - final BigInteger balance = balanceOfTransaction(member.getWalletAddress()); - final BigInteger expected = BigInteger.valueOf(contribution); - - if (balance.equals(expected)) { - blockchain.addHistory(expected, transactionHash); - } - } - - private String sendSmartContract( - final String walletAddress, final long contribution, final Blockchain blockchain) { - return transferTransaction(contribution, blockchain.getContributeType(), walletAddress); - } - - private BigInteger balanceOfTransaction(final String walletAddress) { - return smartContractService.balanceOf(walletAddress); - } - - private String transferTransaction( - final long contribution, - final ContributeType contributeType, - final String walletAddress) { - return smartContractService.transfer(contribution, contributeType, walletAddress); - } - - @Transactional(readOnly = true) - public BlockchainResponses getBlockchainList() { - final UUID memberId = authService.getLoginUserId(); - return new BlockchainResponses(getBlockchainResponses(memberId)); - } - - private List getBlockchainResponses(final UUID memberId) { - return blockchainMapper.toBlockchainResponseList( - blockchainRepository.findByMemberId(memberId)); - } - - @Override - public Blockchain loadEntity(final Long id) { - return blockchainRepository.findById(id).orElseThrow(EntityNotFoundException::new); - } - - public Blockchain findByType(final Member member, final ContributeType contributeType) { - return blockchainRepository - .findByMemberAndContributeType(member, contributeType) - .orElseGet( - () -> - blockchainRepository.save( - blockchainMapper.toEntity(member, contributeType))); - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/service/SmartContractService.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/service/SmartContractService.java deleted file mode 100644 index bf40de26c..000000000 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/service/SmartContractService.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.service; - -import com.dragonguard.backend.domain.blockchain.entity.ContributeType; -import com.dragonguard.backend.domain.blockchain.exception.BlockchainException; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectWriter; -import com.klaytn.caver.abi.datatypes.Type; -import com.klaytn.caver.contract.Contract; -import com.klaytn.caver.contract.SendOptions; - -import lombok.RequiredArgsConstructor; - -import org.springframework.stereotype.Service; - -import java.math.BigInteger; -import java.util.List; - -/** - * @author 김승진 - * @description 블록체인 스마트 컨트랙트로의 접근을 수행하는 클래스 - */ -@Service -@RequiredArgsConstructor -public class SmartContractService { - private static final String SET_METHOD = "set"; - private static final String BALANCE_OF_METHOD = "balanceOf"; - private final Contract contract; - private final ObjectMapper objectMapper; - private final SendOptions sendOptions; - - public String transfer( - final long contribution, - final ContributeType contributeType, - final String walletAddress) { - try { - return contract.send( - sendOptions, - SET_METHOD, - walletAddress, - BigInteger.valueOf(contribution), - contributeType) - .getTransactionHash(); - } catch (Exception e) { - throw new BlockchainException(); - } - } - - public BigInteger balanceOf(final String address) { - try { - List info = contract.call(BALANCE_OF_METHOD, address); - - return new BigInteger(objectToString(info.get(0).getValue())); - - } catch (Exception e) { - throw new BlockchainException(); - } - } - - private String objectToString(final Object value) throws JsonProcessingException { - ObjectWriter ow = objectMapper.writer().withDefaultPrettyPrinter(); - return ow.writeValueAsString(value); - } -} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/codereview/service/CodeReviewService.java b/backend/src/main/java/com/dragonguard/backend/domain/codereview/service/CodeReviewService.java index a3ebdc255..59d895701 100644 --- a/backend/src/main/java/com/dragonguard/backend/domain/codereview/service/CodeReviewService.java +++ b/backend/src/main/java/com/dragonguard/backend/domain/codereview/service/CodeReviewService.java @@ -1,14 +1,10 @@ package com.dragonguard.backend.domain.codereview.service; -import com.dragonguard.backend.domain.blockchain.dto.kafka.BlockchainEvent; -import com.dragonguard.backend.domain.blockchain.service.BlockchainService; import com.dragonguard.backend.domain.codereview.entity.CodeReview; import com.dragonguard.backend.global.annotation.TransactionService; -import com.dragonguard.backend.global.template.kafka.EventProducer; import com.dragonguard.backend.global.template.mapper.ContributionMapper; import com.dragonguard.backend.global.template.repository.ContributionRepository; import com.dragonguard.backend.global.template.service.ContributionService; -import com.dragonguard.backend.utils.RedisRankingUtils; /** * @author 김승진 @@ -19,15 +15,7 @@ public class CodeReviewService extends ContributionService { public CodeReviewService( final ContributionRepository contributionRepository, - final ContributionMapper commitMapper, - final EventProducer blockchainEventProducer, - final BlockchainService blockchainService, - final RedisRankingUtils redisRankingUtils) { - super( - contributionRepository, - commitMapper, - blockchainEventProducer, - blockchainService, - redisRankingUtils); + final ContributionMapper commitMapper) { + super(contributionRepository, commitMapper); } } diff --git a/backend/src/main/java/com/dragonguard/backend/domain/commit/service/CommitService.java b/backend/src/main/java/com/dragonguard/backend/domain/commit/service/CommitService.java index 39fcf53c6..13c906638 100644 --- a/backend/src/main/java/com/dragonguard/backend/domain/commit/service/CommitService.java +++ b/backend/src/main/java/com/dragonguard/backend/domain/commit/service/CommitService.java @@ -1,14 +1,10 @@ package com.dragonguard.backend.domain.commit.service; -import com.dragonguard.backend.domain.blockchain.dto.kafka.BlockchainEvent; -import com.dragonguard.backend.domain.blockchain.service.BlockchainService; import com.dragonguard.backend.domain.commit.entity.Commit; import com.dragonguard.backend.global.annotation.TransactionService; -import com.dragonguard.backend.global.template.kafka.EventProducer; import com.dragonguard.backend.global.template.mapper.ContributionMapper; import com.dragonguard.backend.global.template.repository.ContributionRepository; import com.dragonguard.backend.global.template.service.ContributionService; -import com.dragonguard.backend.utils.RedisRankingUtils; /** * @author 김승진 @@ -18,15 +14,7 @@ public class CommitService extends ContributionService { public CommitService( final ContributionRepository contributionRepository, - final ContributionMapper commitMapper, - final EventProducer blockchainEventProducer, - final BlockchainService blockchainService, - final RedisRankingUtils redisRankingUtils) { - super( - contributionRepository, - commitMapper, - blockchainEventProducer, - blockchainService, - redisRankingUtils); + final ContributionMapper commitMapper) { + super(contributionRepository, commitMapper); } } diff --git a/backend/src/main/java/com/dragonguard/backend/domain/issue/service/IssueService.java b/backend/src/main/java/com/dragonguard/backend/domain/issue/service/IssueService.java index b80784a76..831008969 100644 --- a/backend/src/main/java/com/dragonguard/backend/domain/issue/service/IssueService.java +++ b/backend/src/main/java/com/dragonguard/backend/domain/issue/service/IssueService.java @@ -1,14 +1,10 @@ package com.dragonguard.backend.domain.issue.service; -import com.dragonguard.backend.domain.blockchain.dto.kafka.BlockchainEvent; -import com.dragonguard.backend.domain.blockchain.service.BlockchainService; import com.dragonguard.backend.domain.issue.entity.Issue; import com.dragonguard.backend.global.annotation.TransactionService; -import com.dragonguard.backend.global.template.kafka.EventProducer; import com.dragonguard.backend.global.template.mapper.ContributionMapper; import com.dragonguard.backend.global.template.repository.ContributionRepository; import com.dragonguard.backend.global.template.service.ContributionService; -import com.dragonguard.backend.utils.RedisRankingUtils; /** * @author 김승진 @@ -19,15 +15,7 @@ public class IssueService extends ContributionService { public IssueService( final ContributionRepository contributionRepository, - final ContributionMapper commitMapper, - final EventProducer blockchainEventProducer, - final BlockchainService blockchainService, - final RedisRankingUtils redisRankingUtils) { - super( - contributionRepository, - commitMapper, - blockchainEventProducer, - blockchainService, - redisRankingUtils); + final ContributionMapper commitMapper) { + super(contributionRepository, commitMapper); } } diff --git a/backend/src/main/java/com/dragonguard/backend/domain/member/entity/ContributeType.java b/backend/src/main/java/com/dragonguard/backend/domain/member/entity/ContributeType.java new file mode 100644 index 000000000..ad8c0a83d --- /dev/null +++ b/backend/src/main/java/com/dragonguard/backend/domain/member/entity/ContributeType.java @@ -0,0 +1,8 @@ +package com.dragonguard.backend.domain.member.entity; + +public enum ContributeType { + CODE_REVIEW, + PULL_REQUEST, + ISSUE, + COMMIT +} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/member/entity/Member.java b/backend/src/main/java/com/dragonguard/backend/domain/member/entity/Member.java index 0ff619bf3..f51a06b1a 100644 --- a/backend/src/main/java/com/dragonguard/backend/domain/member/entity/Member.java +++ b/backend/src/main/java/com/dragonguard/backend/domain/member/entity/Member.java @@ -1,6 +1,5 @@ package com.dragonguard.backend.domain.member.entity; -import com.dragonguard.backend.domain.blockchain.entity.Blockchain; import com.dragonguard.backend.domain.codereview.entity.CodeReview; import com.dragonguard.backend.domain.commit.entity.Commit; import com.dragonguard.backend.domain.gitorganization.entity.GitOrganizationMember; @@ -84,9 +83,6 @@ public class Member implements Auditable { @OneToOne(mappedBy = "member") private CodeReview codeReview; - @OneToMany(mappedBy = "member") - private List blockchains = new ArrayList<>(); - @JoinColumn @Where(clause = "organization_status = 'ACCEPTED'") @ManyToOne(fetch = FetchType.LAZY) @@ -258,11 +254,6 @@ public void validateWalletAddressAndUpdateTier() { updateTier(); } - public void organizeBlockchain(final Blockchain blockchain) { - this.blockchains.add(blockchain); - updateTier(); - } - public boolean isServiceMember() { return this.authStep.isServiceMemberAuthStep(); } @@ -303,10 +294,6 @@ public void withdraw() { this.codeReview.delete(); } this.codeReview = null; - if (!blockchains.isEmpty()) { - this.blockchains.forEach(Blockchain::deleteByMember); - this.blockchains = new ArrayList<>(); - } if (organization != null) { this.organization.deleteMember(this); } diff --git a/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberContributionService.java b/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberContributionService.java index 6570cc71b..ae650e878 100644 --- a/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberContributionService.java +++ b/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberContributionService.java @@ -1,6 +1,5 @@ package com.dragonguard.backend.domain.member.service; -import com.dragonguard.backend.domain.blockchain.entity.ContributeType; import com.dragonguard.backend.domain.codereview.entity.CodeReview; import com.dragonguard.backend.domain.commit.entity.Commit; import com.dragonguard.backend.domain.issue.entity.Issue; @@ -8,6 +7,7 @@ import com.dragonguard.backend.domain.pullrequest.entity.PullRequest; import com.dragonguard.backend.global.annotation.TransactionService; import com.dragonguard.backend.global.template.service.ContributionService; + import lombok.RequiredArgsConstructor; @TransactionService @@ -19,19 +19,18 @@ public class MemberContributionService { private final ContributionService commitService; public void saveCodeReview(final Member member, final int codeReviewNum, final Integer year) { - codeReviewService.saveContribution(member, codeReviewNum, year, ContributeType.CODE_REVIEW); + codeReviewService.saveContribution(member, codeReviewNum, year); } public void savePullRequest(final Member member, final int pullRequestNum, final Integer year) { - pullRequestService.saveContribution( - member, pullRequestNum, year, ContributeType.PULL_REQUEST); + pullRequestService.saveContribution(member, pullRequestNum, year); } public void saveIssue(final Member member, final int issueNum, final Integer year) { - issueService.saveContribution(member, issueNum, year, ContributeType.ISSUE); + issueService.saveContribution(member, issueNum, year); } public void saveCommit(final Member member, final int commitNum, final Integer year) { - commitService.saveContribution(member, commitNum, year, ContributeType.COMMIT); + commitService.saveContribution(member, commitNum, year); } } diff --git a/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberFacade.java b/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberFacade.java index 266d42bbe..5f8874c8f 100644 --- a/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberFacade.java +++ b/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberFacade.java @@ -3,7 +3,6 @@ import com.dragonguard.backend.domain.member.dto.kafka.RepositoryEvent; import com.dragonguard.backend.domain.member.dto.request.WalletRequest; import com.dragonguard.backend.domain.member.dto.response.*; -import com.dragonguard.backend.domain.member.entity.Member; import com.dragonguard.backend.global.annotation.TransactionService; import com.dragonguard.backend.global.template.kafka.EventProducer; @@ -62,10 +61,6 @@ public MemberGitOrganizationRepoResponse findMemberGitOrganizationRepo( } private void sendRepositoryRequestToKafka(final String githubId) { - final Member member = memberService.getMemberByGithubId(githubId); - if (!memberService.isBlockchainUpdatable(member)) { - return; - } kafkaRepositoryProducer.send(new RepositoryEvent(githubId)); } diff --git a/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberService.java b/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberService.java index a85b5cbed..f135f0106 100644 --- a/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberService.java +++ b/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberService.java @@ -1,7 +1,5 @@ package com.dragonguard.backend.domain.member.service; -import com.dragonguard.backend.domain.blockchain.entity.Blockchain; -import com.dragonguard.backend.domain.blockchain.entity.History; import com.dragonguard.backend.domain.gitorganization.entity.GitOrganization; import com.dragonguard.backend.domain.gitorganization.entity.GitOrganizationMember; import com.dragonguard.backend.domain.gitorganization.service.GitOrganizationService; @@ -67,20 +65,7 @@ public Member saveIfNone( public void updateContributions() { final Member member = authService.getLoginUser(); - if (isBlockchainUpdatable(member)) { - sendGitRepoAndContributionRequestToKafka(member.getGithubId()); - } - } - - public boolean isBlockchainUpdatable(final Member member) { - final List blockchains = member.getBlockchains(); - if (blockchains.isEmpty()) { - return true; - } - return blockchains.stream() - .map(Blockchain::getHistories) - .flatMap(List::stream) - .allMatch(History::isUpdatable); + sendGitRepoAndContributionRequestToKafka(member.getGithubId()); } public MemberResponse getMember() { @@ -119,18 +104,10 @@ public void updateWalletAddress(final WalletRequest walletRequest) { } private void sendContributionRequestToKafka(final String githubId) { - final Member member = getMemberByGithubId(githubId); - if (!isBlockchainUpdatable(member)) { - return; - } kafkaContributionClientProducer.send(new ContributionEvent(githubId)); } private void sendRepositoryRequestToKafka(final String githubId) { - final Member member = getMemberByGithubId(githubId); - if (!isBlockchainUpdatable(member)) { - return; - } kafkaRepositoryProducer.send(new RepositoryEvent(githubId)); } diff --git a/backend/src/main/java/com/dragonguard/backend/domain/pullrequest/service/PullRequestService.java b/backend/src/main/java/com/dragonguard/backend/domain/pullrequest/service/PullRequestService.java index 455d04f7a..5a36e33c8 100644 --- a/backend/src/main/java/com/dragonguard/backend/domain/pullrequest/service/PullRequestService.java +++ b/backend/src/main/java/com/dragonguard/backend/domain/pullrequest/service/PullRequestService.java @@ -1,14 +1,10 @@ package com.dragonguard.backend.domain.pullrequest.service; -import com.dragonguard.backend.domain.blockchain.dto.kafka.BlockchainEvent; -import com.dragonguard.backend.domain.blockchain.service.BlockchainService; import com.dragonguard.backend.domain.pullrequest.entity.PullRequest; import com.dragonguard.backend.global.annotation.TransactionService; -import com.dragonguard.backend.global.template.kafka.EventProducer; import com.dragonguard.backend.global.template.mapper.ContributionMapper; import com.dragonguard.backend.global.template.repository.ContributionRepository; import com.dragonguard.backend.global.template.service.ContributionService; -import com.dragonguard.backend.utils.RedisRankingUtils; /** * @author 김승진 @@ -19,15 +15,7 @@ public class PullRequestService extends ContributionService { public PullRequestService( final ContributionRepository contributionRepository, - final ContributionMapper commitMapper, - final EventProducer blockchainEventProducer, - final BlockchainService blockchainService, - final RedisRankingUtils redisRankingUtils) { - super( - contributionRepository, - commitMapper, - blockchainEventProducer, - blockchainService, - redisRankingUtils); + final ContributionMapper commitMapper) { + super(contributionRepository, commitMapper); } } diff --git a/backend/src/main/java/com/dragonguard/backend/global/template/service/ContributionService.java b/backend/src/main/java/com/dragonguard/backend/global/template/service/ContributionService.java index d918fec6f..7c3e7d4c7 100644 --- a/backend/src/main/java/com/dragonguard/backend/global/template/service/ContributionService.java +++ b/backend/src/main/java/com/dragonguard/backend/global/template/service/ContributionService.java @@ -1,17 +1,11 @@ package com.dragonguard.backend.global.template.service; -import com.dragonguard.backend.domain.blockchain.dto.kafka.BlockchainEvent; -import com.dragonguard.backend.domain.blockchain.entity.Blockchain; -import com.dragonguard.backend.domain.blockchain.entity.ContributeType; -import com.dragonguard.backend.domain.blockchain.service.BlockchainService; import com.dragonguard.backend.domain.member.entity.Member; import com.dragonguard.backend.global.annotation.DistributedLock; import com.dragonguard.backend.global.exception.EntityNotFoundException; import com.dragonguard.backend.global.template.entity.Contribution; -import com.dragonguard.backend.global.template.kafka.EventProducer; import com.dragonguard.backend.global.template.mapper.ContributionMapper; import com.dragonguard.backend.global.template.repository.ContributionRepository; -import com.dragonguard.backend.utils.RedisRankingUtils; import lombok.RequiredArgsConstructor; @@ -24,44 +18,31 @@ public abstract class ContributionService implements EntityLoader { private static final long NO_AMOUNT = 0L; private final ContributionRepository contributionRepository; - private final ContributionMapper commitMapper; - private final EventProducer blockchainEventProducer; - private final BlockchainService blockchainService; - private final RedisRankingUtils redisRankingUtils; + private final ContributionMapper contributionMapper; @DistributedLock(name = "#member.getGithubId().concat(#contributeType.name())") public void saveContribution( final Member member, final Integer contributionNum, - final Integer year, - final ContributeType contributeType) { - final Blockchain blockchain = blockchainService.findByType(member, contributeType); - + final Integer year) { if (existsByMemberAndYear(member, year)) { - updateAndSendTransaction(member, contributionNum, year, blockchain, contributeType); + updateAndSendTransaction(member, contributionNum, year); return; } - contributionRepository.save(commitMapper.toEntity(member, contributionNum, year)); - sendTransaction(member, contributionNum.longValue(), blockchain, contributeType); + contributionRepository.save(contributionMapper.toEntity(member, contributionNum, year)); } private void updateAndSendTransaction( - final Member member, - final Integer commitNum, - final Integer year, - final Blockchain blockchain, - final ContributeType contributeType) { + final Member member, final Integer commitNum, final Integer year) { final T contribution = getContribution(member, year); - if (isNotUpdatable(commitNum, contribution, commitNum - blockchain.getSumOfAmount())) { + if (isNotUpdatable(commitNum, contribution)) { return; } contribution.updateContributionNum(commitNum); - sendTransaction(member, commitNum.longValue(), blockchain, contributeType); } - private boolean isNotUpdatable( - final Integer commitNum, final T contribution, final long newBlockchainAmount) { - return contribution.isNotUpdatable(commitNum) && newBlockchainAmount == NO_AMOUNT; + private boolean isNotUpdatable(final Integer commitNum, final T contribution) { + return contribution.isNotUpdatable(commitNum); } private T getContribution(final Member member, final Integer year) { @@ -74,24 +55,6 @@ private boolean existsByMemberAndYear(final Member member, final Integer year) { return contributionRepository.existsByMemberAndYear(member, year); } - private void sendTransaction( - final Member member, - final Long amount, - final Blockchain blockchain, - final ContributeType contributeType) { - if (isInvalidToTransaction(member, amount, blockchain)) { - return; - } - blockchainEventProducer.send(new BlockchainEvent(member.getId(), amount, contributeType)); - } - - private boolean isInvalidToTransaction( - final Member member, final Long amount, final Blockchain blockchain) { - return amount <= NO_AMOUNT - || !member.isWalletAddressExists() - || !blockchain.isNewHistory(amount); - } - public T loadEntity(final ID id) { return contributionRepository.findById(id).orElseThrow(EntityNotFoundException::new); } diff --git a/backend/src/test/java/com/dragonguard/backend/batch/WebClientJobBatchTest.java b/backend/src/test/java/com/dragonguard/backend/batch/WebClientJobBatchTest.java deleted file mode 100644 index 8e1f3f9f3..000000000 --- a/backend/src/test/java/com/dragonguard/backend/batch/WebClientJobBatchTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.dragonguard.backend.batch; - -import com.dragonguard.backend.config.kafka.KafkaConsumerConfig; -import com.dragonguard.backend.config.kafka.KafkaProducerConfig; -import com.dragonguard.backend.domain.gitrepo.repository.GitRepoRepository; -import com.dragonguard.backend.domain.gitrepomember.repository.GitRepoMemberRepository; -import com.dragonguard.backend.support.batch.GitRepoBatchTest; - -import lombok.extern.slf4j.Slf4j; - -import org.junit.Test; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.runner.RunWith; -import org.springframework.batch.test.JobLauncherTestUtils; -import org.springframework.batch.test.context.SpringBatchTest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; -import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa; -import org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestEntityManager; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTypeExcludeFilter; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.FilterType; -import org.springframework.kafka.test.context.EmbeddedKafka; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.test.context.junit4.SpringRunner; - -import javax.persistence.EntityManager; - -@Slf4j -@SpringBatchTest -@AutoConfigureCache -@AutoConfigureDataJpa -@ActiveProfiles("test") -@ImportAutoConfiguration -@AutoConfigureTestDatabase -@EmbeddedKafka(topics = {}) -@DisplayName("배치 작업중에서") -@AutoConfigureTestEntityManager -@ExtendWith(SpringExtension.class) -@TypeExcludeFilters(DataJpaTypeExcludeFilter.class) -@ComponentScan( - excludeFilters = { - @ComponentScan.Filter( - type = FilterType.ASSIGNABLE_TYPE, - classes = {KafkaConsumerConfig.class, KafkaProducerConfig.class}) - }) -@SpringBootTest( - "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration") -@RunWith(SpringRunner.class) -public class WebClientJobBatchTest extends GitRepoBatchTest { - @Autowired private JobLauncherTestUtils jobLauncherTestUtils; - @Autowired private GitRepoMemberRepository gitRepoMemberRepository; - @Autowired private GitRepoRepository gitRepoRepository; - @Autowired private EntityManager em; - - @Test - @DisplayName("깃허브 Rest API를 호출하여 GitRepo의 GitRepoMember를 업데이트하는 작업을 수행하는가") - public void runBatch() throws Exception { - gitRepoRepository.saveAll(gitRepos); - - log.info("BEFORE SIZE: {}", gitRepoMemberRepository.findAll().size()); - - jobLauncherTestUtils.launchJob(); - - em.clear(); - - log.info("AFTER SIZE: {}", gitRepoMemberRepository.findAll().size()); - } -} diff --git a/backend/src/test/java/com/dragonguard/backend/domain/blockchain/controller/BlockchainControllerTest.java b/backend/src/test/java/com/dragonguard/backend/domain/blockchain/controller/BlockchainControllerTest.java deleted file mode 100644 index d3b59cd43..000000000 --- a/backend/src/test/java/com/dragonguard/backend/domain/blockchain/controller/BlockchainControllerTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.controller; - -import static com.dragonguard.backend.support.docs.ApiDocumentUtils.getDocumentRequest; -import static com.dragonguard.backend.support.docs.ApiDocumentUtils.getDocumentResponse; - -import static org.mockito.BDDMockito.given; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import com.dragonguard.backend.domain.blockchain.dto.response.BlockchainResponse; -import com.dragonguard.backend.domain.blockchain.dto.response.BlockchainResponses; -import com.dragonguard.backend.domain.blockchain.entity.ContributeType; -import com.dragonguard.backend.domain.blockchain.service.BlockchainService; -import com.dragonguard.backend.domain.blockchain.service.SmartContractService; -import com.dragonguard.backend.support.docs.RestDocumentTest; - -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.http.MediaType; -import org.springframework.test.web.servlet.ResultActions; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.UUID; - -@DisplayName("blockchain 컨트롤러의") -@WebMvcTest(BlockchainController.class) -class BlockchainControllerTest extends RestDocumentTest { - @MockBean private BlockchainService blockchainService; - @MockBean private SmartContractService smartContractService; - - @Test - @DisplayName("블록체인 부여 기록 리스트 조회가 수행되는가") - void getBlockchainInfo() throws Exception { - List expected = - List.of( - new BlockchainResponse( - 1L, - ContributeType.COMMIT.toString(), - 10L, - "ohksj77", - UUID.randomUUID(), - LocalDateTime.now().toString(), - "123123123"), - new BlockchainResponse( - 2L, - ContributeType.COMMIT.toString(), - 5L, - "ohksj77", - UUID.randomUUID(), - LocalDateTime.now().toString(), - "321321321")); - given(blockchainService.getBlockchainList()).willReturn(new BlockchainResponses(expected)); - - ResultActions perform = - mockMvc.perform( - get("/blockchain") - .contentType(MediaType.APPLICATION_JSON) - .header("Authorization", "Bearer apfawfawfa.awfsfawef2.r4svfv32")); - - perform.andExpect(status().isOk()); - - perform.andDo(print()) - .andDo( - document( - "get blockchain list", - getDocumentRequest(), - getDocumentResponse())); - } -} diff --git a/backend/src/test/java/com/dragonguard/backend/domain/blockchain/service/BlockchainServiceTest.java b/backend/src/test/java/com/dragonguard/backend/domain/blockchain/service/BlockchainServiceTest.java deleted file mode 100644 index 7713e8672..000000000 --- a/backend/src/test/java/com/dragonguard/backend/domain/blockchain/service/BlockchainServiceTest.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.dragonguard.backend.domain.blockchain.service; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; - -import com.dragonguard.backend.domain.blockchain.dto.response.BlockchainResponse; -import com.dragonguard.backend.domain.blockchain.entity.Blockchain; -import com.dragonguard.backend.domain.blockchain.mapper.BlockchainMapper; -import com.dragonguard.backend.domain.blockchain.repository.BlockchainRepository; -import com.dragonguard.backend.domain.member.repository.MemberRepository; -import com.dragonguard.backend.support.database.LoginTest; -import com.dragonguard.backend.support.fixture.blockchain.entity.BlockchainFixture; - -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.mock.mockito.MockBean; - -import java.math.BigInteger; -import java.util.List; -import java.util.stream.Collectors; - -@DisplayName("blockchain 서비스의") -class BlockchainServiceTest extends LoginTest { - - @Autowired private BlockchainService blockchainService; - @Autowired private BlockchainRepository blockchainRepository; - @Autowired private MemberRepository memberRepository; - @Autowired private BlockchainMapper blockchainMapper; - @MockBean private SmartContractService smartContractService; - - @Value("${wallet}") - private String walletAddress; - - @Test - @DisplayName("블록체인 트랜잭션 수행이 수행되는가") - void setTransaction() { - // given - memberRepository - .findById(loginUser.getId()) - .ifPresent(m -> m.updateWalletAddress(walletAddress)); - when(smartContractService.transfer(any(), any(), any())).thenReturn("123123123"); - when(smartContractService.balanceOf(any())).thenReturn(BigInteger.valueOf(1)); - - // when - // blockchainService.setTransaction(loginUser, 1L, ContributeType.COMMIT); - // List blockchains = - // blockchainRepository.findAllByMemberAndContributeType(loginUser, ContributeType.COMMIT); - - // then - // assertThat(blockchains).hasSize(1); - // assertThat(blockchains.get(0).getMember()).isEqualTo(loginUser); - // - // assertThat(blockchains.get(0).getContributeType()).isEqualTo(ContributeType.COMMIT); - } - - @Test - @DisplayName("블록체인 내역 조회가 수행되는가") - void getBlockchainList() { - // given - List given = - List.of( - BlockchainFixture.ONE_COMMIT.toEntity(loginUser), - BlockchainFixture.ONE_COMMIT.toEntity(loginUser), - BlockchainFixture.TWO_ISSUES.toEntity(loginUser)); - given.forEach(blockchainRepository::save); - - List expected = - given.stream() - .map(Blockchain::getHistories) - .flatMap(List::stream) - .map(blockchainMapper::toResponse) - .collect(Collectors.toList()); - - // when - List blockchains = blockchainService.getBlockchainList().getData(); - - // then - assertThat(blockchains).hasSize(3); - assertThat(blockchains.get(0).getMemberId()).isEqualTo(loginUser.getId()); - assertThat(blockchains.get(0).getId()).isEqualTo(expected.get(0).getId()); - assertThat(blockchains.get(1).getId()).isEqualTo(expected.get(1).getId()); - assertThat(blockchains.get(2).getId()).isEqualTo(expected.get(2).getId()); - } - - @Test - @DisplayName("엔티티 id로 조회가 수행되는가") - void loadEntity() { - // given - Blockchain expected = - blockchainRepository.save(BlockchainFixture.ONE_COMMIT.toEntity(loginUser)); - - // when - Blockchain result = blockchainService.loadEntity(expected.getId()); - - // then - assertThat(expected).isEqualTo(result); - } -} diff --git a/backend/src/test/java/com/dragonguard/backend/domain/commit/service/CommitServiceTest.java b/backend/src/test/java/com/dragonguard/backend/domain/commit/service/CommitServiceTest.java index a2194e396..34b3396eb 100644 --- a/backend/src/test/java/com/dragonguard/backend/domain/commit/service/CommitServiceTest.java +++ b/backend/src/test/java/com/dragonguard/backend/domain/commit/service/CommitServiceTest.java @@ -2,7 +2,6 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.dragonguard.backend.domain.blockchain.entity.ContributeType; import com.dragonguard.backend.domain.commit.entity.Commit; import com.dragonguard.backend.domain.commit.repository.CommitRepository; import com.dragonguard.backend.domain.member.repository.MemberRepository; @@ -31,8 +30,7 @@ void saveCommits() { commitService.saveContribution( memberRepository.findById(loginUser.getId()).orElse(null), 100, - LocalDateTime.now().getYear(), - ContributeType.COMMIT); + LocalDateTime.now().getYear()); Optional commits = commitRepository.findByMemberAndYear(loginUser, LocalDate.now().getYear()); diff --git a/backend/src/test/java/com/dragonguard/backend/domain/member/service/MemberServiceTest.java b/backend/src/test/java/com/dragonguard/backend/domain/member/service/MemberServiceTest.java index a1f6da58d..6bedafb93 100644 --- a/backend/src/test/java/com/dragonguard/backend/domain/member/service/MemberServiceTest.java +++ b/backend/src/test/java/com/dragonguard/backend/domain/member/service/MemberServiceTest.java @@ -1,13 +1,7 @@ package com.dragonguard.backend.domain.member.service; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; -import com.dragonguard.backend.domain.blockchain.entity.Blockchain; -import com.dragonguard.backend.domain.blockchain.entity.ContributeType; -import com.dragonguard.backend.domain.blockchain.repository.BlockchainRepository; -import com.dragonguard.backend.domain.blockchain.service.SmartContractService; import com.dragonguard.backend.domain.codereview.entity.CodeReview; import com.dragonguard.backend.domain.codereview.repository.CodeReviewRepository; import com.dragonguard.backend.domain.commit.entity.Commit; @@ -33,10 +27,8 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.data.domain.PageRequest; -import java.math.BigInteger; import java.time.LocalDate; import java.util.List; import java.util.UUID; @@ -51,11 +43,9 @@ class MemberServiceTest extends LoginTest { @Autowired private CommitRepository commitRepository; @Autowired private IssueRepository issueRepository; @Autowired private PullRequestRepository pullRequestRepository; - @Autowired private BlockchainRepository blockchainRepository; @Autowired private OrganizationRepository organizationRepository; @Autowired private CodeReviewRepository codeReviewRepository; @Autowired private EntityManager em; - @MockBean private SmartContractService smartContractService; @Test @DisplayName("멤버 저장 기능이 수행되는가") @@ -98,9 +88,6 @@ void updateContributions() { void updateBlockchain() { // given int year = LocalDate.now().getYear(); - List before = loginUser.getBlockchains(); - when(smartContractService.transfer(any(), any(), any())).thenReturn("123123"); - when(smartContractService.balanceOf(any())).thenReturn(BigInteger.valueOf(200L)); em.flush(); em.clear(); @@ -120,7 +107,6 @@ void updateBlockchain() { memberService.updateBlockchain(); // then - List after = loginUser.getBlockchains(); // // assertThat(before.stream().map(Blockchain::getAmount).mapToLong(BigInteger::longValue).sum()) // @@ -133,13 +119,6 @@ void getTier() { // given loginUser = authService.getLoginUser(); int contributionNum = 20000; - Blockchain blockchain = - blockchainRepository.save( - Blockchain.builder() - .member(loginUser) - .contributeType(ContributeType.COMMIT) - .build()); - blockchain.addHistory(BigInteger.valueOf(20000L), "woiufheawoiuerhg"); loginUser.updateTier(); diff --git a/backend/src/test/java/com/dragonguard/backend/support/fixture/blockchain/entity/BlockchainFixture.java b/backend/src/test/java/com/dragonguard/backend/support/fixture/blockchain/entity/BlockchainFixture.java index 2f5281883..f2c1322b5 100644 --- a/backend/src/test/java/com/dragonguard/backend/support/fixture/blockchain/entity/BlockchainFixture.java +++ b/backend/src/test/java/com/dragonguard/backend/support/fixture/blockchain/entity/BlockchainFixture.java @@ -1,8 +1,6 @@ package com.dragonguard.backend.support.fixture.blockchain.entity; -import com.dragonguard.backend.domain.blockchain.entity.Blockchain; -import com.dragonguard.backend.domain.blockchain.entity.ContributeType; -import com.dragonguard.backend.domain.member.entity.Member; +import com.dragonguard.backend.domain.member.entity.ContributeType; import lombok.AllArgsConstructor; @@ -16,8 +14,4 @@ public enum BlockchainFixture { ContributeType contributeType; BigInteger amount; String transactionHash; - - public Blockchain toEntity(Member member) { - return new Blockchain(contributeType, member); - } }