Skip to content

Commit

Permalink
YEL-214 [fix] 푸시알림 type 수정
Browse files Browse the repository at this point in the history
YEL-214 [fix] 푸시알림 type 수정
  • Loading branch information
hyeonjeongs authored Mar 2, 2024
2 parents 42bb5e4 + 72720da commit 8798786
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,31 +110,34 @@ public SignUpResponse signUp(SignUpRequest signUpRequest) {

@Transactional
public void recommendUser(String recommendYelloId, String userYelloId) {
if (recommendYelloId != null && !recommendYelloId.isEmpty()) {
if (recommendYelloId!=null && !recommendYelloId.isEmpty()) {
User recommendedUser = userRepository.getByYelloId(recommendYelloId);
User user = userRepository.getByYelloId(userYelloId);
final Optional<UserData> recommended = userDataRepository.findByUserIdAndTag(recommendedUser.getId(),
UserDataType.RECOMMENDED);
final Optional<UserData> recommended =
userDataRepository.findByUserIdAndTag(recommendedUser.getId(),
UserDataType.RECOMMENDED);

recommendedUser.addRecommendCount(1L);
recommendedUser.addPointBySubscribe(RECOMMEND_POINT);
user.addPointBySubscribe(RECOMMEND_POINT);

final Optional<Cooldown> cooldown =
cooldownRepository.findByUserId(recommendedUser.getId());
cooldown.ifPresent(cooldownRepository::delete);

if (recommended.isEmpty()) {
recommendedUser.addTicketCount(1);
notificationService.sendRecommendSignupAndGetTicketNotification(recommendedUser,
user);

userDataRepository.save(UserData.of(
UserDataType.RECOMMENDED,
ZonedDateTime.now(GlobalZoneId).format(ISO_OFFSET_DATE_TIME),
recommendedUser
));
notificationService.sendRecommendSignupAndGetTicketNotification(recommendedUser, user);
return;
}

notificationService.sendRecommendNotification(user, recommendedUser);

final Optional<Cooldown> cooldown =
cooldownRepository.findByUserId(recommendedUser.getId());
cooldown.ifPresent(cooldownRepository::delete);
}
}

Expand Down Expand Up @@ -166,22 +169,28 @@ public OnBoardingFriendResponse findOnBoardingFriends(OnBoardingFriendRequest fr
return OnBoardingFriendResponse.of(kakaoFriends.size(), pageList);
}

public GroupNameSearchResponse findGroupNameContaining(String keyword, UserGroupType userGroupType,
public GroupNameSearchResponse findGroupNameContaining(String keyword,
UserGroupType userGroupType,
Pageable pageable) {
int totalCount = userGroupRepository.countDistinctGroupNameContaining(keyword, userGroupType);
final List<String> nameList = userGroupRepository.findDistinctGroupNameContaining(keyword, userGroupType,
pageable)
.stream()
.toList();
int totalCount =
userGroupRepository.countDistinctGroupNameContaining(keyword, userGroupType);
final List<String> nameList =
userGroupRepository.findDistinctGroupNameContaining(keyword, userGroupType,
pageable)
.stream()
.toList();

return GroupNameSearchResponse.of(totalCount, nameList);
}

public DepartmentSearchResponse findGroupDepartmentBySchoolNameContaining(String schoolName, String keyword,
public DepartmentSearchResponse findGroupDepartmentBySchoolNameContaining(String schoolName,
String keyword,
UserGroupType userGroupType, Pageable pageable) {
int totalCount = userGroupRepository.countAllByGroupNameContaining(schoolName, keyword, userGroupType);
final List<UserGroup> userGroupResult = userGroupRepository.findAllByGroupNameContaining(schoolName, keyword,
userGroupType, pageable);
int totalCount =
userGroupRepository.countAllByGroupNameContaining(schoolName, keyword, userGroupType);
final List<UserGroup> userGroupResult =
userGroupRepository.findAllByGroupNameContaining(schoolName, keyword,
userGroupType, pageable);

return DepartmentSearchResponse.of(totalCount, userGroupResult);
}
Expand All @@ -206,7 +215,8 @@ public ServiceTokenVO reIssueToken(@NotNull ServiceTokenVO tokens) {

public ClassNameSearchResponse getHighSchoolClassName(String schoolName, String className) {
UserGroup userGroup =
userGroupRepository.getByGroupNameAndSubGroupName(schoolName, className, UserGroupType.HIGH_SCHOOL);
userGroupRepository.getByGroupNameAndSubGroupName(schoolName, className,
UserGroupType.HIGH_SCHOOL);
return ClassNameSearchResponse.of(userGroup);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ public enum NotificationType {
NEW_FRIEND,
RECOMMEND,
LUNCH_EVENT,
OPEN_VOTE
OPEN_VOTE,
FIRST_RECOMMEND
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static NotificationMessage toUserAndFriendRecommendSignupAndGetTicketNoti
return NotificationMessage.builder()
.title(MessageFormat.format("{0}님이 나를 추천인으로 가입해 열람권이 지급됐어요!", user.getName()))
.message("지금이다! 날 짝사랑 하는 사람 보러가기")
.type(NotificationType.RECOMMEND)
.type(NotificationType.FIRST_RECOMMEND)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class EventScheduler {
private final JobRepository jobRepository;
private final PlatformTransactionManager transactionManager;

@Scheduled(cron = "0 20 16 * * ?")
@Scheduled(cron = "0 0 12 * * ?")
public void lunchEventRunJob() {

//JobParamter의 역할은 반복해서 실행되는 Job의 유일한 ID임, 동일한 값이 세팅되면 두번째부터 실행안됨)
Expand Down

0 comments on commit 8798786

Please sign in to comment.