diff --git a/src/main/java/in/koreatech/koin/auth/JwtProvider.java b/src/main/java/in/koreatech/koin/domain/auth/JwtProvider.java similarity index 93% rename from src/main/java/in/koreatech/koin/auth/JwtProvider.java rename to src/main/java/in/koreatech/koin/domain/auth/JwtProvider.java index 9f679dfe7..e688cf60c 100644 --- a/src/main/java/in/koreatech/koin/auth/JwtProvider.java +++ b/src/main/java/in/koreatech/koin/domain/auth/JwtProvider.java @@ -1,16 +1,19 @@ -package in.koreatech.koin.auth; +package in.koreatech.koin.domain.auth; -import in.koreatech.koin.domain.user.User; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.security.Keys; import java.security.Key; import java.time.Instant; import java.util.Base64; import java.util.Date; + import javax.crypto.SecretKey; + import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import in.koreatech.koin.domain.user.model.User; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.security.Keys; + @Component public class JwtProvider { diff --git a/src/main/java/in/koreatech/koin/controller/shop/ShopController.java b/src/main/java/in/koreatech/koin/domain/shop/controller/ShopController.java similarity index 79% rename from src/main/java/in/koreatech/koin/controller/shop/ShopController.java rename to src/main/java/in/koreatech/koin/domain/shop/controller/ShopController.java index 71c6b8153..efb4520ef 100644 --- a/src/main/java/in/koreatech/koin/controller/shop/ShopController.java +++ b/src/main/java/in/koreatech/koin/domain/shop/controller/ShopController.java @@ -1,12 +1,12 @@ -package in.koreatech.koin.controller.shop; +package in.koreatech.koin.domain.shop.controller; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; -import in.koreatech.koin.dto.shop.ShopMenuResponse; -import in.koreatech.koin.service.shop.ShopService; +import in.koreatech.koin.domain.shop.dto.ShopMenuResponse; +import in.koreatech.koin.domain.shop.service.ShopService; import lombok.RequiredArgsConstructor; @RestController diff --git a/src/main/java/in/koreatech/koin/dto/shop/ShopMenuResponse.java b/src/main/java/in/koreatech/koin/domain/shop/dto/ShopMenuResponse.java similarity index 90% rename from src/main/java/in/koreatech/koin/dto/shop/ShopMenuResponse.java rename to src/main/java/in/koreatech/koin/domain/shop/dto/ShopMenuResponse.java index 57e2842e9..03dbaf604 100644 --- a/src/main/java/in/koreatech/koin/dto/shop/ShopMenuResponse.java +++ b/src/main/java/in/koreatech/koin/domain/shop/dto/ShopMenuResponse.java @@ -1,14 +1,14 @@ -package in.koreatech.koin.dto.shop; +package in.koreatech.koin.domain.shop.dto; import java.util.List; import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; -import in.koreatech.koin.domain.shop.Menu; -import in.koreatech.koin.domain.shop.MenuCategory; -import in.koreatech.koin.domain.shop.MenuImage; -import in.koreatech.koin.domain.shop.MenuOption; +import in.koreatech.koin.domain.shop.model.Menu; +import in.koreatech.koin.domain.shop.model.MenuCategory; +import in.koreatech.koin.domain.shop.model.MenuImage; +import in.koreatech.koin.domain.shop.model.MenuOption; import lombok.extern.slf4j.Slf4j; @Slf4j diff --git a/src/main/java/in/koreatech/koin/domain/shop/Menu.java b/src/main/java/in/koreatech/koin/domain/shop/model/Menu.java similarity index 95% rename from src/main/java/in/koreatech/koin/domain/shop/Menu.java rename to src/main/java/in/koreatech/koin/domain/shop/model/Menu.java index 80b62296d..0c89a4c53 100644 --- a/src/main/java/in/koreatech/koin/domain/shop/Menu.java +++ b/src/main/java/in/koreatech/koin/domain/shop/model/Menu.java @@ -1,9 +1,9 @@ -package in.koreatech.koin.domain.shop; +package in.koreatech.koin.domain.shop.model; import java.util.ArrayList; import java.util.List; -import in.koreatech.koin.domain.BaseEntity; +import in.koreatech.koin.global.common.BaseEntity; import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; diff --git a/src/main/java/in/koreatech/koin/domain/shop/MenuCategory.java b/src/main/java/in/koreatech/koin/domain/shop/model/MenuCategory.java similarity index 93% rename from src/main/java/in/koreatech/koin/domain/shop/MenuCategory.java rename to src/main/java/in/koreatech/koin/domain/shop/model/MenuCategory.java index 9659baafd..e9c73255d 100644 --- a/src/main/java/in/koreatech/koin/domain/shop/MenuCategory.java +++ b/src/main/java/in/koreatech/koin/domain/shop/model/MenuCategory.java @@ -1,9 +1,9 @@ -package in.koreatech.koin.domain.shop; +package in.koreatech.koin.domain.shop.model; import java.util.ArrayList; import java.util.List; -import in.koreatech.koin.domain.BaseEntity; +import in.koreatech.koin.global.common.BaseEntity; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; diff --git a/src/main/java/in/koreatech/koin/domain/shop/MenuCategoryMap.java b/src/main/java/in/koreatech/koin/domain/shop/model/MenuCategoryMap.java similarity index 97% rename from src/main/java/in/koreatech/koin/domain/shop/MenuCategoryMap.java rename to src/main/java/in/koreatech/koin/domain/shop/model/MenuCategoryMap.java index 0c9478cb9..b5417e86f 100644 --- a/src/main/java/in/koreatech/koin/domain/shop/MenuCategoryMap.java +++ b/src/main/java/in/koreatech/koin/domain/shop/model/MenuCategoryMap.java @@ -1,4 +1,4 @@ -package in.koreatech.koin.domain.shop; +package in.koreatech.koin.domain.shop.model; import jakarta.persistence.CascadeType; import jakarta.persistence.Column; diff --git a/src/main/java/in/koreatech/koin/domain/shop/MenuImage.java b/src/main/java/in/koreatech/koin/domain/shop/model/MenuImage.java similarity index 96% rename from src/main/java/in/koreatech/koin/domain/shop/MenuImage.java rename to src/main/java/in/koreatech/koin/domain/shop/model/MenuImage.java index d99a29cd6..5b7af596a 100644 --- a/src/main/java/in/koreatech/koin/domain/shop/MenuImage.java +++ b/src/main/java/in/koreatech/koin/domain/shop/model/MenuImage.java @@ -1,4 +1,4 @@ -package in.koreatech.koin.domain.shop; +package in.koreatech.koin.domain.shop.model; import jakarta.persistence.Column; import jakarta.persistence.Entity; diff --git a/src/main/java/in/koreatech/koin/domain/shop/MenuOption.java b/src/main/java/in/koreatech/koin/domain/shop/model/MenuOption.java similarity index 93% rename from src/main/java/in/koreatech/koin/domain/shop/MenuOption.java rename to src/main/java/in/koreatech/koin/domain/shop/model/MenuOption.java index ed4be6d7a..f7f61000a 100644 --- a/src/main/java/in/koreatech/koin/domain/shop/MenuOption.java +++ b/src/main/java/in/koreatech/koin/domain/shop/model/MenuOption.java @@ -1,6 +1,6 @@ -package in.koreatech.koin.domain.shop; +package in.koreatech.koin.domain.shop.model; -import in.koreatech.koin.domain.BaseEntity; +import in.koreatech.koin.global.common.BaseEntity; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; diff --git a/src/main/java/in/koreatech/koin/repository/shop/MenuRepository.java b/src/main/java/in/koreatech/koin/domain/shop/repository/MenuRepository.java similarity index 69% rename from src/main/java/in/koreatech/koin/repository/shop/MenuRepository.java rename to src/main/java/in/koreatech/koin/domain/shop/repository/MenuRepository.java index 62d89cad2..d06c52dbb 100644 --- a/src/main/java/in/koreatech/koin/repository/shop/MenuRepository.java +++ b/src/main/java/in/koreatech/koin/domain/shop/repository/MenuRepository.java @@ -1,10 +1,10 @@ -package in.koreatech.koin.repository.shop; +package in.koreatech.koin.domain.shop.repository; import java.util.Optional; import org.springframework.data.repository.Repository; -import in.koreatech.koin.domain.shop.Menu; +import in.koreatech.koin.domain.shop.model.Menu; public interface MenuRepository extends Repository { diff --git a/src/main/java/in/koreatech/koin/service/shop/ShopService.java b/src/main/java/in/koreatech/koin/domain/shop/service/ShopService.java similarity index 76% rename from src/main/java/in/koreatech/koin/service/shop/ShopService.java rename to src/main/java/in/koreatech/koin/domain/shop/service/ShopService.java index 55f17d9b8..9d2ee55b2 100644 --- a/src/main/java/in/koreatech/koin/service/shop/ShopService.java +++ b/src/main/java/in/koreatech/koin/domain/shop/service/ShopService.java @@ -1,15 +1,15 @@ -package in.koreatech.koin.service.shop; +package in.koreatech.koin.domain.shop.service; import java.util.List; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import in.koreatech.koin.domain.shop.Menu; -import in.koreatech.koin.domain.shop.MenuCategory; -import in.koreatech.koin.domain.shop.MenuCategoryMap; -import in.koreatech.koin.dto.shop.ShopMenuResponse; -import in.koreatech.koin.repository.shop.MenuRepository; +import in.koreatech.koin.domain.shop.model.Menu; +import in.koreatech.koin.domain.shop.model.MenuCategory; +import in.koreatech.koin.domain.shop.model.MenuCategoryMap; +import in.koreatech.koin.domain.shop.dto.ShopMenuResponse; +import in.koreatech.koin.domain.shop.repository.MenuRepository; import lombok.RequiredArgsConstructor; @Service @@ -18,7 +18,7 @@ public class ShopService { private final MenuRepository menuRepository; - + public ShopMenuResponse findMenu(Long menuId) { Menu menu = menuRepository.findById(menuId) .orElseThrow(() -> new IllegalArgumentException("존재하지 않는 메뉴입니다.")); diff --git a/src/main/java/in/koreatech/koin/controller/TrackController.java b/src/main/java/in/koreatech/koin/domain/track/controller/TrackController.java similarity index 78% rename from src/main/java/in/koreatech/koin/controller/TrackController.java rename to src/main/java/in/koreatech/koin/domain/track/controller/TrackController.java index 236028202..f37e001ab 100644 --- a/src/main/java/in/koreatech/koin/controller/TrackController.java +++ b/src/main/java/in/koreatech/koin/domain/track/controller/TrackController.java @@ -1,15 +1,17 @@ -package in.koreatech.koin.controller; +package in.koreatech.koin.domain.track.controller; -import in.koreatech.koin.dto.TrackResponse; -import in.koreatech.koin.dto.TrackSingleResponse; -import in.koreatech.koin.service.TrackService; import java.util.List; -import lombok.RequiredArgsConstructor; + import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; +import in.koreatech.koin.domain.track.dto.TrackResponse; +import in.koreatech.koin.domain.track.dto.TrackSingleResponse; +import in.koreatech.koin.domain.track.service.TrackService; +import lombok.RequiredArgsConstructor; + @RestController @RequiredArgsConstructor public class TrackController { diff --git a/src/main/java/in/koreatech/koin/dto/TrackResponse.java b/src/main/java/in/koreatech/koin/domain/track/dto/TrackResponse.java similarity index 53% rename from src/main/java/in/koreatech/koin/dto/TrackResponse.java rename to src/main/java/in/koreatech/koin/domain/track/dto/TrackResponse.java index 97c9db700..1058aaffe 100644 --- a/src/main/java/in/koreatech/koin/dto/TrackResponse.java +++ b/src/main/java/in/koreatech/koin/domain/track/dto/TrackResponse.java @@ -1,27 +1,22 @@ -package in.koreatech.koin.dto; +package in.koreatech.koin.domain.track.dto; + +import java.time.LocalDateTime; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; -import in.koreatech.koin.domain.Track; -import java.time.LocalDateTime; -import lombok.AllArgsConstructor; -import lombok.Getter; -@Getter -@AllArgsConstructor(access = lombok.AccessLevel.PRIVATE) -@JsonNaming(value = PropertyNamingStrategies.SnakeCaseStrategy.class) -public class TrackResponse { - - private Long id; - private String name; - private Integer headcount; - private Boolean isDeleted; +import in.koreatech.koin.domain.track.model.Track; - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createdAt; - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updatedAt; +@JsonNaming(value = PropertyNamingStrategies.SnakeCaseStrategy.class) +public record TrackResponse( + Long id, + String name, + Integer headcount, + Boolean isDeleted, + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime createdAt, + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime updatedAt +) { public static TrackResponse from(Track track) { return new TrackResponse( diff --git a/src/main/java/in/koreatech/koin/dto/TrackSingleResponse.java b/src/main/java/in/koreatech/koin/domain/track/dto/TrackSingleResponse.java similarity index 53% rename from src/main/java/in/koreatech/koin/dto/TrackSingleResponse.java rename to src/main/java/in/koreatech/koin/domain/track/dto/TrackSingleResponse.java index 555886df0..f7d4aa94b 100644 --- a/src/main/java/in/koreatech/koin/dto/TrackSingleResponse.java +++ b/src/main/java/in/koreatech/koin/domain/track/dto/TrackSingleResponse.java @@ -1,30 +1,22 @@ -package in.koreatech.koin.dto; +package in.koreatech.koin.domain.track.dto; + +import java.time.LocalDateTime; +import java.util.List; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; -import in.koreatech.koin.domain.Member; -import in.koreatech.koin.domain.TechStack; -import in.koreatech.koin.domain.Track; -import java.time.LocalDateTime; -import java.util.List; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -@Getter -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class TrackSingleResponse { +import in.koreatech.koin.domain.track.model.Member; +import in.koreatech.koin.domain.track.model.TechStack; +import in.koreatech.koin.domain.track.model.Track; - @JsonProperty("TrackName") - private String trackName; - - @JsonProperty("TechStacks") - private List innerTechStackResponses; - - @JsonProperty("Members") - private List innerMemberResponses; +public record TrackSingleResponse( + @JsonProperty("TrackName") String trackName, + @JsonProperty("TechStacks") List innerTechStackResponses, + @JsonProperty("Members") List innerMemberResponses +) { public static TrackSingleResponse of(Track track, List members, List techStacks) { return new TrackSingleResponse( @@ -38,21 +30,17 @@ public static TrackSingleResponse of(Track track, List members, List { Member save(Member member); diff --git a/src/main/java/in/koreatech/koin/repository/TechStackRepository.java b/src/main/java/in/koreatech/koin/domain/track/repository/TechStackRepository.java similarity index 69% rename from src/main/java/in/koreatech/koin/repository/TechStackRepository.java rename to src/main/java/in/koreatech/koin/domain/track/repository/TechStackRepository.java index 2839ba3c4..939175a1b 100644 --- a/src/main/java/in/koreatech/koin/repository/TechStackRepository.java +++ b/src/main/java/in/koreatech/koin/domain/track/repository/TechStackRepository.java @@ -1,9 +1,11 @@ -package in.koreatech.koin.repository; +package in.koreatech.koin.domain.track.repository; -import in.koreatech.koin.domain.TechStack; import java.util.List; + import org.springframework.data.repository.Repository; +import in.koreatech.koin.domain.track.model.TechStack; + public interface TechStackRepository extends Repository { TechStack save(TechStack techStack); diff --git a/src/main/java/in/koreatech/koin/repository/TrackRepository.java b/src/main/java/in/koreatech/koin/domain/track/repository/TrackRepository.java similarity index 72% rename from src/main/java/in/koreatech/koin/repository/TrackRepository.java rename to src/main/java/in/koreatech/koin/domain/track/repository/TrackRepository.java index 16207449e..6c44c1bf7 100644 --- a/src/main/java/in/koreatech/koin/repository/TrackRepository.java +++ b/src/main/java/in/koreatech/koin/domain/track/repository/TrackRepository.java @@ -1,10 +1,12 @@ -package in.koreatech.koin.repository; +package in.koreatech.koin.domain.track.repository; -import in.koreatech.koin.domain.Track; import java.util.List; import java.util.Optional; + import org.springframework.data.repository.Repository; +import in.koreatech.koin.domain.track.model.Track; + public interface TrackRepository extends Repository { Track save(Track track); diff --git a/src/main/java/in/koreatech/koin/service/TrackService.java b/src/main/java/in/koreatech/koin/domain/track/service/TrackService.java similarity index 63% rename from src/main/java/in/koreatech/koin/service/TrackService.java rename to src/main/java/in/koreatech/koin/domain/track/service/TrackService.java index b08cdcfe6..2c447f9d5 100644 --- a/src/main/java/in/koreatech/koin/service/TrackService.java +++ b/src/main/java/in/koreatech/koin/domain/track/service/TrackService.java @@ -1,17 +1,19 @@ -package in.koreatech.koin.service; - -import in.koreatech.koin.domain.Member; -import in.koreatech.koin.domain.TechStack; -import in.koreatech.koin.domain.Track; -import in.koreatech.koin.dto.TrackResponse; -import in.koreatech.koin.dto.TrackSingleResponse; -import in.koreatech.koin.repository.MemberRepository; -import in.koreatech.koin.repository.TechStackRepository; -import in.koreatech.koin.repository.TrackRepository; +package in.koreatech.koin.domain.track.service; + import java.util.List; -import lombok.RequiredArgsConstructor; + import org.springframework.stereotype.Service; +import in.koreatech.koin.domain.track.model.Member; +import in.koreatech.koin.domain.track.model.TechStack; +import in.koreatech.koin.domain.track.model.Track; +import in.koreatech.koin.domain.track.dto.TrackResponse; +import in.koreatech.koin.domain.track.dto.TrackSingleResponse; +import in.koreatech.koin.domain.track.repository.MemberRepository; +import in.koreatech.koin.domain.track.repository.TechStackRepository; +import in.koreatech.koin.domain.track.repository.TrackRepository; +import lombok.RequiredArgsConstructor; + @Service @RequiredArgsConstructor public class TrackService { diff --git a/src/main/java/in/koreatech/koin/controller/UserController.java b/src/main/java/in/koreatech/koin/domain/user/controller/UserController.java similarity index 76% rename from src/main/java/in/koreatech/koin/controller/UserController.java rename to src/main/java/in/koreatech/koin/domain/user/controller/UserController.java index 4fc251d22..d8cd202af 100644 --- a/src/main/java/in/koreatech/koin/controller/UserController.java +++ b/src/main/java/in/koreatech/koin/domain/user/controller/UserController.java @@ -1,16 +1,18 @@ -package in.koreatech.koin.controller; +package in.koreatech.koin.domain.user.controller; -import in.koreatech.koin.dto.UserLoginRequest; -import in.koreatech.koin.dto.UserLoginResponse; -import in.koreatech.koin.service.UserService; -import jakarta.validation.Valid; import java.net.URI; -import lombok.RequiredArgsConstructor; + import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; +import in.koreatech.koin.domain.user.dto.UserLoginRequest; +import in.koreatech.koin.domain.user.dto.UserLoginResponse; +import in.koreatech.koin.domain.user.service.UserService; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; + @RestController @RequiredArgsConstructor public class UserController { diff --git a/src/main/java/in/koreatech/koin/domain/user/dto/UserLoginRequest.java b/src/main/java/in/koreatech/koin/domain/user/dto/UserLoginRequest.java new file mode 100644 index 000000000..0182bd556 --- /dev/null +++ b/src/main/java/in/koreatech/koin/domain/user/dto/UserLoginRequest.java @@ -0,0 +1,11 @@ +package in.koreatech.koin.domain.user.dto; + +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.NotBlank; + +public record UserLoginRequest( + @Email(message = "이메일 형식을 지켜주세요.") + @NotBlank(message = "이메일을 입력해주세요.") String email, + @NotBlank(message = "비밀번호를 입력해주세요.") String password +) { +} diff --git a/src/main/java/in/koreatech/koin/domain/user/dto/UserLoginResponse.java b/src/main/java/in/koreatech/koin/domain/user/dto/UserLoginResponse.java new file mode 100644 index 000000000..bfe3f1cfd --- /dev/null +++ b/src/main/java/in/koreatech/koin/domain/user/dto/UserLoginResponse.java @@ -0,0 +1,13 @@ +package in.koreatech.koin.domain.user.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public record UserLoginResponse( + @JsonProperty("token") String accessToken, + @JsonProperty("refresh_token") String refreshToken, + @JsonProperty("user_type") String userType) { + + public static UserLoginResponse of(String token, String refreshToken, String userType) { + return new UserLoginResponse(token, refreshToken, userType); + } +} diff --git a/src/main/java/in/koreatech/koin/domain/user/Student.java b/src/main/java/in/koreatech/koin/domain/user/model/Student.java similarity index 95% rename from src/main/java/in/koreatech/koin/domain/user/Student.java rename to src/main/java/in/koreatech/koin/domain/user/model/Student.java index a64029c93..eb0900893 100644 --- a/src/main/java/in/koreatech/koin/domain/user/Student.java +++ b/src/main/java/in/koreatech/koin/domain/user/model/Student.java @@ -1,4 +1,4 @@ -package in.koreatech.koin.domain.user; +package in.koreatech.koin.domain.user.model; import jakarta.persistence.Column; import jakarta.persistence.Entity; diff --git a/src/main/java/in/koreatech/koin/domain/user/User.java b/src/main/java/in/koreatech/koin/domain/user/model/User.java similarity index 89% rename from src/main/java/in/koreatech/koin/domain/user/User.java rename to src/main/java/in/koreatech/koin/domain/user/model/User.java index d7ce56cdf..5f3acc685 100644 --- a/src/main/java/in/koreatech/koin/domain/user/User.java +++ b/src/main/java/in/koreatech/koin/domain/user/model/User.java @@ -1,6 +1,8 @@ -package in.koreatech.koin.domain.user; +package in.koreatech.koin.domain.user.model; -import in.koreatech.koin.domain.BaseEntity; +import java.time.LocalDateTime; + +import in.koreatech.koin.global.common.BaseEntity; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; @@ -12,7 +14,6 @@ import jakarta.persistence.Table; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; -import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -92,10 +93,10 @@ public class User extends BaseEntity { @Builder public User(String password, String nickname, String name, String phoneNumber, UserType userType, - String email, - UserGender gender, Boolean isAuthed, LocalDateTime lastLoggedAt, String profileImageUrl, - Boolean isDeleted, - String authToken, String authExpiredAt, String resetToken, String resetExpiredAt) { + String email, + UserGender gender, Boolean isAuthed, LocalDateTime lastLoggedAt, String profileImageUrl, + Boolean isDeleted, + String authToken, String authExpiredAt, String resetToken, String resetExpiredAt) { this.password = password; this.nickname = nickname; this.name = name; diff --git a/src/main/java/in/koreatech/koin/domain/user/UserGender.java b/src/main/java/in/koreatech/koin/domain/user/model/UserGender.java similarity index 54% rename from src/main/java/in/koreatech/koin/domain/user/UserGender.java rename to src/main/java/in/koreatech/koin/domain/user/model/UserGender.java index 52b8372f0..d8dd6d82d 100644 --- a/src/main/java/in/koreatech/koin/domain/user/UserGender.java +++ b/src/main/java/in/koreatech/koin/domain/user/model/UserGender.java @@ -1,4 +1,4 @@ -package in.koreatech.koin.domain.user; +package in.koreatech.koin.domain.user.model; public enum UserGender { MAN, diff --git a/src/main/java/in/koreatech/koin/domain/user/UserIdentity.java b/src/main/java/in/koreatech/koin/domain/user/model/UserIdentity.java similarity index 90% rename from src/main/java/in/koreatech/koin/domain/user/UserIdentity.java rename to src/main/java/in/koreatech/koin/domain/user/model/UserIdentity.java index b11f349c9..791d24627 100644 --- a/src/main/java/in/koreatech/koin/domain/user/UserIdentity.java +++ b/src/main/java/in/koreatech/koin/domain/user/model/UserIdentity.java @@ -1,4 +1,4 @@ -package in.koreatech.koin.domain.user; +package in.koreatech.koin.domain.user.model; import lombok.Getter; diff --git a/src/main/java/in/koreatech/koin/domain/user/UserToken.java b/src/main/java/in/koreatech/koin/domain/user/model/UserToken.java similarity index 94% rename from src/main/java/in/koreatech/koin/domain/user/UserToken.java rename to src/main/java/in/koreatech/koin/domain/user/model/UserToken.java index efe335cae..5502e0e5a 100644 --- a/src/main/java/in/koreatech/koin/domain/user/UserToken.java +++ b/src/main/java/in/koreatech/koin/domain/user/model/UserToken.java @@ -1,11 +1,13 @@ -package in.koreatech.koin.domain.user; +package in.koreatech.koin.domain.user.model; import java.util.concurrent.TimeUnit; -import lombok.Getter; + import org.springframework.data.annotation.Id; import org.springframework.data.redis.core.RedisHash; import org.springframework.data.redis.core.TimeToLive; +import lombok.Getter; + @Getter @RedisHash("refreshToken") public class UserToken { diff --git a/src/main/java/in/koreatech/koin/domain/user/UserType.java b/src/main/java/in/koreatech/koin/domain/user/model/UserType.java similarity index 87% rename from src/main/java/in/koreatech/koin/domain/user/UserType.java rename to src/main/java/in/koreatech/koin/domain/user/model/UserType.java index 9eb5abe62..01bc02fba 100644 --- a/src/main/java/in/koreatech/koin/domain/user/UserType.java +++ b/src/main/java/in/koreatech/koin/domain/user/model/UserType.java @@ -1,4 +1,4 @@ -package in.koreatech.koin.domain.user; +package in.koreatech.koin.domain.user.model; import lombok.Getter; diff --git a/src/main/java/in/koreatech/koin/repository/UserRepository.java b/src/main/java/in/koreatech/koin/domain/user/repository/UserRepository.java similarity index 72% rename from src/main/java/in/koreatech/koin/repository/UserRepository.java rename to src/main/java/in/koreatech/koin/domain/user/repository/UserRepository.java index d38ad52af..3ecf5950f 100644 --- a/src/main/java/in/koreatech/koin/repository/UserRepository.java +++ b/src/main/java/in/koreatech/koin/domain/user/repository/UserRepository.java @@ -1,9 +1,11 @@ -package in.koreatech.koin.repository; +package in.koreatech.koin.domain.user.repository; -import in.koreatech.koin.domain.user.User; import java.util.Optional; + import org.springframework.data.repository.Repository; +import in.koreatech.koin.domain.user.model.User; + public interface UserRepository extends Repository { User save(User user); diff --git a/src/main/java/in/koreatech/koin/repository/UserTokenRepository.java b/src/main/java/in/koreatech/koin/domain/user/repository/UserTokenRepository.java similarity index 70% rename from src/main/java/in/koreatech/koin/repository/UserTokenRepository.java rename to src/main/java/in/koreatech/koin/domain/user/repository/UserTokenRepository.java index dff4366e9..562674d81 100644 --- a/src/main/java/in/koreatech/koin/repository/UserTokenRepository.java +++ b/src/main/java/in/koreatech/koin/domain/user/repository/UserTokenRepository.java @@ -1,9 +1,11 @@ -package in.koreatech.koin.repository; +package in.koreatech.koin.domain.user.repository; -import in.koreatech.koin.domain.user.UserToken; import java.util.Optional; + import org.springframework.data.repository.Repository; +import in.koreatech.koin.domain.user.model.UserToken; + public interface UserTokenRepository extends Repository { UserToken save(UserToken userToken); diff --git a/src/main/java/in/koreatech/koin/service/UserService.java b/src/main/java/in/koreatech/koin/domain/user/service/UserService.java similarity index 67% rename from src/main/java/in/koreatech/koin/service/UserService.java rename to src/main/java/in/koreatech/koin/domain/user/service/UserService.java index 1244793ad..bbe2053d2 100644 --- a/src/main/java/in/koreatech/koin/service/UserService.java +++ b/src/main/java/in/koreatech/koin/domain/user/service/UserService.java @@ -1,18 +1,20 @@ -package in.koreatech.koin.service; - -import in.koreatech.koin.auth.JwtProvider; -import in.koreatech.koin.domain.user.User; -import in.koreatech.koin.domain.user.UserToken; -import in.koreatech.koin.dto.UserLoginRequest; -import in.koreatech.koin.dto.UserLoginResponse; -import in.koreatech.koin.repository.UserRepository; -import in.koreatech.koin.repository.UserTokenRepository; +package in.koreatech.koin.domain.user.service; + import java.time.LocalDateTime; import java.util.UUID; -import lombok.RequiredArgsConstructor; + import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import in.koreatech.koin.domain.auth.JwtProvider; +import in.koreatech.koin.domain.user.model.User; +import in.koreatech.koin.domain.user.model.UserToken; +import in.koreatech.koin.domain.user.dto.UserLoginRequest; +import in.koreatech.koin.domain.user.dto.UserLoginResponse; +import in.koreatech.koin.domain.user.repository.UserRepository; +import in.koreatech.koin.domain.user.repository.UserTokenRepository; +import lombok.RequiredArgsConstructor; + @Service @RequiredArgsConstructor @Transactional(readOnly = true) @@ -24,10 +26,10 @@ public class UserService { @Transactional public UserLoginResponse login(UserLoginRequest request) { - User user = userRepository.findByEmail(request.getEmail()) + User user = userRepository.findByEmail(request.email()) .orElseThrow(() -> new IllegalArgumentException("잘못된 로그인 정보입니다.")); - if (!user.isSamePassword(request.getPassword())) { + if (!user.isSamePassword(request.password())) { throw new IllegalArgumentException("잘못된 로그인 정보입니다."); } diff --git a/src/main/java/in/koreatech/koin/dto/UserLoginRequest.java b/src/main/java/in/koreatech/koin/dto/UserLoginRequest.java deleted file mode 100644 index 25ea66541..000000000 --- a/src/main/java/in/koreatech/koin/dto/UserLoginRequest.java +++ /dev/null @@ -1,16 +0,0 @@ -package in.koreatech.koin.dto; - -import jakarta.validation.constraints.Email; -import jakarta.validation.constraints.NotBlank; -import lombok.Getter; - -@Getter -public class UserLoginRequest { - - @Email(message = "이메일 형식을 지켜주세요.") - @NotBlank(message = "이메일을 입력해주세요.") - private String email; - - @NotBlank(message = "비밀번호를 입력해주세요.") - private String password; -} diff --git a/src/main/java/in/koreatech/koin/dto/UserLoginResponse.java b/src/main/java/in/koreatech/koin/dto/UserLoginResponse.java deleted file mode 100644 index d8e74d5c8..000000000 --- a/src/main/java/in/koreatech/koin/dto/UserLoginResponse.java +++ /dev/null @@ -1,23 +0,0 @@ -package in.koreatech.koin.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor(access = lombok.AccessLevel.PRIVATE) -public class UserLoginResponse { - - @JsonProperty("token") - private String accessToken; - - @JsonProperty("refresh_token") - private String refreshToken; - - @JsonProperty("user_type") - private String userType; - - public static UserLoginResponse of(String token, String refreshToken, String userType) { - return new UserLoginResponse(token, refreshToken, userType); - } -} diff --git a/src/main/java/in/koreatech/koin/domain/BaseEntity.java b/src/main/java/in/koreatech/koin/global/common/BaseEntity.java similarity index 95% rename from src/main/java/in/koreatech/koin/domain/BaseEntity.java rename to src/main/java/in/koreatech/koin/global/common/BaseEntity.java index 37c5f2943..814b1ac31 100644 --- a/src/main/java/in/koreatech/koin/domain/BaseEntity.java +++ b/src/main/java/in/koreatech/koin/global/common/BaseEntity.java @@ -1,14 +1,16 @@ -package in.koreatech.koin.domain; +package in.koreatech.koin.global.common; + +import java.time.LocalDateTime; + +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; import jakarta.persistence.Column; import jakarta.persistence.EntityListeners; import jakarta.persistence.MappedSuperclass; import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; import lombok.Getter; -import org.springframework.data.annotation.CreatedDate; -import org.springframework.data.annotation.LastModifiedDate; -import org.springframework.data.jpa.domain.support.AuditingEntityListener; @Getter @MappedSuperclass diff --git a/src/main/java/in/koreatech/koin/config/JpaConfiguration.java b/src/main/java/in/koreatech/koin/global/config/JpaConfiguration.java similarity index 83% rename from src/main/java/in/koreatech/koin/config/JpaConfiguration.java rename to src/main/java/in/koreatech/koin/global/config/JpaConfiguration.java index f1a948c05..aa1acd063 100644 --- a/src/main/java/in/koreatech/koin/config/JpaConfiguration.java +++ b/src/main/java/in/koreatech/koin/global/config/JpaConfiguration.java @@ -1,4 +1,4 @@ -package in.koreatech.koin.config; +package in.koreatech.koin.global.config; import org.springframework.context.annotation.Configuration; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; diff --git a/src/main/java/in/koreatech/koin/controller/GlobalExceptionHandler.java b/src/main/java/in/koreatech/koin/global/exception/GlobalExceptionHandler.java similarity index 90% rename from src/main/java/in/koreatech/koin/controller/GlobalExceptionHandler.java rename to src/main/java/in/koreatech/koin/global/exception/GlobalExceptionHandler.java index 9d3288582..c648df477 100644 --- a/src/main/java/in/koreatech/koin/controller/GlobalExceptionHandler.java +++ b/src/main/java/in/koreatech/koin/global/exception/GlobalExceptionHandler.java @@ -1,12 +1,12 @@ -package in.koreatech.koin.controller; +package in.koreatech.koin.global.exception; -import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Component; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; +import lombok.extern.slf4j.Slf4j; + @Slf4j @RestControllerAdvice public class GlobalExceptionHandler { diff --git a/src/test/java/in/koreatech/koin/acceptance/ShopApiTest.java b/src/test/java/in/koreatech/koin/acceptance/ShopApiTest.java index 60aff1e09..72acf9604 100644 --- a/src/test/java/in/koreatech/koin/acceptance/ShopApiTest.java +++ b/src/test/java/in/koreatech/koin/acceptance/ShopApiTest.java @@ -7,12 +7,12 @@ import org.springframework.http.HttpStatus; import in.koreatech.koin.AcceptanceTest; -import in.koreatech.koin.domain.shop.Menu; -import in.koreatech.koin.domain.shop.MenuCategory; -import in.koreatech.koin.domain.shop.MenuCategoryMap; -import in.koreatech.koin.domain.shop.MenuImage; -import in.koreatech.koin.domain.shop.MenuOption; -import in.koreatech.koin.repository.shop.MenuRepository; +import in.koreatech.koin.domain.shop.model.Menu; +import in.koreatech.koin.domain.shop.model.MenuCategory; +import in.koreatech.koin.domain.shop.model.MenuCategoryMap; +import in.koreatech.koin.domain.shop.model.MenuImage; +import in.koreatech.koin.domain.shop.model.MenuOption; +import in.koreatech.koin.domain.shop.repository.MenuRepository; import io.restassured.RestAssured; import io.restassured.response.ExtractableResponse; import io.restassured.response.Response; diff --git a/src/test/java/in/koreatech/koin/acceptance/TrackApiTest.java b/src/test/java/in/koreatech/koin/acceptance/TrackApiTest.java index afb96932f..88aa2a375 100644 --- a/src/test/java/in/koreatech/koin/acceptance/TrackApiTest.java +++ b/src/test/java/in/koreatech/koin/acceptance/TrackApiTest.java @@ -1,22 +1,24 @@ package in.koreatech.koin.acceptance; -import in.koreatech.koin.AcceptanceTest; -import in.koreatech.koin.domain.Member; -import in.koreatech.koin.domain.TechStack; -import in.koreatech.koin.domain.Track; -import in.koreatech.koin.repository.MemberRepository; -import in.koreatech.koin.repository.TechStackRepository; -import in.koreatech.koin.repository.TrackRepository; -import io.restassured.RestAssured; -import io.restassured.response.ExtractableResponse; -import io.restassured.response.Response; import java.time.format.DateTimeFormatter; + import org.assertj.core.api.SoftAssertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import in.koreatech.koin.AcceptanceTest; +import in.koreatech.koin.domain.track.model.Member; +import in.koreatech.koin.domain.track.model.TechStack; +import in.koreatech.koin.domain.track.model.Track; +import in.koreatech.koin.domain.track.repository.MemberRepository; +import in.koreatech.koin.domain.track.repository.TechStackRepository; +import in.koreatech.koin.domain.track.repository.TrackRepository; +import io.restassured.RestAssured; +import io.restassured.response.ExtractableResponse; +import io.restassured.response.Response; + class TrackApiTest extends AcceptanceTest { @Autowired diff --git a/src/test/java/in/koreatech/koin/acceptance/UserApiTest.java b/src/test/java/in/koreatech/koin/acceptance/UserApiTest.java index 06c59555d..a47f424c3 100644 --- a/src/test/java/in/koreatech/koin/acceptance/UserApiTest.java +++ b/src/test/java/in/koreatech/koin/acceptance/UserApiTest.java @@ -1,22 +1,22 @@ package in.koreatech.koin.acceptance; - import static org.assertj.core.api.SoftAssertions.assertSoftly; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; + import in.koreatech.koin.AcceptanceTest; -import in.koreatech.koin.domain.user.User; -import in.koreatech.koin.domain.user.UserToken; -import in.koreatech.koin.domain.user.UserType; -import in.koreatech.koin.repository.UserRepository; -import in.koreatech.koin.repository.UserTokenRepository; +import in.koreatech.koin.domain.user.model.User; +import in.koreatech.koin.domain.user.model.UserToken; +import in.koreatech.koin.domain.user.model.UserType; +import in.koreatech.koin.domain.user.repository.UserRepository; +import in.koreatech.koin.domain.user.repository.UserTokenRepository; import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.response.ExtractableResponse; import io.restassured.response.Response; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; class UserApiTest extends AcceptanceTest {