diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/dto/SortedMyLikeDiary.java b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/dto/SortedMyLikeDiary.java index 5db9953..351be4c 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/dto/SortedMyLikeDiary.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/dto/SortedMyLikeDiary.java @@ -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; } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/dto/response/FarmClubDiary.java b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/dto/response/FarmClubDiary.java index caaaac7..58dca28 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/dto/response/FarmClubDiary.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/dto/response/FarmClubDiary.java @@ -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(), @@ -34,6 +35,7 @@ public static FarmClubDiary of(Diary diary, User user, String writeDateTime, int user.getNickname(), user.getProfileImage(), myLike, + myDiary, status ); } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/repository/DiaryRepository.java b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/repository/DiaryRepository.java index ba0a67b..a6c7006 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/repository/DiaryRepository.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/repository/DiaryRepository.java @@ -37,6 +37,7 @@ public interface DiaryRepository extends JpaRepository { "WHERE d.id = :diaryId") List 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 " + @@ -44,7 +45,9 @@ public interface DiaryRepository extends JpaRepository { "WHERE d.farmClub.id = :farmClubId AND d.isOpen = true " ) List 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 " + diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/service/MyVeggieDiaryService.java b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/service/MyVeggieDiaryService.java index 8cc3c5e..d12cb52 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/service/MyVeggieDiaryService.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/service/MyVeggieDiaryService.java @@ -109,6 +109,7 @@ private List proccessFarmClubData(List diaryAl allDiary.getDiary().getDiaryLikes().size(), allDiary.getDiary().getDiaryComments().size(), allDiary.isMyLike(), + allDiary.isMyDiary(), allDiary.getDiary().getState() );}).toList(); } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/user/controller/UserController.java b/src/main/java/com/modernfarmer/farmusspring/domain/user/controller/UserController.java index 16a297f..f48910a 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/user/controller/UserController.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/user/controller/UserController.java @@ -59,7 +59,7 @@ public BaseResponseDto bringNotification(@AuthenticationPrincipal CustomUser @PostMapping(value = "/profile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public BaseResponseDto 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()); diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/user/util/EncouragementMessages.java b/src/main/java/com/modernfarmer/farmusspring/domain/user/util/EncouragementMessages.java index 4a06cd5..df55efb 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/user/util/EncouragementMessages.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/user/util/EncouragementMessages.java @@ -10,8 +10,8 @@ public enum EncouragementMessages { "직접 기른 채소로\n매일 알뜰하게, 매일 특별하게!" }), 건강과웰빙(new String[]{ - "파머님, 직접 기른 채소로\n건강한 삶을 챙겨봐요!", - "파머님의 사랑으로\n오늘도 쑥쑥 자라는 중", + "직접 기른 채소로\n건강한 삶을 챙겨봐요!", + "정성으로 가꾼 채소들이\n오늘도 쑥쑥 자라는 중", "직접 기른 채소를\n먹을 수 있는 그날까지!", "신선함으로 가득 채워지는 식탁, \n 늘 함께할게요!", "눈으로 보는 재미, 입으로 맛보는\n홈파밍의 즐거움!"