Skip to content

Commit 058eb19

Browse files
authored
Merge pull request #344 from let-s-record-it/develop
Merge develop into main
2 parents e205a87 + 6e53f41 commit 058eb19

File tree

16 files changed

+121
-32
lines changed

16 files changed

+121
-32
lines changed

src/main/java/com/sillim/recordit/calendar/dto/response/CalendarResponse.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
import com.sillim.recordit.calendar.domain.Calendar;
44

5-
public record CalendarResponse(Long id, String title, String colorHex) {
5+
public record CalendarResponse(Long id, String title, String colorHex, Long categoryId) {
66

77
public static CalendarResponse from(Calendar calendar) {
8-
return new CalendarResponse(calendar.getId(), calendar.getTitle(), calendar.getColorHex());
8+
return new CalendarResponse(
9+
calendar.getId(),
10+
calendar.getTitle(),
11+
calendar.getColorHex(),
12+
calendar.getCategory().getId());
913
}
1014
}

src/main/java/com/sillim/recordit/feed/service/FeedCommandService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public class FeedCommandService {
3232
public Long addFeed(FeedAddRequest request, List<MultipartFile> images, Long memberId) {
3333
Long feedId = feedRepository.save(request.toFeed(memberId)).getId();
3434

35+
if (images == null || images.isEmpty()) {
36+
return feedId;
37+
}
3538
messagePublisher.send(
3639
new Message<>(
3740
MessageType.IMAGES.name(),

src/main/java/com/sillim/recordit/feed/service/FeedLikeService.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import com.sillim.recordit.feed.repository.FeedRepository;
77
import com.sillim.recordit.global.exception.ErrorCode;
88
import com.sillim.recordit.global.exception.common.RecordNotFoundException;
9+
import com.sillim.recordit.member.service.MemberQueryService;
10+
import com.sillim.recordit.pushalarm.dto.PushMessage;
11+
import com.sillim.recordit.pushalarm.service.AlarmService;
912
import jakarta.persistence.OptimisticLockException;
1013
import lombok.RequiredArgsConstructor;
1114
import org.hibernate.StaleObjectStateException;
@@ -22,14 +25,16 @@ public class FeedLikeService {
2225

2326
private final FeedLikeRepository feedLikeRepository;
2427
private final FeedRepository feedRepository;
28+
private final AlarmService alarmService;
29+
private final MemberQueryService memberQueryService;
2530

2631
@Retryable(
2732
retryFor = {
2833
OptimisticLockException.class,
2934
ObjectOptimisticLockingFailureException.class,
3035
StaleObjectStateException.class
3136
},
32-
maxAttempts = 15,
37+
maxAttempts = 20,
3338
backoff = @Backoff(delay = 30))
3439
public void feedLike(Long feedId, Long memberId) {
3540
Feed feed =
@@ -38,6 +43,16 @@ public void feedLike(Long feedId, Long memberId) {
3843
.orElseThrow(() -> new RecordNotFoundException(ErrorCode.FEED_NOT_FOUND));
3944
feed.like();
4045
feedLikeRepository.save(new FeedLike(feed, memberId));
46+
47+
if (!feed.isOwner(memberId)) {
48+
alarmService.pushAlarm(
49+
memberId,
50+
feed.getMemberId(),
51+
PushMessage.fromFeedLike(
52+
feed.getId(),
53+
memberQueryService.findByMemberId(memberId).getPersonalId(),
54+
feed.getTitle()));
55+
}
4156
}
4257

4358
@Retryable(
@@ -46,7 +61,7 @@ public void feedLike(Long feedId, Long memberId) {
4661
ObjectOptimisticLockingFailureException.class,
4762
StaleObjectStateException.class
4863
},
49-
maxAttempts = 15,
64+
maxAttempts = 20,
5065
backoff = @Backoff(delay = 30))
5166
public void feedUnlike(Long feedId, Long memberId) {
5267
feedRepository

src/main/java/com/sillim/recordit/goal/dto/response/MonthlyGoalListResponse.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,14 @@
22

33
import com.sillim.recordit.goal.domain.MonthlyGoal;
44

5-
public record MonthlyGoalListResponse(
6-
Long id,
7-
String title,
8-
Long categoryId,
9-
String colorHex,
10-
Boolean achieved,
11-
Long calendarId) {
5+
public record MonthlyGoalListResponse(Long id, String title, String colorHex, Boolean achieved) {
126

137
public static MonthlyGoalListResponse from(final MonthlyGoal monthlyGoal) {
148

159
return new MonthlyGoalListResponse(
1610
monthlyGoal.getId(),
1711
monthlyGoal.getTitle(),
18-
monthlyGoal.getCategory().getId(),
1912
monthlyGoal.getColorHex(),
20-
monthlyGoal.isAchieved(),
21-
monthlyGoal.getCalendar().getId());
13+
monthlyGoal.isAchieved());
2214
}
2315
}

src/main/java/com/sillim/recordit/goal/dto/response/WeeklyGoalDetailsResponse.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public static WeeklyGoalDetailsResponse from(final WeeklyGoal weeklyGoal) {
2727
.week(weeklyGoal.getWeek())
2828
.startDate(weeklyGoal.getStartDate())
2929
.endDate(weeklyGoal.getEndDate())
30+
.calendarId(weeklyGoal.getCalendar().getId())
3031
.categoryId(weeklyGoal.getCategory().getId())
3132
.colorHex(weeklyGoal.getColorHex())
3233
.build();
@@ -38,6 +39,7 @@ public static WeeklyGoalDetailsResponse from(final WeeklyGoal weeklyGoal) {
3839
.week(weeklyGoal.getWeek())
3940
.startDate(weeklyGoal.getStartDate())
4041
.endDate(weeklyGoal.getEndDate())
42+
.calendarId(weeklyGoal.getCalendar().getId())
4143
.categoryId(weeklyGoal.getCategory().getId())
4244
.colorHex(weeklyGoal.getColorHex())
4345
.relatedMonthlyGoal(

src/main/java/com/sillim/recordit/goal/dto/response/WeeklyGoalResponse.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
public record WeeklyGoalResponse(
88
Long id,
99
String title,
10-
Long categoryId,
10+
Integer week,
1111
String colorHex,
1212
Boolean achieved,
13-
Long calendarId,
1413
RelatedMonthlyGoalResponse relatedMonthlyGoal) {
1514

1615
public static WeeklyGoalResponse from(final WeeklyGoal weeklyGoal) {
@@ -19,19 +18,17 @@ public static WeeklyGoalResponse from(final WeeklyGoal weeklyGoal) {
1918
return WeeklyGoalResponse.builder()
2019
.id(weeklyGoal.getId())
2120
.title(weeklyGoal.getTitle())
22-
.categoryId(weeklyGoal.getCategory().getId())
21+
.week(weeklyGoal.getWeek())
2322
.colorHex(weeklyGoal.getColorHex())
2423
.achieved(weeklyGoal.isAchieved())
25-
.calendarId(weeklyGoal.getCalendar().getId())
2624
.build();
2725
}
2826
return WeeklyGoalResponse.builder()
2927
.id(weeklyGoal.getId())
3028
.title(weeklyGoal.getTitle())
31-
.categoryId(weeklyGoal.getCategory().getId())
29+
.week(weeklyGoal.getWeek())
3230
.colorHex(weeklyGoal.getColorHex())
3331
.achieved(weeklyGoal.isAchieved())
34-
.calendarId(weeklyGoal.getCalendar().getId())
3532
.relatedMonthlyGoal(
3633
RelatedMonthlyGoalResponse.from(weeklyGoal.getRelatedMonthlyGoal().get()))
3734
.build();

src/main/java/com/sillim/recordit/goal/repository/CustomWeeklyGoalRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public interface CustomWeeklyGoalRepository {
1010

1111
List<WeeklyGoal> findWeeklyGoalInMonth(Integer year, Integer month, Long calendarId);
1212

13-
@Query("select wg from WeeklyGoal wg left join fetch wg.calendar where wg.id = :id")
13+
@Query(
14+
"select wg from WeeklyGoal wg left join fetch wg.calendar left join fetch wg.category left join fetch wg.relatedMonthlyGoal where wg.id = :id")
1415
Optional<WeeklyGoal> findWeeklyGoalById(@Param("id") Long id);
1516
}

src/main/java/com/sillim/recordit/invite/controller/InviteController.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
import com.sillim.recordit.invite.dto.response.InviteLinkResponse;
88
import com.sillim.recordit.invite.service.InviteService;
99
import com.sillim.recordit.member.domain.Member;
10+
import com.sillim.recordit.member.dto.response.MemberListResponse;
1011
import com.sillim.recordit.member.service.MemberQueryService;
1112
import java.io.IOException;
13+
import java.util.List;
1214
import lombok.RequiredArgsConstructor;
1315
import org.springframework.http.ResponseEntity;
1416
import org.springframework.web.bind.annotation.*;
@@ -37,6 +39,17 @@ public ResponseEntity<InviteInfoResponse> getInviteInfo(@PathVariable String inv
3739
calendar.getId(), calendar.getTitle(), member.getId(), member.getName()));
3840
}
3941

42+
@GetMapping("/followings")
43+
public ResponseEntity<List<MemberListResponse>> myFollowingList(
44+
@RequestParam Long calendarId, @CurrentMember Member member) {
45+
return ResponseEntity.ok(
46+
inviteService
47+
.searchFollowingsNotInvited(calendarId, member.getPersonalId())
48+
.stream()
49+
.map(MemberListResponse::of)
50+
.toList());
51+
}
52+
4053
@PostMapping("/members/{inviteMemberId}")
4154
public ResponseEntity<Void> inviteMember(
4255
@PathVariable Long inviteMemberId,

src/main/java/com/sillim/recordit/invite/service/InviteService.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.sillim.recordit.invite.service;
22

33
import com.sillim.recordit.calendar.domain.Calendar;
4+
import com.sillim.recordit.calendar.dto.response.CalendarMemberResponse;
45
import com.sillim.recordit.calendar.service.CalendarMemberService;
56
import com.sillim.recordit.calendar.service.CalendarQueryService;
67
import com.sillim.recordit.global.exception.ErrorCode;
@@ -12,10 +13,12 @@
1213
import com.sillim.recordit.invite.repository.InviteLinkRepository;
1314
import com.sillim.recordit.invite.repository.InviteLogRepository;
1415
import com.sillim.recordit.member.domain.Member;
16+
import com.sillim.recordit.member.service.MemberQueryService;
1517
import com.sillim.recordit.pushalarm.dto.PushMessage;
1618
import com.sillim.recordit.pushalarm.service.AlarmService;
1719
import java.time.LocalDateTime;
1820
import java.util.Base64;
21+
import java.util.List;
1922
import java.util.Optional;
2023
import java.util.UUID;
2124
import lombok.RequiredArgsConstructor;
@@ -32,6 +35,7 @@ public class InviteService {
3235
private final InviteLogRepository inviteLogRepository;
3336
private final AlarmService alarmService;
3437
private final CalendarMemberService calendarMemberService;
38+
private final MemberQueryService memberQueryService;
3539

3640
public String getOrGenerateInviteLink(Long calendarId) {
3741
Optional<InviteLink> inviteLink =
@@ -74,6 +78,23 @@ public InviteLink searchInviteInfo(String inviteCode) {
7478
new String(Base64.getUrlDecoder().decode(inviteCode)));
7579
}
7680

81+
@Transactional(readOnly = true)
82+
public List<Member> searchFollowingsNotInvited(Long calendarId, String personalId) {
83+
List<CalendarMemberResponse> calendarMembers =
84+
calendarMemberService.searchCalendarMembers(calendarId);
85+
return memberQueryService.searchFollowings(personalId).stream()
86+
.filter(
87+
follow -> {
88+
for (var calendarMember : calendarMembers) {
89+
if (calendarMember.memberId().equals(follow.getId())) {
90+
return false;
91+
}
92+
}
93+
return true;
94+
})
95+
.toList();
96+
}
97+
7798
public void inviteMember(Long calendarId, Long invitedMemberId, Member inviter) {
7899
Calendar calendar = calendarQueryService.searchByCalendarId(calendarId);
79100
calendar.validateAuthenticatedMember(inviter.getId());

src/main/java/com/sillim/recordit/member/controller/MemberController.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,6 @@ public ResponseEntity<List<FollowRecommendResponse>> recommendMemberList(
7171
return ResponseEntity.ok(body);
7272
}
7373

74-
@GetMapping("/me/followings")
75-
public ResponseEntity<List<MemberListResponse>> myFollowingList(@CurrentMember Member member) {
76-
return ResponseEntity.ok(
77-
memberQueryService.searchFollowings(member.getPersonalId()).stream()
78-
.map(MemberListResponse::of)
79-
.toList());
80-
}
81-
8274
@PostMapping("/{memberId}/follow")
8375
public ResponseEntity<Void> follow(@PathVariable Long memberId, @CurrentMember Member member)
8476
throws IOException {

0 commit comments

Comments
 (0)