Skip to content

Commit

Permalink
feat: 알림 - 랜덤 매칭 일기 생성되었을 때 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
idon1nab committed May 7, 2024
1 parent 9b66cf2 commit 2ccd080
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public void diaryStateModify (@PathVariable("diaryID") Long diaryID){
emitterService.sendEvents(receiverID, senderID, NotifyDTO.NotifyType.INACTIVATE);
emitterService.sendEvents(senderID, receiverID, NotifyDTO.NotifyType.INACTIVATE);
notifyService.saveNotifyTable(receiverID, senderID, NotifyDTO.NotifyType.INACTIVATE);
notifyService.saveNotifyTable(senderID, receiverID, NotifyDTO.NotifyType.INACTIVATE);

log.info(diaryService.findOne(diaryID));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public Map<String, String> partnerModify(String code, Authentication authenticat
emitterService.sendEvents(receiverID, partnerID, NotifyDTO.NotifyType.NEWDIARY);
emitterService.sendEvents(partnerID, receiverID, NotifyDTO.NotifyType.NEWDIARY);
notifyService.saveNotifyTable(receiverID, partnerID, NotifyDTO.NotifyType.NEWDIARY);
notifyService.saveNotifyTable(partnerID, receiverID, NotifyDTO.NotifyType.NEWDIARY);
matchingHistoryService.addHistory(receiverID, partnerID);

result.put("diaryID", diaryID.toString());
Expand All @@ -101,6 +100,16 @@ public Map<String, Object> unknownMatchingAdd(@Valid @RequestBody MatchingDTO.ne

Map<String, Object> result = matchingService.saveMatchingSearch(newMatching, Long.parseLong(authentication.getName()));

if ((boolean) result.get("state")) {

Long receiverID = (Long)result.get("memberID");
Long partnerID = (Long)result.get("partnerID");

emitterService.sendEvents(receiverID, partnerID, NotifyDTO.NotifyType.NEWDIARY);
emitterService.sendEvents(partnerID, receiverID, NotifyDTO.NotifyType.NEWDIARY);
notifyService.saveNotifyTable(receiverID, partnerID, NotifyDTO.NotifyType.NEWDIARY);
}

return result;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class NotifyServiceImpl implements NotifyService{
private final ModelMapper modelMapper;

public void saveNotifyTable(Long receiverID, Long senderID, NotifyDTO.NotifyType type){

NotifyDTO receiverNotifyDTO = NotifyDTO.builder()
.notifyType(type)
.updatedAt(LocalDateTime.now())
Expand All @@ -28,6 +29,17 @@ public void saveNotifyTable(Long receiverID, Long senderID, NotifyDTO.NotifyType
//log.info(receiverNotifyDTO);
Notify receiverNotify = modelMapper.map(receiverNotifyDTO, Notify.class);
notifyRepository.save(receiverNotify);

if(type == NotifyDTO.NotifyType.NEWDIARY || type == NotifyDTO.NotifyType.INACTIVATE){
NotifyDTO senderNotifyDTO = NotifyDTO.builder()
.notifyType(type)
.updatedAt(LocalDateTime.now())
.receiverID(senderID)
.senderID(receiverID)
.build();
Notify senderNotify = modelMapper.map(senderNotifyDTO, Notify.class);
notifyRepository.save(senderNotify);
}
}

public void removeNotify(Long notifyID){
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spring:
show-sql: true

profiles:
active: local
active: prod

logging:
level:
Expand Down

0 comments on commit 2ccd080

Please sign in to comment.