Skip to content

Commit

Permalink
Merge pull request #103 from Mojacknong/fix_102/일기-조회
Browse files Browse the repository at this point in the history
Fix 102/일기 조회
  • Loading branch information
MinchoGreenT authored Aug 21, 2024
2 parents 86bc5c3 + d18b062 commit 93aacef
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
public class SortedMyLikeDiary {

private Diary diary;
private boolean myDiary;
private boolean myLike;

public SortedMyLikeDiary(Diary diary, boolean myLike) {
public SortedMyLikeDiary(Diary diary, boolean myDiary, boolean myLike) {
this.diary = diary;
this.myDiary=myDiary;
this.myLike = myLike;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ public class FarmClubDiary {
private String nickname;
private String profileImage;
private boolean myLike;
private boolean myDiary;
private String state;

public static FarmClubDiary of(Diary diary, User user, String writeDateTime, int likeCount, int commentCount, boolean myLike, String status){
public static FarmClubDiary of(Diary diary, User user, String writeDateTime, int likeCount, int commentCount, boolean myLike, boolean myDiary, String status){
return new FarmClubDiary(
diary.getId(),
diary.getImage(),
Expand All @@ -34,6 +35,7 @@ public static FarmClubDiary of(Diary diary, User user, String writeDateTime, int
user.getNickname(),
user.getProfileImage(),
myLike,
myDiary,
status
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ public interface DiaryRepository extends JpaRepository<Diary, Long> {
"WHERE d.id = :diaryId")
List<DiaryComment> findDiaryById(@Param("diaryId") Long diaryId);
@Query("SELECT new com.modernfarmer.farmusspring.domain.myveggiegarden.dto.SortedMyLikeDiary(d, " +
"CASE WHEN d.myVeggie.user.id = :userId THEN true ELSE false END, " +
"CASE WHEN dl.user.id = :userId THEN true ELSE false END) " +
"FROM diary AS d " +
"JOIN FETCH d.myVeggie AS mv " +
"LEFT JOIN diary_like AS dl ON dl.diary.id = d.id AND dl.user.id = :userId " +
"WHERE d.farmClub.id = :farmClubId AND d.isOpen = true "
)
List<SortedMyLikeDiary> findDiaryByFarmClub(@Param("farmClubId") Long farmClubId, @Param("userId") Long userId);

@Query("SELECT new com.modernfarmer.farmusspring.domain.myveggiegarden.dto.SortedMyLikeDiary(d, " +
"CASE WHEN d.myVeggie.user.id = :userId THEN true ELSE false END, " +
"CASE WHEN dl.user.id = :userId THEN true ELSE false END) " +
"FROM diary AS d " +
"JOIN FETCH d.myVeggie AS mv " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ private List<FarmClubDiary> proccessFarmClubData(List<SortedMyLikeDiary> diaryAl
allDiary.getDiary().getDiaryLikes().size(),
allDiary.getDiary().getDiaryComments().size(),
allDiary.isMyLike(),
allDiary.isMyDiary(),
allDiary.getDiary().getState()
);}).toList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public BaseResponseDto<?> bringNotification(@AuthenticationPrincipal CustomUser
@PostMapping(value = "/profile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public BaseResponseDto<Void> settingProfile(
@AuthenticationPrincipal CustomUser user,
@RequestPart UserNickname userNickname,
@Validated @RequestPart UserNickname userNickname,
@RequestPart(value = "image", required = false) MultipartFile file
) throws IOException {
return userService.settingProfile(user.getUserId(), file, userNickname.getNickname());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public enum EncouragementMessages {
"직접 기른 채소로\n매일 알뜰하게, 매일 특별하게!"
}),
건강과웰빙(new String[]{
"파머님, 직접 기른 채소로\n건강한 삶을 챙겨봐요!",
"파머님의 사랑으로\n오늘도 쑥쑥 자라는 중",
"직접 기른 채소로\n건강한 삶을 챙겨봐요!",
"정성으로 가꾼 채소들이\n오늘도 쑥쑥 자라는 중",
"직접 기른 채소를\n먹을 수 있는 그날까지!",
"신선함으로 가득 채워지는 식탁, \n 늘 함께할게요!",
"눈으로 보는 재미, 입으로 맛보는\n홈파밍의 즐거움!"
Expand Down

0 comments on commit 93aacef

Please sign in to comment.