-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: 포인트 도메인 리펙토링 #231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 19 commits
1afa6b1
12307f3
32e1b18
d4b044e
406173c
3060634
94788fc
973c238
2632542
5220d38
eed58da
44ee6c7
d6f77cd
a31352f
bbdbea8
1033ecd
3777ce3
26a8b1e
dc3c613
2848333
2db80d5
5d74eb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.kau.capstone.entity.point; | ||
|
|
||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| public enum PointType { | ||
| PAYMENT_POINT("포인트 결제"), | ||
| EARN_POINT("포인트 적립"); | ||
|
|
||
| final String description; | ||
|
|
||
| PointType(String description) { | ||
| this.description = description; | ||
| } | ||
|
|
||
| public static PointType getPointType(String description) { | ||
| for (PointType pointType : PointType.values()) { | ||
| if (pointType.description.equals(description)) { | ||
| return pointType; | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| import com.kau.capstone.entity.member.Member; | ||
| import com.kau.capstone.entity.point.History; | ||
| import com.kau.capstone.v2.point.dto.response.HistoryListResV2; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
|
|
@@ -10,6 +11,11 @@ | |
|
|
||
| public interface HistoryRepository extends JpaRepository<History, Long> { | ||
|
|
||
| @Query("SELECT h FROM History h WHERE h.member = :member ORDER BY h.id DESC ") | ||
| @Query("SELECT h FROM History h WHERE h.point.member = :member ORDER BY h.id DESC ") | ||
| List<History> findHistoriesByMember(@Param("member") Member member); | ||
|
|
||
| default HistoryListResV2 findHistoryListByMember(Member member){ | ||
| List<History> res = findHistoriesByMember(member); | ||
| return HistoryListResV2.of(res); | ||
| } | ||
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,20 @@ | ||
| package com.kau.capstone.entity.point.repository; | ||
|
|
||
| import com.kau.capstone.entity.member.Member; | ||
| import com.kau.capstone.entity.point.Point; | ||
| import com.kau.capstone.v2.point.exception.PointNotFoundExceptionV2; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| public interface PointRepository extends JpaRepository<Point, Long> { | ||
|
|
||
| @Query("SELECT p FROM Point p WHERE p.member = :member") | ||
| Optional<Point> findByMember(@Param("member") Member member); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 얘는 왜 Optional 써요 |
||
|
|
||
| default Point getByMember(Member member){ | ||
| return findByMember(member).orElseThrow(PointNotFoundExceptionV2::new); | ||
| }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| package com.kau.capstone.v1.point.dto; | ||
|
|
||
| public record DeliveryFeeRequest( | ||
| Long deliveryFee | ||
| long deliveryFee | ||
| ) { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| package com.kau.capstone.v1.point.dto; | ||
|
|
||
| public record EarnPointRequest( | ||
| Long point | ||
| long point | ||
| ) { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| package com.kau.capstone.v1.point.dto; | ||
|
|
||
| public record PayPointRequest( | ||
| Long point | ||
| long point | ||
| ) { | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
얘도 없애주세요~