diff --git a/src/main/java/umc/meme/shop/domain/artist/controller/ArtistController.java b/src/main/java/umc/meme/shop/domain/artist/controller/ArtistController.java index 3185ce0..7d953d5 100644 --- a/src/main/java/umc/meme/shop/domain/artist/controller/ArtistController.java +++ b/src/main/java/umc/meme/shop/domain/artist/controller/ArtistController.java @@ -28,6 +28,7 @@ public ApiResponse getArtistProfile(@PathVariable Long artistId){ } //temp method for Artist create + @Operation(summary = "temp 아티스트 생성(프론트랑 상관X)") @PostMapping("/artist") public ApiResponse createArtist(@RequestBody ArtistProfileDto profileDto){ artistService.createArtist(profileDto); diff --git a/src/main/java/umc/meme/shop/domain/common/BaseEntity.java b/src/main/java/umc/meme/shop/domain/common/BaseEntity.java new file mode 100644 index 0000000..40704aa --- /dev/null +++ b/src/main/java/umc/meme/shop/domain/common/BaseEntity.java @@ -0,0 +1,23 @@ +package umc.meme.shop.domain.common; + +import jakarta.persistence.EntityListeners; +import jakarta.persistence.MappedSuperclass; +import lombok.Getter; +import lombok.experimental.SuperBuilder; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import java.time.LocalDateTime; + +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +@Getter +public abstract class BaseEntity { + + @CreatedDate + private LocalDateTime createdAt; + + @LastModifiedDate + private LocalDateTime updatedAt; +} diff --git a/src/main/java/umc/meme/shop/domain/favorite/entity/FavoriteArtist.java b/src/main/java/umc/meme/shop/domain/favorite/entity/FavoriteArtist.java index 6f0a3f2..51adc43 100644 --- a/src/main/java/umc/meme/shop/domain/favorite/entity/FavoriteArtist.java +++ b/src/main/java/umc/meme/shop/domain/favorite/entity/FavoriteArtist.java @@ -5,6 +5,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import umc.meme.shop.domain.common.BaseEntity; import umc.meme.shop.domain.model.entity.Model; @Builder @@ -12,7 +13,7 @@ @AllArgsConstructor @NoArgsConstructor @Entity -public class FavoriteArtist { +public class FavoriteArtist extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/umc/meme/shop/domain/favorite/entity/FavoritePortfolio.java b/src/main/java/umc/meme/shop/domain/favorite/entity/FavoritePortfolio.java index c4e930e..b80358b 100644 --- a/src/main/java/umc/meme/shop/domain/favorite/entity/FavoritePortfolio.java +++ b/src/main/java/umc/meme/shop/domain/favorite/entity/FavoritePortfolio.java @@ -1,10 +1,12 @@ package umc.meme.shop.domain.favorite.entity; +import com.fasterxml.jackson.databind.ser.Serializers; import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import umc.meme.shop.domain.common.BaseEntity; import umc.meme.shop.domain.portfolio.entity.Portfolio; import umc.meme.shop.domain.user.User; @@ -13,7 +15,7 @@ @AllArgsConstructor @NoArgsConstructor @Entity -public class FavoritePortfolio { +public class FavoritePortfolio extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/umc/meme/shop/domain/model/controller/ModelController.java b/src/main/java/umc/meme/shop/domain/model/controller/ModelController.java index be56ad2..9ac159a 100644 --- a/src/main/java/umc/meme/shop/domain/model/controller/ModelController.java +++ b/src/main/java/umc/meme/shop/domain/model/controller/ModelController.java @@ -20,6 +20,7 @@ public class ModelController { private final ModelService modelService; /**temp model create method**/ + @Operation(summary = "temp 모델 생성(프론트랑 상관X)") @PostMapping("/model") public ApiResponse createModel(@RequestBody ModelProfileDto profileDto){ modelService.createModel(profileDto); diff --git a/src/main/java/umc/meme/shop/domain/mypage/entity/Inquiry.java b/src/main/java/umc/meme/shop/domain/mypage/entity/Inquiry.java index 9c8402b..acc575c 100644 --- a/src/main/java/umc/meme/shop/domain/mypage/entity/Inquiry.java +++ b/src/main/java/umc/meme/shop/domain/mypage/entity/Inquiry.java @@ -5,6 +5,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import umc.meme.shop.domain.common.BaseEntity; import umc.meme.shop.domain.mypage.dto.request.MypageInquiryDto; import umc.meme.shop.domain.user.User; import umc.meme.shop.domain.user.UserRepository; @@ -14,7 +15,7 @@ @AllArgsConstructor @NoArgsConstructor @Entity -public class Inquiry { +public class Inquiry extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "inquiry_id") diff --git a/src/main/java/umc/meme/shop/domain/portfolio/entity/Portfolio.java b/src/main/java/umc/meme/shop/domain/portfolio/entity/Portfolio.java index 5c3d765..5d19fa7 100644 --- a/src/main/java/umc/meme/shop/domain/portfolio/entity/Portfolio.java +++ b/src/main/java/umc/meme/shop/domain/portfolio/entity/Portfolio.java @@ -6,6 +6,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import umc.meme.shop.domain.artist.entity.Artist; +import umc.meme.shop.domain.common.BaseEntity; import umc.meme.shop.domain.portfolio.dto.request.UpdatePortfolioDto; import umc.meme.shop.global.enums.Category; import umc.meme.shop.domain.review.entity.Review; @@ -18,7 +19,7 @@ @AllArgsConstructor @NoArgsConstructor @Entity -public class Portfolio { +public class Portfolio extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "portfolio_id") diff --git a/src/main/java/umc/meme/shop/domain/portfolio/entity/PortfolioImg.java b/src/main/java/umc/meme/shop/domain/portfolio/entity/PortfolioImg.java index ee7c74f..e19b90d 100644 --- a/src/main/java/umc/meme/shop/domain/portfolio/entity/PortfolioImg.java +++ b/src/main/java/umc/meme/shop/domain/portfolio/entity/PortfolioImg.java @@ -2,15 +2,16 @@ import jakarta.persistence.*; import lombok.AllArgsConstructor; -import lombok.Data; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; +import umc.meme.shop.domain.common.BaseEntity; -@Data @AllArgsConstructor @NoArgsConstructor @Entity -public class PortfolioImg { +@Getter @Setter +public class PortfolioImg extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long portfolioImgId; diff --git a/src/main/java/umc/meme/shop/domain/reservation/entity/Reservation.java b/src/main/java/umc/meme/shop/domain/reservation/entity/Reservation.java index 0dd8ace..7ade6d1 100644 --- a/src/main/java/umc/meme/shop/domain/reservation/entity/Reservation.java +++ b/src/main/java/umc/meme/shop/domain/reservation/entity/Reservation.java @@ -5,6 +5,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import umc.meme.shop.domain.common.BaseEntity; import umc.meme.shop.domain.portfolio.entity.Portfolio; import umc.meme.shop.global.enums.Status; import umc.meme.shop.domain.user.User; @@ -19,7 +20,7 @@ @AllArgsConstructor @NoArgsConstructor @Entity -public class Reservation { +public class Reservation extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/umc/meme/shop/domain/reservation/repository/ReservationRepository.java b/src/main/java/umc/meme/shop/domain/reservation/repository/ReservationRepository.java index 6ff22f0..627fa9a 100644 --- a/src/main/java/umc/meme/shop/domain/reservation/repository/ReservationRepository.java +++ b/src/main/java/umc/meme/shop/domain/reservation/repository/ReservationRepository.java @@ -6,6 +6,7 @@ import org.springframework.data.repository.query.Param; import umc.meme.shop.domain.artist.entity.Artist; import umc.meme.shop.domain.model.entity.Model; +import umc.meme.shop.domain.portfolio.entity.Portfolio; import umc.meme.shop.domain.reservation.entity.Reservation; import java.util.List; @@ -21,6 +22,7 @@ public interface ReservationRepository extends JpaRepository @Query("SELECT r FROM Reservation r JOIN r.model m WHERE r.reservationId = :reservationId AND m.userId = :modelId") Optional findByReservationIdAndModelId(@Param("reservationId") Long reservationId, @Param("modelId") Long modelId); + List findByModelAndPortfolio(Model model, Portfolio portfolio); } diff --git a/src/main/java/umc/meme/shop/domain/reservation/service/ReservationService.java b/src/main/java/umc/meme/shop/domain/reservation/service/ReservationService.java index 94ef00d..75f282b 100644 --- a/src/main/java/umc/meme/shop/domain/reservation/service/ReservationService.java +++ b/src/main/java/umc/meme/shop/domain/reservation/service/ReservationService.java @@ -87,6 +87,14 @@ public ReservationCompleteDto createReservation(ReservationRequestDto reservatio throw new GlobalException(ErrorStatus.NOT_ALLOW_OVER_ONE_RESERVATION); } + //예약 중복 처리 + List reservationList = reservationRepository.findByModelAndPortfolio(model, portfolio); + for(int i=0; i inquiryList; diff --git a/src/main/java/umc/meme/shop/global/ErrorStatus.java b/src/main/java/umc/meme/shop/global/ErrorStatus.java index 34f0019..b42d663 100644 --- a/src/main/java/umc/meme/shop/global/ErrorStatus.java +++ b/src/main/java/umc/meme/shop/global/ErrorStatus.java @@ -50,6 +50,7 @@ public enum ErrorStatus { //reservation ALREADY_CHANGE_STATUS(400, "이미 예약 상태가 변경되었습니다."), INVALID_CHANGE_STATUS(400, "이미 완료된 예약은 취소할 수 없습니다."), + NOT_ALLOW_DUPLICATED_RESERVATION(400, "중복된 예약 시간입니다."), NOT_ALLOW_OVER_ONE_RESERVATION(400,"한 번에 하나의 예약만 가능합니다." ), INVALID_CHANGE_COMPLETE(400,"취소된 예약을 완료 상태로 변경할 수 없습니다." ),