forked from Exagonal-Study/est-delivery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from this-is-spear/5-전화번호를-입력해-쿠폰을-나눠줄-수-있게-하고…
…-싶음-3 �선물 받은 쿠폰 코드 등록 유효기간 정책을 설정한다.
- Loading branch information
Showing
18 changed files
with
167 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...tlin/com/example/estdelivery/coupon/application/port/in/FindAvailableGiftCouponUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package com.example.estdelivery.coupon.application.port.`in` | ||
|
||
import com.example.estdelivery.coupon.domain.coupon.GiftCoupon | ||
import com.example.estdelivery.coupon.application.port.`in`.web.dto.GiftCouponResponses | ||
|
||
interface FindAvailableGiftCouponUseCase { | ||
/** | ||
* 회원은 가게에 발행된 쿠폰 중 선물 가능한 쿠폰을 조회한다. | ||
* @param memberId | ||
*/ | ||
fun findAvailableGiftCoupon(memberId: Long): List<GiftCoupon> | ||
fun findAvailableGiftCoupon(memberId: Long): GiftCouponResponses | ||
} |
4 changes: 2 additions & 2 deletions
4
...n/kotlin/com/example/estdelivery/coupon/application/port/in/GiftCouponByMessageUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package com.example.estdelivery.coupon.application.port.`in` | ||
|
||
import com.example.estdelivery.coupon.domain.coupon.GiftMessage | ||
import com.example.estdelivery.coupon.application.port.`in`.web.dto.GiftMessageResponse | ||
|
||
interface GiftCouponByMessageUseCase { | ||
fun sendGiftAvailableCoupon(memberId: Long, couponId: Long, giftMessage: String): GiftMessage | ||
fun sendGiftAvailableCoupon(memberId: Long, couponId: Long, giftMessage: String): GiftMessageResponse | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
.../kotlin/com/example/estdelivery/coupon/application/port/in/web/dto/GiftMessageResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
package com.example.estdelivery.coupon.application.port.`in`.web.dto | ||
|
||
import java.net.URL | ||
import java.time.LocalDate | ||
|
||
data class GiftMessageResponse( | ||
val senderName: String, | ||
val description: String, | ||
val enrollEndDate: LocalDate, | ||
val enrollHref: URL, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...le/estdelivery/coupon/application/port/out/adapter/persistence/entity/EnrollTermEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.example.estdelivery.coupon.application.port.out.adapter.persistence.entity | ||
|
||
import jakarta.persistence.Column | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.EnumType | ||
import jakarta.persistence.Enumerated | ||
import jakarta.persistence.GeneratedValue | ||
import jakarta.persistence.GenerationType | ||
import jakarta.persistence.Id | ||
import jakarta.persistence.Table | ||
import java.time.LocalDateTime | ||
import java.time.temporal.ChronoUnit | ||
|
||
@Entity | ||
@Table(name = "enroll_term") | ||
class EnrollTermEntity( | ||
@Column(updatable = false) | ||
val term: Long, | ||
@Enumerated(value = EnumType.STRING) | ||
val unit: ChronoUnit, | ||
@Column(updatable = false) | ||
val createDate: LocalDateTime = LocalDateTime.now(), | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
val id: Long? = null, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...livery/coupon/application/port/out/adapter/persistence/repository/EnrollDateRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.example.estdelivery.coupon.application.port.out.adapter.persistence.repository | ||
|
||
import com.example.estdelivery.coupon.application.port.out.adapter.persistence.entity.EnrollTermEntity | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.data.jpa.repository.Query | ||
import org.springframework.stereotype.Repository | ||
|
||
interface EnrollDateJpaRepository : JpaRepository<EnrollTermEntity, Long> { | ||
@Query("SELECT e FROM EnrollTermEntity e WHERE e.id = (SELECT MAX(e2.id) FROM EnrollTermEntity e2)") | ||
fun findLatestPolicy(): EnrollTermEntity? | ||
} | ||
|
||
@Repository | ||
class EnrollDateRepository( | ||
private val repository: EnrollDateJpaRepository | ||
) { | ||
fun findLatestPolicy(): EnrollTermEntity? { | ||
return repository.findLatestPolicy() | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
coupon/src/main/kotlin/com/example/estdelivery/coupon/domain/coupon/GiftCoupon.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
package com.example.estdelivery.coupon.domain.coupon | ||
|
||
import java.time.LocalDate | ||
|
||
/** | ||
* 선물하는 쿠폰을 선정할 때 여러 제약이 생길 수 있다. | ||
* 제약 변경에 대응하기 위해 컴포지션을 활용한다. | ||
*/ | ||
data class GiftCoupon( | ||
val coupon: Coupon, | ||
val enrollEndDate: LocalDate, | ||
val isUsed: Boolean = false, | ||
) { | ||
init { | ||
require(!coupon.isPublished()) { "발행한 쿠폰은 선물할 수 없습니다." } | ||
require(enrollEndDate.isAfter(LocalDate.now())) { "유효기간이 지난 쿠폰은 선물할 수 없습니다." } | ||
require(!isUsed) { "이미 사용된 쿠폰은 선물할 수 없습니다." } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.