Skip to content

Commit

Permalink
[feat/CK-242] 로드맵 관련 부분 의존성 리팩토링을 한다 (#206)
Browse files Browse the repository at this point in the history
* refactor: roadmap 관련 코드 패키지 분리

* refactor: RoadmapCreateService에서 goalRoom 의존성 제거

* refactor: RoadmapReadService에서 goalRoom 의존성 제거

* refactor: RoadmapScheduler에서 goalRoom 의존성 제거 및 테스트코드 패키지 분리

* refactor: Roadmap에서 발생한 예외는 RoaadmapException을 던지도록 수정

* refactor: RoadmapSaveArgumentResolver 의존성 역전

* test: 테스트 코드 수정

* chore: build.gradle 수정 (jacoco 테스트 커버리지)

* refactor: roadmap과 roadmapReview에서 member 직접 참조를 삭제

* chore: ScrollResponseMapper common으로 이관

* refactor: 로드맵 삭제 시 하위 골룸 삭제 방식 변경 (OnDelete 옵션 사용)

* chore: 패키지 경로 수정

* refactor: dto 패키지 분리

* refactor: Event 객체에서 도메인 직접 전달 제거

* refactor: RoadmapNode에서 RoadmapContent 의존 제거

* refactor: Roadmap과 RoadmapContent, RoadmapReview간 의존 관계 제거

* refactor: Roadmap 생성 시 태그, RoadmapContent 생성 시 노드들을 필수로 넣도록 수정

* test: RoadmapNodes 테스트코드 추가

* refactor: 불필요한 클래스 삭제

* fix: 데이터베이스 무결성 오류 수정

* refactor: 로드맵 삭제 시 연관된 리뷰 삭제를 이벤트로 발행

* refactor: 불필요한 이벤트 호출 제거
  • Loading branch information
Ohjintaek authored Mar 27, 2024
1 parent 3f01915 commit 9152846
Show file tree
Hide file tree
Showing 206 changed files with 2,383 additions and 3,178 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

import co.kirikiri.auth.service.AuthService;
import co.kirikiri.auth.service.NaverOauthService;
import co.kirikiri.auth.service.dto.response.OauthRedirectResponse;
import co.kirikiri.auth.service.dto.request.LoginRequest;
import co.kirikiri.auth.service.dto.request.ReissueTokenRequest;
import co.kirikiri.auth.service.dto.response.AuthenticationResponse;
import co.kirikiri.auth.service.dto.response.OauthRedirectResponse;
import jakarta.validation.Valid;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -16,6 +15,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;

@RestController
@RequestMapping("/auth")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package co.kirikiri.auth.infra;

import co.kirikiri.auth.service.OauthNetworkService;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpEntity;
Expand All @@ -10,6 +9,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.Map;

@Service
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package co.kirikiri.auth.persistence;

import java.util.Optional;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Repository;
import java.util.Optional;
import java.util.concurrent.TimeUnit;

@Repository
public class RefreshTokenRepositoryImpl implements RefreshTokenRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import co.kirikiri.member.domain.vo.Identifier;
import co.kirikiri.member.domain.vo.Password;
import co.kirikiri.member.persistence.MemberRepository;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;

@Service
@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
import io.jsonwebtoken.JwtException;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.security.Keys;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.crypto.SecretKey;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.crypto.SecretKey;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class JwtTokenProvider implements TokenProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
import co.kirikiri.auth.service.dto.NaverMemberProfileDto;
import co.kirikiri.auth.service.dto.NaverMemberProfileResponseDto;
import co.kirikiri.auth.service.dto.NaverOauthTokenDto;
import co.kirikiri.auth.service.dto.response.OauthRedirectResponse;
import co.kirikiri.auth.service.dto.response.AuthenticationResponse;
import co.kirikiri.auth.service.dto.response.OauthRedirectResponse;
import co.kirikiri.auth.service.mapper.OauthMapper;
import co.kirikiri.member.domain.Member;
import co.kirikiri.member.persistence.MemberRepository;
import co.kirikiri.member.service.MemberService;
import co.kirikiri.member.service.dto.OauthMemberJoinDto;
import co.kirikiri.member.service.dto.request.GenderType;
import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.Map;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.Map;
import java.util.Optional;

@Service
@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package co.kirikiri.auth.service;

import java.util.Map;
import org.springframework.http.ResponseEntity;
import java.util.Map;

public interface OauthNetworkService {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package co.kirikiri.common.aop;

import co.kirikiri.common.exception.BadRequestException;
import co.kirikiri.common.exception.domain.DomainException;
import co.kirikiri.common.exception.ServerException;
import co.kirikiri.common.exception.domain.DomainException;
import co.kirikiri.common.exception.domain.UnexpectedDomainException;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import java.time.Duration;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
Expand All @@ -16,6 +15,7 @@
import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import java.time.Duration;

@Configuration
@EnableCaching
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import co.kirikiri.common.interceptor.AuthInterceptor;
import co.kirikiri.common.resolver.MemberIdentifierArgumentResolver;
import co.kirikiri.common.resolver.RoadmapSaveArgumentResolver;
import java.util.List;
import co.kirikiri.roadmap.resolver.RoadmapSaveArgumentResolver;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.List;

@Configuration
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import co.kirikiri.common.exception.ServerException;
import co.kirikiri.service.dto.ErrorResponse;
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.util.List;

@RestControllerAdvice
public class GlobalExceptionHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest;
import com.amazonaws.services.s3.model.ObjectMetadata;
import java.io.InputStream;
import java.net.URL;
import java.util.Date;
import lombok.RequiredArgsConstructor;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
import java.io.InputStream;
import java.net.URL;
import java.util.Date;

@Service
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package co.kirikiri.common.infra;

import co.kirikiri.common.exception.ServerException;
import java.net.MalformedURLException;
import java.net.URL;
import lombok.RequiredArgsConstructor;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import java.net.MalformedURLException;
import java.net.URL;

@Service
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package co.kirikiri.service.mapper;
package co.kirikiri.common.mapper;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package co.kirikiri.common.service;

import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.stream.Collectors;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.stereotype.Component;

@Component
public class CacheKeyGenerator implements KeyGenerator {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package co.kirikiri.common.service;

import co.kirikiri.service.dto.FileInformation;
import java.net.URL;
import org.springframework.http.HttpMethod;
import java.net.URL;

public interface FileService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import co.kirikiri.service.goalroom.GoalRoomCreateService;
import co.kirikiri.service.goalroom.GoalRoomReadService;
import jakarta.validation.Valid;
import java.net.URI;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
Expand All @@ -33,6 +31,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.net.URI;
import java.util.List;

@RestController
@RequestMapping("/goal-rooms")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
import jakarta.persistence.ManyToOne;
import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.PrePersist;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Objects;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import org.springframework.data.annotation.CreatedDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Objects;

@MappedSuperclass
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand All @@ -31,6 +33,7 @@ public abstract class BaseGoalRoomMember extends BaseEntity {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "goal_room_id", nullable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
@QueryInit(value = {"roadmapContent.roadmap"})
protected GoalRoom goalRoom;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import co.kirikiri.domain.goalroom.exception.GoalRoomException;
import co.kirikiri.domain.goalroom.vo.GoalRoomName;
import co.kirikiri.domain.goalroom.vo.LimitedMemberCount;
import co.kirikiri.domain.roadmap.RoadmapContent;
import co.kirikiri.member.domain.Member;
import co.kirikiri.roadmap.domain.RoadmapContent;
import jakarta.persistence.Column;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
Expand All @@ -14,51 +14,44 @@
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class GoalRoom extends BaseUpdatedTimeEntity {

private static final int DATE_OFFSET = 1;

@Embedded
private final GoalRoomPendingMembers goalRoomPendingMembers = new GoalRoomPendingMembers();
@Embedded
private final GoalRoomMembers goalRoomMembers = new GoalRoomMembers();
@Embedded
private final GoalRoomToDos goalRoomToDos = new GoalRoomToDos();
@Embedded
private final GoalRoomRoadmapNodes goalRoomRoadmapNodes = new GoalRoomRoadmapNodes();
@Embedded
private GoalRoomName name;

@Embedded
private LimitedMemberCount limitedMemberCount;

@Enumerated(value = EnumType.STRING)
private GoalRoomStatus status = GoalRoomStatus.RECRUITING;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "roadmap_content_id", nullable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
private RoadmapContent roadmapContent;

@Column(nullable = false)
private LocalDate startDate;

@Column(nullable = false)
private LocalDate endDate;

@Embedded
private final GoalRoomPendingMembers goalRoomPendingMembers = new GoalRoomPendingMembers();

@Embedded
private final GoalRoomMembers goalRoomMembers = new GoalRoomMembers();

@Embedded
private final GoalRoomToDos goalRoomToDos = new GoalRoomToDos();

@Embedded
private final GoalRoomRoadmapNodes goalRoomRoadmapNodes = new GoalRoomRoadmapNodes();

public GoalRoom(final GoalRoomName name, final LimitedMemberCount limitedMemberCount,
final RoadmapContent roadmapContent, final Member member) {
this(null, name, limitedMemberCount, roadmapContent, member);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import jakarta.persistence.Embeddable;
import jakarta.persistence.FetchType;
import jakarta.persistence.OneToMany;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.BatchSize;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.BatchSize;

@Embeddable
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import co.kirikiri.member.domain.Member;
import jakarta.persistence.Entity;
import java.time.LocalDateTime;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;

@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand Down
Loading

0 comments on commit 9152846

Please sign in to comment.