diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 99cef88..bb5a36d 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -40,7 +40,7 @@ jobs: uses: docker/login-action@v1 with: registry: ghcr.io - username: ${{ github.actor }} + username: ${{ secrets.GHCR_ACTOR }} password: ${{ secrets.GHCR_TOKEN }} - name: Setup Gradle diff --git a/application/app-api/src/main/java/core/startup/mealtoktok/api/mealdelivery/dto/MealDeliveryResponse.java b/application/app-api/src/main/java/core/startup/mealtoktok/api/mealdelivery/dto/MealDeliveryResponse.java index c1eb3a1..f055721 100644 --- a/application/app-api/src/main/java/core/startup/mealtoktok/api/mealdelivery/dto/MealDeliveryResponse.java +++ b/application/app-api/src/main/java/core/startup/mealtoktok/api/mealdelivery/dto/MealDeliveryResponse.java @@ -5,7 +5,7 @@ import core.startup.mealtoktok.domain.mealdelivery.DeliveryDateTime; import core.startup.mealtoktok.domain.mealdelivery.DeliveryState; import core.startup.mealtoktok.domain.mealdelivery.MealDelivery; -import core.startup.mealtoktok.domain.order.OrderedMeal; +import core.startup.mealtoktok.domain.mealdelivery.OrderedMeal; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/application/app-api/src/main/java/core/startup/mealtoktok/api/order/dto/MealOrderRequest.java b/application/app-api/src/main/java/core/startup/mealtoktok/api/order/dto/MealOrderRequest.java index 3ece9b2..000e585 100644 --- a/application/app-api/src/main/java/core/startup/mealtoktok/api/order/dto/MealOrderRequest.java +++ b/application/app-api/src/main/java/core/startup/mealtoktok/api/order/dto/MealOrderRequest.java @@ -2,10 +2,10 @@ import java.util.List; +import core.startup.mealtoktok.domain.mealdelivery.OrderedMeal; import core.startup.mealtoktok.domain.order.OrderContent; import core.startup.mealtoktok.domain.order.OrderPrice; import core.startup.mealtoktok.domain.order.OrderType; -import core.startup.mealtoktok.domain.order.OrderedMeal; public record MealOrderRequest( OrderType orderType, diff --git a/application/app-api/src/main/java/core/startup/mealtoktok/api/user/UserApi.java b/application/app-api/src/main/java/core/startup/mealtoktok/api/user/UserApi.java index d206e8b..7eb3879 100644 --- a/application/app-api/src/main/java/core/startup/mealtoktok/api/user/UserApi.java +++ b/application/app-api/src/main/java/core/startup/mealtoktok/api/user/UserApi.java @@ -16,6 +16,7 @@ import core.startup.mealtoktok.api.auth.dto.SignUpRequest.AddressInfoRequest; import core.startup.mealtoktok.api.user.dto.AvailabilityResponse; import core.startup.mealtoktok.api.user.dto.DeliveryAddressResponse; +import core.startup.mealtoktok.api.user.dto.UserResponse; import core.startup.mealtoktok.common.dto.Response; import core.startup.mealtoktok.domain.user.TargetDeliveryAddress; import core.startup.mealtoktok.domain.user.TargetUser; @@ -28,6 +29,12 @@ public class UserApi implements UserApiDocs { private final UserService userService; + @Override + @GetMapping("/{userId}") + public Response getUser(@PathVariable Long userId) { + return Response.success(UserResponse.from(userService.getUser(TargetUser.from(userId)))); + } + @GetMapping("/nickname/change-available") public Response checkNicknameDuplicate(String nickname) { boolean isDuplicated = userService.checkNicknameDuplicate(nickname); diff --git a/application/app-api/src/main/java/core/startup/mealtoktok/api/user/UserApiDocs.java b/application/app-api/src/main/java/core/startup/mealtoktok/api/user/UserApiDocs.java index 3fa8f01..2b3a77f 100644 --- a/application/app-api/src/main/java/core/startup/mealtoktok/api/user/UserApiDocs.java +++ b/application/app-api/src/main/java/core/startup/mealtoktok/api/user/UserApiDocs.java @@ -5,6 +5,7 @@ import core.startup.mealtoktok.api.auth.dto.SignUpRequest.AddressInfoRequest; import core.startup.mealtoktok.api.user.dto.AvailabilityResponse; import core.startup.mealtoktok.api.user.dto.DeliveryAddressResponse; +import core.startup.mealtoktok.api.user.dto.UserResponse; import core.startup.mealtoktok.common.dto.Response; import core.startup.mealtoktok.domain.user.TargetUser; @@ -14,6 +15,10 @@ @Tag(name = "회원 API") public interface UserApiDocs { + @Operation(summary = "유저 정보 조회") + Response getUser(Long userId); + + @Operation(summary = "닉네임 중복 확인") Response checkNicknameDuplicate(String nickname); @Operation(summary = "닉네임 변경") diff --git a/application/app-api/src/main/java/core/startup/mealtoktok/api/user/dto/UserResponse.java b/application/app-api/src/main/java/core/startup/mealtoktok/api/user/dto/UserResponse.java new file mode 100644 index 0000000..6ff4edf --- /dev/null +++ b/application/app-api/src/main/java/core/startup/mealtoktok/api/user/dto/UserResponse.java @@ -0,0 +1,30 @@ +package core.startup.mealtoktok.api.user.dto; + +import java.time.LocalDate; + +import core.startup.mealtoktok.domain.user.User; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +@JsonInclude(Include.NON_NULL) +public record UserResponse( + Long userId, + String username, + String nickname, + String email, + String phoneNumber, + String profileImageUrl, + LocalDate birth) { + + public static UserResponse from(User user) { + return new UserResponse( + user.getUserId(), + user.getUserProfile().getUsername(), + user.getUserProfile().getNickname(), + user.getUserProfile().getEmail(), + user.getUserProfile().getPhoneNumber(), + user.getUserProfile().getProfileImageUrl(), + user.getUserProfile().getBirth()); + } +} diff --git a/application/app-api/src/main/resources/application.yml b/application/app-api/src/main/resources/application.yml index 1353a5d..97ad50a 100644 --- a/application/app-api/src/main/resources/application.yml +++ b/application/app-api/src/main/resources/application.yml @@ -30,7 +30,7 @@ spring: on-profile: local jwt: access-token: - expiration: 2592000 #3일 + expiration: 25920000 --- spring: @@ -39,4 +39,4 @@ spring: on-profile: dev jwt: access-token: - expiration: 2592000 #3일 + expiration: 25920000 diff --git a/domain/src/main/java/core/startup/mealtoktok/domain/mealdelivery/MealDelivery.java b/domain/src/main/java/core/startup/mealtoktok/domain/mealdelivery/MealDelivery.java index 6ced56a..6599514 100644 --- a/domain/src/main/java/core/startup/mealtoktok/domain/mealdelivery/MealDelivery.java +++ b/domain/src/main/java/core/startup/mealtoktok/domain/mealdelivery/MealDelivery.java @@ -7,16 +7,13 @@ import lombok.Builder; import lombok.Getter; -import core.startup.mealtoktok.domain.order.OrderedMeal; -import core.startup.mealtoktok.domain.order.TargetOrder; - @Getter @AllArgsConstructor(access = AccessLevel.PRIVATE) @Builder public class MealDelivery { private Long mealDeliveryId; - private TargetOrder targetOrder; + private Long orderId; private OrderedMeal orderedMeal; private DeliveryState deliveryState; private DeliveryDateTime deliveryDateTime; @@ -32,9 +29,9 @@ public void completeDelivery(LocalDateTime completeDateTime) { this.deliveryState = DeliveryState.DELIVERED; } - public static MealDelivery create(TargetOrder targetOrder, OrderedMeal orderedMeal) { + public static MealDelivery create(Long orderId, OrderedMeal orderedMeal) { return new MealDelivery( - null, targetOrder, orderedMeal, DeliveryState.PENDING, DeliveryDateTime.init()); + null, orderId, orderedMeal, DeliveryState.PENDING, DeliveryDateTime.init()); } public boolean hasFullDiningOption() { diff --git a/domain/src/main/java/core/startup/mealtoktok/domain/mealdelivery/MealDeliveryReserver.java b/domain/src/main/java/core/startup/mealtoktok/domain/mealdelivery/MealDeliveryReserver.java index 7108a4a..b130b14 100644 --- a/domain/src/main/java/core/startup/mealtoktok/domain/mealdelivery/MealDeliveryReserver.java +++ b/domain/src/main/java/core/startup/mealtoktok/domain/mealdelivery/MealDeliveryReserver.java @@ -6,20 +6,13 @@ import lombok.RequiredArgsConstructor; -import core.startup.mealtoktok.domain.order.OrderedMeal; -import core.startup.mealtoktok.domain.order.TargetOrder; - @Component @RequiredArgsConstructor public class MealDeliveryReserver { private final MealDeliveryRepository mealDeliveryRepository; - public List reserve(TargetOrder targetOrder, List orderedMeals) { - List mealDeliveries = - orderedMeals.parallelStream() - .map(orderedMeal -> MealDelivery.create(targetOrder, orderedMeal)) - .toList(); + public List reserve(List mealDeliveries) { return mealDeliveryRepository.saveAll(mealDeliveries); } } diff --git a/domain/src/main/java/core/startup/mealtoktok/domain/order/OrderedMeal.java b/domain/src/main/java/core/startup/mealtoktok/domain/mealdelivery/OrderedMeal.java similarity index 77% rename from domain/src/main/java/core/startup/mealtoktok/domain/order/OrderedMeal.java rename to domain/src/main/java/core/startup/mealtoktok/domain/mealdelivery/OrderedMeal.java index 0439bf0..6aaab63 100644 --- a/domain/src/main/java/core/startup/mealtoktok/domain/order/OrderedMeal.java +++ b/domain/src/main/java/core/startup/mealtoktok/domain/mealdelivery/OrderedMeal.java @@ -1,7 +1,10 @@ -package core.startup.mealtoktok.domain.order; +package core.startup.mealtoktok.domain.mealdelivery; import java.time.LocalDate; +import core.startup.mealtoktok.domain.order.ReservedSchedule; +import core.startup.mealtoktok.domain.order.ReservedTime; + public record OrderedMeal( Long mealId, ReservedSchedule reservedSchedule, diff --git a/domain/src/main/java/core/startup/mealtoktok/domain/order/OrderContent.java b/domain/src/main/java/core/startup/mealtoktok/domain/order/OrderContent.java index dbcd14d..9a00a44 100644 --- a/domain/src/main/java/core/startup/mealtoktok/domain/order/OrderContent.java +++ b/domain/src/main/java/core/startup/mealtoktok/domain/order/OrderContent.java @@ -2,8 +2,18 @@ import java.util.List; +import core.startup.mealtoktok.domain.mealdelivery.MealDelivery; +import core.startup.mealtoktok.domain.mealdelivery.OrderedMeal; + public record OrderContent( OrderType orderType, List orderedMeals, String specialInstruction, - OrderPrice orderPrice) {} + OrderPrice orderPrice) { + + public List toMealDeliveries(TargetOrder targetOrder) { + return orderedMeals.parallelStream() + .map(orderedMeal -> MealDelivery.create(targetOrder.orderId(), orderedMeal)) + .toList(); + } +} diff --git a/domain/src/main/java/core/startup/mealtoktok/domain/order/OrderService.java b/domain/src/main/java/core/startup/mealtoktok/domain/order/OrderService.java index e622075..41b7939 100644 --- a/domain/src/main/java/core/startup/mealtoktok/domain/order/OrderService.java +++ b/domain/src/main/java/core/startup/mealtoktok/domain/order/OrderService.java @@ -28,7 +28,7 @@ public TargetOrder orderMeals(Orderer orderer, OrderContent orderContent) { orderValidator.validate(orderContent); TargetOrder targetOrder = orderAppender.append(orderer, orderContent); List mealDeliveries = - mealDeliveryReserver.reserve(targetOrder, orderContent.orderedMeals()); + mealDeliveryReserver.reserve(orderContent.toMealDeliveries(targetOrder)); fullDiningManager.reserve(mealDeliveries); return targetOrder; } diff --git a/domain/src/main/java/core/startup/mealtoktok/domain/user/UserService.java b/domain/src/main/java/core/startup/mealtoktok/domain/user/UserService.java index 1311bee..ee188bf 100644 --- a/domain/src/main/java/core/startup/mealtoktok/domain/user/UserService.java +++ b/domain/src/main/java/core/startup/mealtoktok/domain/user/UserService.java @@ -15,6 +15,10 @@ public class UserService { private final userRemover userRemover; private final UserValidator userValidator; + public User getUser(TargetUser targetUser) { + return userReader.read(targetUser); + } + public TargetUser addDeliveryAddress( TargetUser targetUser, AddressWithCoordinate addressWithCoordinate) { User user = userReader.read(targetUser); diff --git a/infra/src/main/java/core/startup/mealtoktok/infra/mealdelivery/entity/MealDeliveryEntity.java b/infra/src/main/java/core/startup/mealtoktok/infra/mealdelivery/entity/MealDeliveryEntity.java index a849616..ca0870f 100644 --- a/infra/src/main/java/core/startup/mealtoktok/infra/mealdelivery/entity/MealDeliveryEntity.java +++ b/infra/src/main/java/core/startup/mealtoktok/infra/mealdelivery/entity/MealDeliveryEntity.java @@ -19,7 +19,7 @@ import core.startup.mealtoktok.domain.mealdelivery.DeliveryDateTime; import core.startup.mealtoktok.domain.mealdelivery.DeliveryState; import core.startup.mealtoktok.domain.mealdelivery.MealDelivery; -import core.startup.mealtoktok.domain.order.OrderedMeal; +import core.startup.mealtoktok.domain.mealdelivery.OrderedMeal; import core.startup.mealtoktok.domain.order.ReservedTime; import core.startup.mealtoktok.domain.order.TargetOrder; diff --git a/infra/src/main/resources/application-infra.yml b/infra/src/main/resources/application-infra.yml index 37868b8..0b97367 100644 --- a/infra/src/main/resources/application-infra.yml +++ b/infra/src/main/resources/application-infra.yml @@ -15,7 +15,7 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver jpa: hibernate: - ddl-auto: update + ddl-auto: create properties: hibernate: show-sql: true @@ -44,7 +44,7 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver jpa: hibernate: - ddl-auto: create-drop + ddl-auto: update properties: hibernate: show-sql: true