-
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.
Browse files
Browse the repository at this point in the history
[suffle] Chapter10_API & Paging
- Loading branch information
Showing
9 changed files
with
112 additions
and
10 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
src/mission/umc/src/main/java/com/example/umc/repository/MemberMissionRepository.java
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,10 @@ | ||
package com.example.umc.repository; | ||
|
||
import com.example.umc.domain.maaping.MemberMission; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface MemberMissionRepository extends JpaRepository<MemberMission, Long> { | ||
Page<MemberMission> findByMemberId(Long memberId, Pageable pageable); | ||
} |
3 changes: 3 additions & 0 deletions
3
src/mission/umc/src/main/java/com/example/umc/repository/MissionRepository.java
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,8 +1,11 @@ | ||
package com.example.umc.repository; | ||
|
||
import com.example.umc.domain.Mission; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface MissionRepository extends JpaRepository<Mission, Long> { | ||
Page<Mission> findByStoreId(Long storeId, Pageable pageable); | ||
|
||
} |
5 changes: 4 additions & 1 deletion
5
src/mission/umc/src/main/java/com/example/umc/repository/ReviewRepository.java
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,8 +1,11 @@ | ||
package com.example.umc.repository; | ||
|
||
import com.example.umc.domain.Review; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface ReviewRepository extends JpaRepository<Review, Long> { | ||
|
||
//특정 사용자가 작성한 리뷰를 페이징 처리하여 가져오는 메서드 추가 | ||
Page<Review> findByMemberId(Long memberId, Pageable pageable); | ||
} |
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
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
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
43 changes: 43 additions & 0 deletions
43
src/mission/umc/src/main/java/com/example/umc/web/dto/reponse/MissionResponseDto.java
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,43 @@ | ||
package com.example.umc.web.dto.reponse; | ||
|
||
import com.example.umc.domain.Mission; | ||
import com.example.umc.domain.maaping.MemberMission; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Getter | ||
@Builder | ||
public class MissionResponseDto { | ||
|
||
private Long id; | ||
private Integer reward; | ||
private LocalDate deadline; | ||
|
||
@Builder | ||
public MissionResponseDto (Long id, Integer reward, LocalDate deadline){ | ||
this.id = id; | ||
this.reward = reward; | ||
this.deadline = deadline; | ||
} | ||
|
||
public static MissionResponseDto fromEntity(Mission mission){ | ||
return MissionResponseDto.builder() | ||
.id(mission.getId()) | ||
.reward(mission.getReward()) | ||
.deadline(mission.getDeadline()) | ||
.build(); | ||
} | ||
|
||
public static MissionResponseDto fromMemberMissionEntity(MemberMission memberMission) { | ||
return MissionResponseDto.builder() | ||
.id(memberMission.getMission().getId()) | ||
.reward(memberMission.getMission().getReward()) | ||
.deadline(memberMission.getMission().getDeadline()) | ||
.build(); | ||
} | ||
|
||
|
||
} |