Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor,feat: UseCase 어노테이션 적용 및 Exception 적용 범위 포함 #148

Merged
merged 2 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package vook.server.api.globalcommon.annotation;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Service
@Validated
@Transactional
public @interface UseCase {
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package vook.server.api.domain.common.exception;
package vook.server.api.globalcommon.exception;

import jakarta.validation.ConstraintViolationException;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import vook.server.api.globalcommon.exception.ParameterValidateException;

@Aspect
@Component
public class ExceptionAdvisor {

// vook.server.api.domain 패키지 이하의 모든 메서드에 대해 실행
@Around("execution(* vook.server.api.domain..*.*(..))")
public class ExceptionConvertAdvisor {

@Around("""
@within(vook.server.api.globalcommon.annotation.DomainLogic) ||
@within(vook.server.api.globalcommon.annotation.UseCase)
""")
public Object convertException(ProceedingJoinPoint joinPoint) throws Throwable {
try {
return joinPoint.proceed();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package vook.server.api.web.term.usecase;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vook.server.api.domain.user.logic.UserLogic;
import vook.server.api.domain.vocabulary.logic.TermLogic;
import vook.server.api.domain.vocabulary.model.Term;
import vook.server.api.globalcommon.annotation.UseCase;
import vook.server.api.policy.VocabularyPolicy;

import java.util.List;

@Service
@Transactional
@UseCase
@RequiredArgsConstructor
public class BatchDeleteTermUseCase {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package vook.server.api.web.term.usecase;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vook.server.api.domain.user.logic.UserLogic;
import vook.server.api.domain.vocabulary.logic.TermLogic;
import vook.server.api.domain.vocabulary.logic.VocabularyLogic;
import vook.server.api.domain.vocabulary.logic.dto.TermCreateCommand;
import vook.server.api.domain.vocabulary.model.Term;
import vook.server.api.domain.vocabulary.model.Vocabulary;
import vook.server.api.globalcommon.annotation.UseCase;
import vook.server.api.policy.VocabularyPolicy;

import java.util.List;

@Service
@Transactional
@UseCase
@RequiredArgsConstructor
public class CreateTermUseCase {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package vook.server.api.web.term.usecase;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vook.server.api.domain.user.logic.UserLogic;
import vook.server.api.domain.vocabulary.logic.TermLogic;
import vook.server.api.domain.vocabulary.model.Term;
import vook.server.api.globalcommon.annotation.UseCase;
import vook.server.api.policy.VocabularyPolicy;

@Service
@Transactional
@UseCase
@RequiredArgsConstructor
public class DeleteTermUseCase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vook.server.api.domain.user.logic.UserLogic;
import vook.server.api.domain.vocabulary.logic.VocabularyLogic;
import vook.server.api.domain.vocabulary.model.Term;
import vook.server.api.domain.vocabulary.model.Vocabulary;
import vook.server.api.globalcommon.annotation.UseCase;
import vook.server.api.policy.VocabularyPolicy;

import java.time.LocalDateTime;
import java.util.List;

@Service
@Transactional
@UseCase
@RequiredArgsConstructor
public class RetrieveTermUseCase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@
import jakarta.validation.constraints.NotEmpty;
import lombok.Builder;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import vook.server.api.domain.vocabulary.logic.VocabularyLogic;
import vook.server.api.domain.vocabulary.model.UserUid;
import vook.server.api.globalcommon.annotation.UseCase;
import vook.server.api.policy.VocabularyPolicy;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Validated
@Transactional
@UseCase
@RequiredArgsConstructor
public class SearchTermUseCase {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package vook.server.api.web.term.usecase;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vook.server.api.domain.user.logic.UserLogic;
import vook.server.api.domain.vocabulary.logic.TermLogic;
import vook.server.api.domain.vocabulary.logic.dto.TermUpdateCommand;
import vook.server.api.domain.vocabulary.model.Term;
import vook.server.api.globalcommon.annotation.UseCase;
import vook.server.api.policy.VocabularyPolicy;

import java.util.List;

@Service
@Transactional
@UseCase
@RequiredArgsConstructor
public class UpdateTermUseCase {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package vook.server.api.web.user.usecase;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vook.server.api.domain.user.logic.UserLogic;
import vook.server.api.domain.user.logic.dto.UserOnboardingCommand;
import vook.server.api.domain.user.model.Funnel;
Expand All @@ -16,11 +14,11 @@
import vook.server.api.domain.vocabulary.model.TemplateVocabularyType;
import vook.server.api.domain.vocabulary.model.UserUid;
import vook.server.api.domain.vocabulary.model.Vocabulary;
import vook.server.api.globalcommon.annotation.UseCase;

import java.util.List;

@Service
@Transactional
@UseCase
@RequiredArgsConstructor
public class OnboardingUserUseCase {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package vook.server.api.web.user.usecase;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vook.server.api.domain.user.logic.UserLogic;
import vook.server.api.domain.vocabulary.logic.VocabularyLogic;
import vook.server.api.domain.vocabulary.model.UserUid;
import vook.server.api.globalcommon.annotation.UseCase;

@Service
@Transactional
@UseCase
@RequiredArgsConstructor
public class WithdrawUserUseCase {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package vook.server.api.web.vocabulary.usecase;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vook.server.api.domain.user.logic.UserLogic;
import vook.server.api.domain.vocabulary.logic.VocabularyLogic;
import vook.server.api.domain.vocabulary.logic.dto.VocabularyCreateCommand;
import vook.server.api.domain.vocabulary.model.UserUid;
import vook.server.api.globalcommon.annotation.UseCase;

@Service
@Transactional
@UseCase
@RequiredArgsConstructor
public class CreateVocabularyUseCase {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package vook.server.api.web.vocabulary.usecase;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vook.server.api.domain.user.logic.UserLogic;
import vook.server.api.domain.vocabulary.logic.VocabularyLogic;
import vook.server.api.domain.vocabulary.model.Vocabulary;
import vook.server.api.globalcommon.annotation.UseCase;
import vook.server.api.policy.VocabularyPolicy;

@Service
@Transactional
@UseCase
@RequiredArgsConstructor
public class DeleteVocabularyUseCase {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package vook.server.api.web.vocabulary.usecase;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vook.server.api.domain.user.logic.UserLogic;
import vook.server.api.domain.vocabulary.logic.VocabularyLogic;
import vook.server.api.domain.vocabulary.model.UserUid;
import vook.server.api.domain.vocabulary.model.Vocabulary;
import vook.server.api.globalcommon.annotation.UseCase;

import java.time.LocalDateTime;
import java.util.List;

@Service
@Transactional
@UseCase
@RequiredArgsConstructor
public class RetrieveVocabularyUseCase {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package vook.server.api.web.vocabulary.usecase;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vook.server.api.domain.user.logic.UserLogic;
import vook.server.api.domain.vocabulary.logic.VocabularyLogic;
import vook.server.api.domain.vocabulary.logic.dto.VocabularyUpdateCommand;
import vook.server.api.domain.vocabulary.model.Vocabulary;
import vook.server.api.globalcommon.annotation.UseCase;
import vook.server.api.policy.VocabularyPolicy;

@Service
@Transactional
@UseCase
@RequiredArgsConstructor
public class UpdateVocabularyUseCase {

Expand Down