From 1a87c66f804e94dd44678aa31d9e675be1fd2c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=20=EC=8A=B9=20=EC=97=B0?= <53565255+seungyeonnnnnni@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:17:48 +0900 Subject: [PATCH 01/21] =?UTF-8?q?fix=20:=20=EB=AA=A8=EB=93=A0=20score=20?= =?UTF-8?q?=EA=B0=92=20100=20=EB=84=98=EC=A7=80=20=EC=95=8A=EB=8F=84?= =?UTF-8?q?=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teamScore/application/service/TeamScoreGetUseCase.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/com/moing/backend/domain/teamScore/application/service/TeamScoreGetUseCase.java b/src/main/java/com/moing/backend/domain/teamScore/application/service/TeamScoreGetUseCase.java index a51f4026..16206b9c 100644 --- a/src/main/java/com/moing/backend/domain/teamScore/application/service/TeamScoreGetUseCase.java +++ b/src/main/java/com/moing/backend/domain/teamScore/application/service/TeamScoreGetUseCase.java @@ -30,13 +30,9 @@ public TeamScoreRes getTeamScoreInfo(Long teamId) { Long level = teamScore.getLevel(); Long score = teamScore.getScore(); - // 70 레벨 이상은 경험치 120 되어야 레벨업 가능. level을 각 레벨 별 필요한 경험치 수에 따르 퍼센트로 계산 - if (level > 70) { - score = ( score / 120 ) * 100; - } return TeamScoreRes.builder() - .score(score) + .score(score%100) .level(level) .build(); From 67b954fb8cebf0aaadcf25ffe37188a54b83ad6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=20=EC=8A=B9=20=EC=97=B0?= <53565255+seungyeonnnnnni@users.noreply.github.com> Date: Tue, 7 May 2024 09:10:20 +0900 Subject: [PATCH 02/21] =?UTF-8?q?fix=20:=20=EB=AF=B8=EC=85=98=20=EC=9D=B8?= =?UTF-8?q?=EC=A6=9D=20=EC=8B=9C=20commentNum=20=EB=94=94=ED=8F=B4?= =?UTF-8?q?=ED=8A=B8=EA=B0=92=20=EC=A7=80=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../missionArchive/application/mapper/MissionArchiveMapper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/moing/backend/domain/missionArchive/application/mapper/MissionArchiveMapper.java b/src/main/java/com/moing/backend/domain/missionArchive/application/mapper/MissionArchiveMapper.java index 7dc09888..d9c4f86e 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/application/mapper/MissionArchiveMapper.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/application/mapper/MissionArchiveMapper.java @@ -29,6 +29,7 @@ public static MissionArchive mapToMissionArchive(MissionArchiveReq missionArchiv .mission(mission) .heartList(new ArrayList<>()) .contents(missionArchiveReq.getContents()) + .commentNum(0L) .build(); } From 99a592729bd4cdbfd58aa005346b67b9312c8db1 Mon Sep 17 00:00:00 2001 From: seungueonn Date: Sun, 23 Jun 2024 18:18:23 +0900 Subject: [PATCH 03/21] =?UTF-8?q?MNG-25=20feat=20:=20=EB=B6=88=EB=8D=98?= =?UTF-8?q?=EC=A7=80=EA=B8=B0=20=ED=91=B8=EC=8B=9C=EC=95=8C=EB=A6=BC=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=B6=94=EA=B0=80=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=A5=B8=20entity=20=EC=B9=BC=EB=9F=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/moing/backend/domain/fire/domain/entity/Fire.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/moing/backend/domain/fire/domain/entity/Fire.java b/src/main/java/com/moing/backend/domain/fire/domain/entity/Fire.java index 9b32a630..d4f2cbf9 100644 --- a/src/main/java/com/moing/backend/domain/fire/domain/entity/Fire.java +++ b/src/main/java/com/moing/backend/domain/fire/domain/entity/Fire.java @@ -25,4 +25,7 @@ public class Fire extends BaseTimeEntity { private Long receiveMemberId; + @Column(nullable = true, columnDefinition="TEXT", length = 100) + private String message; + } From 444580ac866f45d4893fb4c6eae51d7df04a4fed Mon Sep 17 00:00:00 2001 From: seungueonn Date: Sun, 23 Jun 2024 18:18:56 +0900 Subject: [PATCH 04/21] =?UTF-8?q?MNG-25=20feat=20:=20=EB=B6=88=EB=8D=98?= =?UTF-8?q?=EC=A7=80=EA=B8=B0=20=ED=91=B8=EC=8B=9C=EC=95=8C=EB=A6=BC=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=B6=94=EA=B0=80=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/req/FireThrowReq.java | 19 +++++++++++++++ .../service/FireThrowAlarmUseCase.java | 23 +++++++++++-------- .../application/service/FireThrowUseCase.java | 13 +++++++---- .../fire/presentation/FireController.java | 5 ++-- .../config/fcm/constant/FireThrowMessage.java | 16 ++++++++++--- .../representation/FireControllerTest.java | 11 ++++++++- 6 files changed, 67 insertions(+), 20 deletions(-) create mode 100644 src/main/java/com/moing/backend/domain/fire/application/dto/req/FireThrowReq.java diff --git a/src/main/java/com/moing/backend/domain/fire/application/dto/req/FireThrowReq.java b/src/main/java/com/moing/backend/domain/fire/application/dto/req/FireThrowReq.java new file mode 100644 index 00000000..b0845e15 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/fire/application/dto/req/FireThrowReq.java @@ -0,0 +1,19 @@ +package com.moing.backend.domain.fire.application.dto.req; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import javax.annotation.Nullable; + + +@AllArgsConstructor +@Builder +@NoArgsConstructor +@Getter +public class FireThrowReq { + + @Nullable + private String message; +} diff --git a/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowAlarmUseCase.java b/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowAlarmUseCase.java index ca28e88a..4955176a 100644 --- a/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowAlarmUseCase.java @@ -24,28 +24,31 @@ public class FireThrowAlarmUseCase { private final ApplicationEventPublisher eventPublisher; - public void sendFireThrowAlarm(Member throwMember, Member receiveMember, Team team, Mission mission) { + public void sendFireThrowAlarm(Member throwMember, Member receiveMember, Team team, Mission mission, String message) { - Random random = new Random(System.currentTimeMillis()); - int randomNum = random.nextInt(2); + int randomNum = new Random(System.currentTimeMillis()).nextInt(2); - String title = getTitle(throwMember.getNickName(), receiveMember.getNickName(), randomNum); - String message = getMessage(throwMember.getNickName(), receiveMember.getNickName(), randomNum); + String title = message != null ? NEW_FIRE_THROW_TITLE_WITH_COMMENT.to(throwMember.getNickName()) + : getRandomTitle(throwMember.getNickName(), receiveMember.getNickName(), randomNum); + message = message != null ? message + : getRandomMessage(throwMember.getNickName(), receiveMember.getNickName(), randomNum); String idInfo = createIdInfo(mission.getType() == MissionType.REPEAT, mission.getTeam().getTeamId(), mission.getId()); eventPublisher.publishEvent(new SingleFcmEvent(receiveMember, title, message, idInfo, team.getName(), AlarmType.FIRE, MISSION_PATH.getValue(), receiveMember.isFirePush())); } - public String getMessage(String pusher, String receiver, int num) { + public String getRandomMessage(String pusher, String receiver, int num) { switch (num) { - case 0: return pusher + "님이 " + receiver + NEW_FIRE_THROW_MESSAGE1.getMessage(); - case 1: return receiver + "님! " + pusher + NEW_FIRE_THROW_MESSAGE2.getMessage(); + case 0: + return NEW_FIRE_THROW_MESSAGE1.fromTo(pusher, receiver); + case 1: return NEW_FIRE_THROW_MESSAGE2.toFrom(receiver, pusher); + } - return pusher + "님이" + receiver + NEW_FIRE_THROW_MESSAGE1.getMessage(); + return NEW_FIRE_THROW_MESSAGE1.fromTo(pusher, receiver); } - public String getTitle(String pusher, String receiver, int num) { + public String getRandomTitle(String pusher, String receiver, int num) { switch (num) { case 0: diff --git a/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowUseCase.java b/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowUseCase.java index 7fd5015b..fc1b0501 100644 --- a/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowUseCase.java +++ b/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowUseCase.java @@ -1,5 +1,6 @@ package com.moing.backend.domain.fire.application.service; +import com.moing.backend.domain.fire.application.dto.req.FireThrowReq; import com.moing.backend.domain.fire.application.dto.res.FireReceiveRes; import com.moing.backend.domain.fire.application.dto.res.FireThrowRes; import com.moing.backend.domain.fire.application.mapper.FireMapper; @@ -19,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.List; +import java.util.Optional; @Service @Transactional @@ -33,7 +35,7 @@ public class FireThrowUseCase { private final MissionQueryService missionQueryService; private final TeamGetService teamGetService; - public FireThrowRes createFireThrow(String userId, Long receiveMemberId, Long missionId, Long teamId) { + public FireThrowRes createFireThrow(String userId, Long receiveMemberId, Long missionId, Long teamId, FireThrowReq fireThrowReq) { Member throwMember = memberGetService.getMemberBySocialId(userId); Member receiveMember = memberGetService.getMemberByMemberId(receiveMemberId); @@ -50,12 +52,15 @@ public FireThrowRes createFireThrow(String userId, Long receiveMemberId, Long mi throw new NoAuthThrowFireException(); } - fireThrowAlarmUseCase.sendFireThrowAlarm(throwMember, receiveMember, team, mission); + fireThrowAlarmUseCase.sendFireThrowAlarm(throwMember, receiveMember, team, mission, fireThrowReq.getMessage()); - return FireMapper.mapToFireThrowRes(fireSaveService.save(Fire.builder() + Fire save = fireSaveService.save(Fire.builder() .throwMemberId(throwMember.getMemberId()) .receiveMemberId(receiveMemberId) - .build())); + .message(fireThrowReq.getMessage()) + .build()); + + return FireMapper.mapToFireThrowRes(fireSaveService.save(save)); } public List getFireReceiveList(String userId,Long teamId, Long missionId) { diff --git a/src/main/java/com/moing/backend/domain/fire/presentation/FireController.java b/src/main/java/com/moing/backend/domain/fire/presentation/FireController.java index 5de8aa94..576a705f 100644 --- a/src/main/java/com/moing/backend/domain/fire/presentation/FireController.java +++ b/src/main/java/com/moing/backend/domain/fire/presentation/FireController.java @@ -1,5 +1,6 @@ package com.moing.backend.domain.fire.presentation; +import com.moing.backend.domain.fire.application.dto.req.FireThrowReq; import com.moing.backend.domain.fire.application.dto.res.FireReceiveRes; import com.moing.backend.domain.fire.application.dto.res.FireThrowRes; import com.moing.backend.domain.fire.application.service.FireThrowUseCase; @@ -30,8 +31,8 @@ public class FireController { @PostMapping("/{receiveMemberId}") public ResponseEntity> throwFire (@AuthenticationPrincipal User user, @PathVariable("teamId") Long teamId, - @PathVariable("receiveMemberId") Long receiveMemberId, @PathVariable("missionId") Long missionId) { - return ResponseEntity.ok(SuccessResponse.create(THROW_FIRE_SUCCESS.getMessage(), this.fireThrowUseCase.createFireThrow(user.getSocialId(), receiveMemberId, missionId, teamId))); + @PathVariable("receiveMemberId") Long receiveMemberId, @PathVariable("missionId") Long missionId, @RequestBody FireThrowReq fireThrowReq) { + return ResponseEntity.ok(SuccessResponse.create(THROW_FIRE_SUCCESS.getMessage(), this.fireThrowUseCase.createFireThrow(user.getSocialId(), receiveMemberId, missionId, teamId, fireThrowReq))); } /** diff --git a/src/main/java/com/moing/backend/global/config/fcm/constant/FireThrowMessage.java b/src/main/java/com/moing/backend/global/config/fcm/constant/FireThrowMessage.java index dbfb2f79..ef720ec8 100644 --- a/src/main/java/com/moing/backend/global/config/fcm/constant/FireThrowMessage.java +++ b/src/main/java/com/moing/backend/global/config/fcm/constant/FireThrowMessage.java @@ -10,14 +10,24 @@ public enum FireThrowMessage { NEW_FIRE_THROW_TITLE1("어라… 왜 이렇게 발등이 뜨겁지?\uD83E\uDD28"), NEW_FIRE_THROW_TITLE2("⚠\uFE0F불조심⚠\uFE0F "), + NEW_FIRE_THROW_TITLE_WITH_COMMENT("%s님이 불을 던졌어요!"), - NEW_FIRE_THROW_MESSAGE1("님에게 불을 던졌어요! 어서 미션을 인증해볼까요?"), - NEW_FIRE_THROW_MESSAGE2("님이 던진 불에 타버릴지도 몰라요! 어서 인증하러갈까요?"); - + NEW_FIRE_THROW_MESSAGE1("%s님이 %s님에게 불을 던졌어요! 어서 미션을 인증해볼까요?"), + NEW_FIRE_THROW_MESSAGE2("%s님! %s님이 던진 불에 타버릴지도 몰라요! 어서 인증하러갈까요?"); private final String message; + public String to(String pusher) { + return String.format(message, pusher); + } + public String fromTo(String pusher,String receiver) { + return String.format(message, pusher,receiver); + } + public String toFrom(String receiver,String pusher) { + return String.format(message, receiver,pusher); + } + } diff --git a/src/test/java/com/moing/backend/domain/fire/representation/FireControllerTest.java b/src/test/java/com/moing/backend/domain/fire/representation/FireControllerTest.java index 0cdd119b..c7d78bb6 100644 --- a/src/test/java/com/moing/backend/domain/fire/representation/FireControllerTest.java +++ b/src/test/java/com/moing/backend/domain/fire/representation/FireControllerTest.java @@ -1,10 +1,12 @@ package com.moing.backend.domain.fire.representation; import com.moing.backend.config.CommonControllerTest; +import com.moing.backend.domain.fire.application.dto.req.FireThrowReq; import com.moing.backend.domain.fire.application.dto.res.FireReceiveRes; import com.moing.backend.domain.fire.application.dto.res.FireThrowRes; import com.moing.backend.domain.fire.application.service.FireThrowUseCase; import com.moing.backend.domain.fire.presentation.FireController; +import com.moing.backend.domain.missionArchive.application.dto.req.MissionArchiveReq; import org.assertj.core.util.Lists; import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -89,11 +91,17 @@ public class FireControllerTest extends CommonControllerTest { public void 불_던지기() throws Exception { //given + FireThrowReq input = FireThrowReq.builder() + .message("message") + .build(); + + String body = objectMapper.writeValueAsString(input); + FireThrowRes output = FireThrowRes.builder() .receiveMemberId(1L) .build(); - given(fireThrowUseCase.createFireThrow(any(), any(), any(), any())).willReturn(output); + given(fireThrowUseCase.createFireThrow(any(), any(), any(), any(),any())).willReturn(output); Long teamId = 2L; Long missionId = 2L; @@ -103,6 +111,7 @@ public class FireControllerTest extends CommonControllerTest { post("/api/team/{teamId}/missions/{missionId}/fire/{receiveMemberId}",teamId,missionId,receiveMemberId) .header("Authorization", "Bearer ACCESS_TOKEN") .contentType(MediaType.APPLICATION_JSON) + .content(body) ); //then From e43d564ff7e923df80c3a33913f547f86b6e22ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=20=EC=8A=B9=20=EC=97=B0?= <53565255+seungyeonnnnnni@users.noreply.github.com> Date: Mon, 1 Jul 2024 09:15:15 +0900 Subject: [PATCH 05/21] =?UTF-8?q?feat=20:=20=EB=B6=88=20=EB=8D=98=EC=A7=80?= =?UTF-8?q?=EA=B8=B0=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=A0=80=EC=9E=A5=20?= =?UTF-8?q?=EC=95=88=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fire/application/service/FireThrowAlarmUseCase.java | 7 ++++--- .../domain/fire/application/service/FireThrowUseCase.java | 3 +-- .../com/moing/backend/domain/fire/domain/entity/Fire.java | 4 ++-- .../backend/domain/fire/presentation/FireController.java | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowAlarmUseCase.java b/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowAlarmUseCase.java index 4955176a..ba2c35c4 100644 --- a/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowAlarmUseCase.java @@ -1,5 +1,6 @@ package com.moing.backend.domain.fire.application.service; +import com.moing.backend.domain.fire.application.dto.req.FireThrowReq; import com.moing.backend.domain.history.domain.entity.AlarmType; import com.moing.backend.domain.member.domain.entity.Member; import com.moing.backend.domain.mission.domain.entity.Mission; @@ -24,13 +25,13 @@ public class FireThrowAlarmUseCase { private final ApplicationEventPublisher eventPublisher; - public void sendFireThrowAlarm(Member throwMember, Member receiveMember, Team team, Mission mission, String message) { + public void sendFireThrowAlarm(Member throwMember, Member receiveMember, Team team, Mission mission, FireThrowReq fireThrowReq) { int randomNum = new Random(System.currentTimeMillis()).nextInt(2); - String title = message != null ? NEW_FIRE_THROW_TITLE_WITH_COMMENT.to(throwMember.getNickName()) + String title = fireThrowReq != null ? NEW_FIRE_THROW_TITLE_WITH_COMMENT.to(throwMember.getNickName()) : getRandomTitle(throwMember.getNickName(), receiveMember.getNickName(), randomNum); - message = message != null ? message + String message = fireThrowReq != null ? fireThrowReq.getMessage() : getRandomMessage(throwMember.getNickName(), receiveMember.getNickName(), randomNum); String idInfo = createIdInfo(mission.getType() == MissionType.REPEAT, mission.getTeam().getTeamId(), mission.getId()); diff --git a/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowUseCase.java b/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowUseCase.java index fc1b0501..494a1c0d 100644 --- a/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowUseCase.java +++ b/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowUseCase.java @@ -52,12 +52,11 @@ public FireThrowRes createFireThrow(String userId, Long receiveMemberId, Long mi throw new NoAuthThrowFireException(); } - fireThrowAlarmUseCase.sendFireThrowAlarm(throwMember, receiveMember, team, mission, fireThrowReq.getMessage()); + fireThrowAlarmUseCase.sendFireThrowAlarm(throwMember, receiveMember, team, mission, fireThrowReq); Fire save = fireSaveService.save(Fire.builder() .throwMemberId(throwMember.getMemberId()) .receiveMemberId(receiveMemberId) - .message(fireThrowReq.getMessage()) .build()); return FireMapper.mapToFireThrowRes(fireSaveService.save(save)); diff --git a/src/main/java/com/moing/backend/domain/fire/domain/entity/Fire.java b/src/main/java/com/moing/backend/domain/fire/domain/entity/Fire.java index d4f2cbf9..11a7ec74 100644 --- a/src/main/java/com/moing/backend/domain/fire/domain/entity/Fire.java +++ b/src/main/java/com/moing/backend/domain/fire/domain/entity/Fire.java @@ -25,7 +25,7 @@ public class Fire extends BaseTimeEntity { private Long receiveMemberId; - @Column(nullable = true, columnDefinition="TEXT", length = 100) - private String message; +// @Column(nullable = true, columnDefinition="TEXT", length = 100) +// private String message; } diff --git a/src/main/java/com/moing/backend/domain/fire/presentation/FireController.java b/src/main/java/com/moing/backend/domain/fire/presentation/FireController.java index 576a705f..76eb46a5 100644 --- a/src/main/java/com/moing/backend/domain/fire/presentation/FireController.java +++ b/src/main/java/com/moing/backend/domain/fire/presentation/FireController.java @@ -31,7 +31,7 @@ public class FireController { @PostMapping("/{receiveMemberId}") public ResponseEntity> throwFire (@AuthenticationPrincipal User user, @PathVariable("teamId") Long teamId, - @PathVariable("receiveMemberId") Long receiveMemberId, @PathVariable("missionId") Long missionId, @RequestBody FireThrowReq fireThrowReq) { + @PathVariable("receiveMemberId") Long receiveMemberId, @PathVariable("missionId") Long missionId, @RequestBody(required = false) FireThrowReq fireThrowReq) { return ResponseEntity.ok(SuccessResponse.create(THROW_FIRE_SUCCESS.getMessage(), this.fireThrowUseCase.createFireThrow(user.getSocialId(), receiveMemberId, missionId, teamId, fireThrowReq))); } From c13f83c589d344c6e784216b78a20a9ceb490861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=20=EC=8A=B9=20=EC=97=B0?= <53565255+seungyeonnnnnni@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:06:03 +0900 Subject: [PATCH 06/21] =?UTF-8?q?MNG-25=20fix=20:=20=EB=B6=88=20=EB=8D=98?= =?UTF-8?q?=EC=A7=80=EA=B8=B0=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=EC=95=88=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/moing/backend/domain/fire/domain/entity/Fire.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/moing/backend/domain/fire/domain/entity/Fire.java b/src/main/java/com/moing/backend/domain/fire/domain/entity/Fire.java index 11a7ec74..8d6fe05c 100644 --- a/src/main/java/com/moing/backend/domain/fire/domain/entity/Fire.java +++ b/src/main/java/com/moing/backend/domain/fire/domain/entity/Fire.java @@ -15,7 +15,6 @@ @AllArgsConstructor public class Fire extends BaseTimeEntity { - @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "fire_id") @@ -25,7 +24,4 @@ public class Fire extends BaseTimeEntity { private Long receiveMemberId; -// @Column(nullable = true, columnDefinition="TEXT", length = 100) -// private String message; - } From b1f3679db8afcbc940ac483bbc6227fab47a0633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=20=EC=8A=B9=20=EC=97=B0?= <53565255+seungyeonnnnnni@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:56:24 +0900 Subject: [PATCH 07/21] =?UTF-8?q?MNG-26=20feat=20:=20=EB=AF=B8=EC=85=98=20?= =?UTF-8?q?=EC=9D=B8=EC=A6=9D=20=EC=8B=9C=20=ED=91=B8=EC=8B=9C=20=EC=95=8C?= =?UTF-8?q?=EB=A6=BC=20=EC=A0=84=EC=86=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MissionArchiveCreateMessage.java | 22 +++++++ .../service/MissionArchiveCreateUseCase.java | 10 ++- .../SendMissionArchiveCreateAlarmUseCase.java | 62 +++++++++++++++++++ 3 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveCreateMessage.java create mode 100644 src/main/java/com/moing/backend/domain/missionArchive/application/service/SendMissionArchiveCreateAlarmUseCase.java diff --git a/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveCreateMessage.java b/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveCreateMessage.java new file mode 100644 index 00000000..bb3564b9 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveCreateMessage.java @@ -0,0 +1,22 @@ +package com.moing.backend.domain.missionArchive.application.service; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum MissionArchiveCreateMessage { + + CREATOR_CREATE_MISSION_ARCHIVE("%s님이 미션을 인증했어요!"), + TEAM_AND_TITLE("[%s] %s"); + + private final String message; + + public String to(String creator) { + return String.format(message, creator); + } + + public String teamAndTitle(String team, String title) { + return String.format(message, team, title); + } +} diff --git a/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveCreateUseCase.java b/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveCreateUseCase.java index 618a02c7..2979b706 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveCreateUseCase.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveCreateUseCase.java @@ -34,6 +34,8 @@ public class MissionArchiveCreateUseCase { private final TeamScoreUpdateUseCase teamScoreUpdateUseCase; + private final SendMissionArchiveCreateAlarmUseCase sendMissionArchiveCreateAlarmUseCase; + public MissionArchiveRes createArchive(String userSocialId, Long missionId, MissionArchiveReq missionReq) { Member member = memberGetService.getMemberBySocialId(userSocialId); @@ -59,7 +61,6 @@ public MissionArchiveRes createArchive(String userSocialId, Long missionId, Miss newArchive.updateCount(missionArchiveQueryService.findMyDoneArchives(memberId, missionId) + 1); missionArchiveRes = MissionArchiveMapper.mapToMissionArchiveRes(missionArchiveSaveService.save(newArchive), memberId); - } // 한번 미션일 경우 @@ -78,13 +79,16 @@ public MissionArchiveRes createArchive(String userSocialId, Long missionId, Miss missionArchiveRes.updateCount(doneSingleArchives); } - // TODO : 소모임원 3명 이상일 경우 보너스 점수 + // 소모임원 3명 이상일 경우 보너스 점수 if (mission.getTeam().getNumOfMember() > 2) { gainBonusScore(mission, newArchive); } - // TODO : 미션 인증 1회당 점수 + // 미션 인증 1회당 점수 teamScoreUpdateUseCase.gainScoreOfArchive(mission, ScoreStatus.PLUS); + // 미션 인증 시 다른 팀원에게 알림 전송 + sendMissionArchiveCreateAlarmUseCase.sendNewMissionArchiveUploadAlarm(member,mission); + return missionArchiveRes; } diff --git a/src/main/java/com/moing/backend/domain/missionArchive/application/service/SendMissionArchiveCreateAlarmUseCase.java b/src/main/java/com/moing/backend/domain/missionArchive/application/service/SendMissionArchiveCreateAlarmUseCase.java new file mode 100644 index 00000000..dd553da3 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionArchive/application/service/SendMissionArchiveCreateAlarmUseCase.java @@ -0,0 +1,62 @@ +package com.moing.backend.domain.missionArchive.application.service; + +import com.moing.backend.domain.history.application.dto.response.MemberIdAndToken; +import com.moing.backend.domain.history.application.dto.response.NewUploadInfo; +import com.moing.backend.domain.history.application.mapper.AlarmHistoryMapper; +import com.moing.backend.domain.history.domain.entity.AlarmType; +import com.moing.backend.domain.history.domain.entity.PagePath; +import com.moing.backend.domain.member.domain.entity.Member; +import com.moing.backend.domain.mission.domain.entity.Mission; +import com.moing.backend.domain.mission.domain.entity.constant.MissionStatus; +import com.moing.backend.domain.mission.domain.entity.constant.MissionType; +import com.moing.backend.domain.team.domain.entity.Team; +import com.moing.backend.domain.teamMember.domain.service.TeamMemberGetService; +import com.moing.backend.global.config.fcm.dto.event.MultiFcmEvent; +import lombok.RequiredArgsConstructor; +import net.minidev.json.JSONObject; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Service; + +import javax.transaction.Transactional; +import java.util.List; +import java.util.Optional; + +import static com.moing.backend.domain.missionArchive.application.service.MissionArchiveCreateMessage.CREATOR_CREATE_MISSION_ARCHIVE; +import static com.moing.backend.domain.missionArchive.application.service.MissionArchiveCreateMessage.TEAM_AND_TITLE; +import static com.moing.backend.global.config.fcm.constant.NewMissionTitle.NEW_SINGLE_MISSION_COMING; + +@Service +@Transactional +@RequiredArgsConstructor +public class SendMissionArchiveCreateAlarmUseCase { + + private final TeamMemberGetService teamMemberGetService; + private final ApplicationEventPublisher eventPublisher; + + public void sendNewMissionArchiveUploadAlarm(Member member, Mission mission) { + Team team = mission.getTeam(); + + String title = CREATOR_CREATE_MISSION_ARCHIVE.to(member.getNickName()); + String message = TEAM_AND_TITLE.teamAndTitle(team.getName(),mission.getTitle()); + + String type = mission.getType().toString(); + String status = mission.getStatus().toString(); + + Optional> newUploadInfos=teamMemberGetService.getNewUploadInfo(team.getTeamId(), member.getMemberId()); + + Optional> memberIdAndTokensByPush = AlarmHistoryMapper.getNewUploadPushInfo(newUploadInfos); + Optional> memberIdAndTokensBySave = AlarmHistoryMapper.getNewUploadSaveInfo(newUploadInfos); + // 알림 보내기 + eventPublisher.publishEvent(new MultiFcmEvent(title, message, memberIdAndTokensByPush, memberIdAndTokensBySave, createIdInfo(team.getTeamId(), mission.getId(),mission.getType(),mission.getStatus()), team.getName(), AlarmType.NEW_UPLOAD, PagePath.MISSION_PATH.getValue())); + } + + private String createIdInfo(Long teamId, Long missionId,MissionType type, MissionStatus status) { + JSONObject jo = new JSONObject(); + jo.put("isRepeated", type.equals(MissionType.REPEAT)); + jo.put("teamId", teamId); + jo.put("missionId", missionId); + jo.put("status", status.name()); + return jo.toJSONString(); + } +} + From 228836c79ce48183310dfd163d6a12cbb9fb323e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=20=EC=8A=B9=20=EC=97=B0?= <53565255+seungyeonnnnnni@users.noreply.github.com> Date: Tue, 2 Jul 2024 08:34:11 +0900 Subject: [PATCH 08/21] =?UTF-8?q?MNG-26=20fix=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=ED=95=84=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/SendMissionArchiveCreateAlarmUseCase.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/moing/backend/domain/missionArchive/application/service/SendMissionArchiveCreateAlarmUseCase.java b/src/main/java/com/moing/backend/domain/missionArchive/application/service/SendMissionArchiveCreateAlarmUseCase.java index dd553da3..303ccc6b 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/application/service/SendMissionArchiveCreateAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/application/service/SendMissionArchiveCreateAlarmUseCase.java @@ -39,8 +39,6 @@ public void sendNewMissionArchiveUploadAlarm(Member member, Mission mission) { String title = CREATOR_CREATE_MISSION_ARCHIVE.to(member.getNickName()); String message = TEAM_AND_TITLE.teamAndTitle(team.getName(),mission.getTitle()); - String type = mission.getType().toString(); - String status = mission.getStatus().toString(); Optional> newUploadInfos=teamMemberGetService.getNewUploadInfo(team.getTeamId(), member.getMemberId()); From 77ead00985e8fc5d300e6d70c02b706a4460d8da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=20=EC=8A=B9=20=EC=97=B0?= <53565255+seungyeonnnnnni@users.noreply.github.com> Date: Tue, 2 Jul 2024 09:23:22 +0900 Subject: [PATCH 09/21] =?UTF-8?q?MNG-25=20feat=20:=20=EB=B6=88=EB=8D=98?= =?UTF-8?q?=EC=A7=80=EA=B8=B0=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20API=20=EB=AC=B8=EC=84=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/fire/application/dto/req/FireThrowReq.java | 9 +++++---- .../domain/fire/representation/FireControllerTest.java | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/moing/backend/domain/fire/application/dto/req/FireThrowReq.java b/src/main/java/com/moing/backend/domain/fire/application/dto/req/FireThrowReq.java index b0845e15..c668da02 100644 --- a/src/main/java/com/moing/backend/domain/fire/application/dto/req/FireThrowReq.java +++ b/src/main/java/com/moing/backend/domain/fire/application/dto/req/FireThrowReq.java @@ -7,13 +7,14 @@ import javax.annotation.Nullable; - -@AllArgsConstructor -@Builder @NoArgsConstructor @Getter public class FireThrowReq { - @Nullable private String message; + + @Builder + public FireThrowReq(String message) { + this.message = message; + } } diff --git a/src/test/java/com/moing/backend/domain/fire/representation/FireControllerTest.java b/src/test/java/com/moing/backend/domain/fire/representation/FireControllerTest.java index c7d78bb6..d87a66c4 100644 --- a/src/test/java/com/moing/backend/domain/fire/representation/FireControllerTest.java +++ b/src/test/java/com/moing/backend/domain/fire/representation/FireControllerTest.java @@ -24,8 +24,7 @@ import static org.mockito.BDDMockito.given; import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName; import static org.springframework.restdocs.headers.HeaderDocumentation.requestHeaders; -import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.restdocs.payload.PayloadDocumentation.*; import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; @@ -92,7 +91,7 @@ public class FireControllerTest extends CommonControllerTest { //given FireThrowReq input = FireThrowReq.builder() - .message("message") + .message("불던지기 메시지. 메시지가 없는경우 DTO 자체를 전송하지 않음") .build(); String body = objectMapper.writeValueAsString(input); @@ -122,12 +121,14 @@ public class FireControllerTest extends CommonControllerTest { requestHeaders( headerWithName("Authorization").description("접근 토큰") ), + requestFields( + fieldWithPath("message").description("불던지기 메시지. 메시지가 없는경우 DTO 자체를 전송하지 않음") + ), pathParameters( parameterWithName("teamId").description("팀 아이디"), parameterWithName("missionId").description("미션 아이디"), parameterWithName("receiveMemberId").description("불 받을 사람 아이디") ), - responseFields( fieldWithPath("isSuccess").description("true"), fieldWithPath("message").description(THROW_FIRE_SUCCESS.getMessage()), From 852b2a8c3cf38d4d3752c400078ef088c78b67e7 Mon Sep 17 00:00:00 2001 From: seungueonn Date: Sun, 7 Jul 2024 16:09:59 +0900 Subject: [PATCH 10/21] =?UTF-8?q?MNG-25=20chore=20:=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC(logs/)=20gitignore=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 03d183bf..850b9ca6 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,4 @@ data.sql firebase-key.json apple-key.p8 +logs/ \ No newline at end of file From 5f62c3fb486d3c1f77c92f9aca0c40491e0cfcf9 Mon Sep 17 00:00:00 2001 From: seungueonn Date: Sun, 7 Jul 2024 16:24:42 +0900 Subject: [PATCH 11/21] =?UTF-8?q?MNG-25=20chore=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20import=20=EC=82=AD=EC=A0=9C=20=EB=B0=8F=20?= =?UTF-8?q?field=20=EC=88=9C=EC=84=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/fire/application/dto/req/FireThrowReq.java | 3 --- .../domain/fire/representation/FireControllerTest.java | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/moing/backend/domain/fire/application/dto/req/FireThrowReq.java b/src/main/java/com/moing/backend/domain/fire/application/dto/req/FireThrowReq.java index c668da02..34907e1b 100644 --- a/src/main/java/com/moing/backend/domain/fire/application/dto/req/FireThrowReq.java +++ b/src/main/java/com/moing/backend/domain/fire/application/dto/req/FireThrowReq.java @@ -1,12 +1,9 @@ package com.moing.backend.domain.fire.application.dto.req; -import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import javax.annotation.Nullable; - @NoArgsConstructor @Getter public class FireThrowReq { diff --git a/src/test/java/com/moing/backend/domain/fire/representation/FireControllerTest.java b/src/test/java/com/moing/backend/domain/fire/representation/FireControllerTest.java index d87a66c4..1ee71150 100644 --- a/src/test/java/com/moing/backend/domain/fire/representation/FireControllerTest.java +++ b/src/test/java/com/moing/backend/domain/fire/representation/FireControllerTest.java @@ -121,14 +121,14 @@ public class FireControllerTest extends CommonControllerTest { requestHeaders( headerWithName("Authorization").description("접근 토큰") ), - requestFields( - fieldWithPath("message").description("불던지기 메시지. 메시지가 없는경우 DTO 자체를 전송하지 않음") - ), pathParameters( parameterWithName("teamId").description("팀 아이디"), parameterWithName("missionId").description("미션 아이디"), parameterWithName("receiveMemberId").description("불 받을 사람 아이디") ), + requestFields( + fieldWithPath("message").description("불던지기 메시지. 메시지가 없는경우 DTO 자체를 전송하지 않음") + ), responseFields( fieldWithPath("isSuccess").description("true"), fieldWithPath("message").description(THROW_FIRE_SUCCESS.getMessage()), From f1de5a67943a2b12b0d2fdfb28090819c144c8df Mon Sep 17 00:00:00 2001 From: minsu20 Date: Wed, 10 Jul 2024 22:40:59 +0900 Subject: [PATCH 12/21] =?UTF-8?q?MNG-28=20feat:=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=EC=97=90=20isCommentPush=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/domain/history/domain/entity/AlarmType.java | 3 ++- .../moing/backend/domain/member/domain/entity/Member.java | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/moing/backend/domain/history/domain/entity/AlarmType.java b/src/main/java/com/moing/backend/domain/history/domain/entity/AlarmType.java index fbf7fd58..e29851bf 100644 --- a/src/main/java/com/moing/backend/domain/history/domain/entity/AlarmType.java +++ b/src/main/java/com/moing/backend/domain/history/domain/entity/AlarmType.java @@ -8,5 +8,6 @@ public enum AlarmType { FIRE, REMIND, APPROVE_TEAM, - REJECT_TEAM + REJECT_TEAM, + COMMENT } diff --git a/src/main/java/com/moing/backend/domain/member/domain/entity/Member.java b/src/main/java/com/moing/backend/domain/member/domain/entity/Member.java index d13b5886..c06c7af6 100644 --- a/src/main/java/com/moing/backend/domain/member/domain/entity/Member.java +++ b/src/main/java/com/moing/backend/domain/member/domain/entity/Member.java @@ -79,6 +79,10 @@ public class Member extends BaseTimeEntity { @Column(nullable = false) private boolean isFirePush; + @ColumnDefault("true") + @Column(nullable = false) + private boolean isCommentPush; + private boolean isDeleted; private LocalDateTime lastSignInTime; @@ -140,6 +144,10 @@ public void updateFirePush(boolean firePush) { this.isFirePush = firePush; } + public void updateCommentPush(boolean commentPush){ + this.isCommentPush=commentPush; + } + public void updateAllPush(boolean allPush) { this.isNewUploadPush = allPush; this.isRemindPush = allPush; From 563950691db475841c2cd7ee6e1b3a39f270633a Mon Sep 17 00:00:00 2001 From: minsu20 Date: Wed, 10 Jul 2024 22:44:12 +0900 Subject: [PATCH 13/21] =?UTF-8?q?MNG-28=20feat:=20=EB=AF=B8=EC=85=98=20?= =?UTF-8?q?=EB=8C=93=EA=B8=80=20=EC=83=9D=EC=84=B1=20=EC=8B=9C=20=ED=91=B8?= =?UTF-8?q?=EC=8B=9C=20=EC=95=8C=EB=A6=BC=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/CreateBoardCommentUseCase.java | 4 +- ...java => SendBoardCommentAlarmUseCase.java} | 8 +- .../BoardCommentCustomRepositoryImpl.java | 2 +- .../service/CreateMissionCommentUseCase.java | 7 +- .../service/SendMissionAlarmUseCase.java | 4 - .../SendMissionCommentAlarmUseCase.java | 92 +++++++++++++++++++ .../MissionCommentCustomRepositoryImpl.java | 2 +- .../dto/response/GetAlarmResponse.java | 2 +- .../application/service/AlarmUseCase.java | 6 +- .../mypage/presentation/MyPageController.java | 2 +- .../presentation/MypageControllerTest.java | 9 +- 11 files changed, 116 insertions(+), 22 deletions(-) rename src/main/java/com/moing/backend/domain/boardComment/application/service/{SendCommentAlarmUseCase.java => SendBoardCommentAlarmUseCase.java} (93%) delete mode 100644 src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionAlarmUseCase.java create mode 100644 src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java diff --git a/src/main/java/com/moing/backend/domain/boardComment/application/service/CreateBoardCommentUseCase.java b/src/main/java/com/moing/backend/domain/boardComment/application/service/CreateBoardCommentUseCase.java index ffac8705..47fb22f0 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/application/service/CreateBoardCommentUseCase.java +++ b/src/main/java/com/moing/backend/domain/boardComment/application/service/CreateBoardCommentUseCase.java @@ -21,7 +21,7 @@ public class CreateBoardCommentUseCase { private final BoardCommentSaveService boardCommentSaveService; private final BaseBoardService baseBoardService; private final CheckLeaderUseCase checkLeaderUseCase; - private final SendCommentAlarmUseCase sendCommentAlarmUseCase; + private final SendBoardCommentAlarmUseCase sendCommentAlarm; /** * 게시글 댓글 생성 */ @@ -33,7 +33,7 @@ public CreateCommentResponse createBoardComment(String socialId, Long teamId, Lo // 2. 게시글 댓글 개수 증가 data.getBoard().incrComNum(); // 3. 게시글 댓글 알림 - sendCommentAlarmUseCase.sendNewUploadAlarm(data, boardComment); + sendCommentAlarm.sendCommentAlarm(data, boardComment); return new CreateCommentResponse(boardComment.getBoardCommentId()); } } diff --git a/src/main/java/com/moing/backend/domain/boardComment/application/service/SendCommentAlarmUseCase.java b/src/main/java/com/moing/backend/domain/boardComment/application/service/SendBoardCommentAlarmUseCase.java similarity index 93% rename from src/main/java/com/moing/backend/domain/boardComment/application/service/SendCommentAlarmUseCase.java rename to src/main/java/com/moing/backend/domain/boardComment/application/service/SendBoardCommentAlarmUseCase.java index 84d1078a..42db80ac 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/application/service/SendCommentAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/boardComment/application/service/SendBoardCommentAlarmUseCase.java @@ -28,12 +28,12 @@ @Service @RequiredArgsConstructor @Transactional -public class SendCommentAlarmUseCase { +public class SendBoardCommentAlarmUseCase { private final ApplicationEventPublisher eventPublisher; private final BoardCommentGetService boardCommentGetService; - public void sendNewUploadAlarm(BaseBoardServiceResponse response, BoardComment comment) { + public void sendCommentAlarm(BaseBoardServiceResponse response, BoardComment comment) { Member member = response.getMember(); Team team = response.getTeam(); Board board = response.getBoard(); @@ -50,7 +50,7 @@ private void sendBoardWriter(Board board, Member member, String title, String bo Member receiver = board.getTeamMember().getMember(); if (checkBoardWriter(receiver, member, newUploadInfos)) { - eventPublisher.publishEvent(new SingleFcmEvent(receiver, title, body, createIdInfo(team.getTeamId(), board.getBoardId()), team.getName(), AlarmType.NEW_UPLOAD, PagePath.NOTICE_PATH.getValue(), receiver.isNewUploadPush())); + eventPublisher.publishEvent(new SingleFcmEvent(receiver, title, body, createIdInfo(team.getTeamId(), board.getBoardId()), team.getName(), AlarmType.COMMENT, PagePath.NOTICE_PATH.getValue(), receiver.isCommentPush())); } } @@ -58,7 +58,7 @@ private void sendBoardCommentWriter(Board board, Member member, String title, St Optional> memberIdAndTokensByPush = AlarmHistoryMapper.getNewUploadPushInfo(newUploadInfos); Optional> memberIdAndTokensBySave = AlarmHistoryMapper.getNewUploadSaveInfo(newUploadInfos); - eventPublisher.publishEvent(new MultiFcmEvent(title, body, memberIdAndTokensByPush, memberIdAndTokensBySave, createIdInfo(team.getTeamId(), board.getBoardId()), team.getName(), AlarmType.NEW_UPLOAD, PagePath.NOTICE_PATH.getValue())); + eventPublisher.publishEvent(new MultiFcmEvent(title, body, memberIdAndTokensByPush, memberIdAndTokensBySave, createIdInfo(team.getTeamId(), board.getBoardId()), team.getName(), AlarmType.COMMENT, PagePath.NOTICE_PATH.getValue())); } private String createIdInfo(Long teamId, Long boardId) { diff --git a/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentCustomRepositoryImpl.java b/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentCustomRepositoryImpl.java index 413f4203..9ac674c3 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentCustomRepositoryImpl.java +++ b/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentCustomRepositoryImpl.java @@ -69,7 +69,7 @@ public Optional> findNewUploadInfo(Long memberId, Long board List result = queryFactory.select(Projections.constructor(NewUploadInfo.class, boardComment.teamMember.member.fcmToken, boardComment.teamMember.member.memberId, - boardComment.teamMember.member.isNewUploadPush, + boardComment.teamMember.member.isCommentPush, boardComment.teamMember.member.isSignOut)) .distinct() .from(boardComment) diff --git a/src/main/java/com/moing/backend/domain/missionComment/application/service/CreateMissionCommentUseCase.java b/src/main/java/com/moing/backend/domain/missionComment/application/service/CreateMissionCommentUseCase.java index 54a0ef10..7e2a2bbc 100644 --- a/src/main/java/com/moing/backend/domain/missionComment/application/service/CreateMissionCommentUseCase.java +++ b/src/main/java/com/moing/backend/domain/missionComment/application/service/CreateMissionCommentUseCase.java @@ -1,6 +1,5 @@ package com.moing.backend.domain.missionComment.application.service; -import com.moing.backend.domain.boardComment.application.service.SendCommentAlarmUseCase; import com.moing.backend.domain.comment.application.dto.request.CreateCommentRequest; import com.moing.backend.domain.comment.application.dto.response.CreateCommentResponse; import com.moing.backend.domain.missionComment.application.mapper.MissionCommentMapper; @@ -22,7 +21,7 @@ public class CreateMissionCommentUseCase { private final MissionCommentSaveService missionCommentSaveService; private final BaseMissionService baseMissionService; private final CheckLeaderUseCase checkLeaderUseCase; - private final SendCommentAlarmUseCase sendCommentAlarmUseCase; + private final SendMissionCommentAlarmUseCase sendCommentAlarm; /** * 게시글 댓글 생성 */ @@ -33,8 +32,8 @@ public CreateCommentResponse createBoardComment(String socialId, Long teamId, Lo MissionComment missionComment = missionCommentSaveService.saveComment(MissionCommentMapper.toMissionComment(data.getTeamMember(), data.getMissionArchive(), createCommentRequest, isLeader)); // 2. 미션 게시글 댓글 개수 증가 data.getMissionArchive().incrComNum(); -// // 3. 미션 게시글 댓글 알림 -// sendCommentAlarmUseCase.sendNewUploadAlarm(data, missionComment); + // 3. 미션 게시글 댓글 알림 + sendCommentAlarm.sendCommentAlarm(data, missionComment); return new CreateCommentResponse(missionComment.getMissionCommentId()); } } diff --git a/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionAlarmUseCase.java b/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionAlarmUseCase.java deleted file mode 100644 index ced7594c..00000000 --- a/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionAlarmUseCase.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.moing.backend.domain.missionComment.application.service; - -public class SendMissionAlarmUseCase { -} diff --git a/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java b/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java new file mode 100644 index 00000000..5f5adadb --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java @@ -0,0 +1,92 @@ +package com.moing.backend.domain.missionComment.application.service; + +import com.moing.backend.domain.history.application.dto.response.MemberIdAndToken; +import com.moing.backend.domain.history.application.dto.response.NewUploadInfo; +import com.moing.backend.domain.history.application.mapper.AlarmHistoryMapper; +import com.moing.backend.domain.history.domain.entity.AlarmType; +import com.moing.backend.domain.history.domain.entity.PagePath; +import com.moing.backend.domain.member.domain.entity.Member; +import com.moing.backend.domain.mission.domain.entity.Mission; +import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive; +import com.moing.backend.domain.missionComment.domain.entity.MissionComment; +import com.moing.backend.domain.missionComment.domain.service.MissionCommentGetService; +import com.moing.backend.domain.team.domain.entity.Team; +import com.moing.backend.global.config.fcm.dto.event.MultiFcmEvent; +import com.moing.backend.global.config.fcm.dto.event.SingleFcmEvent; +import com.moing.backend.global.response.BaseMissionServiceResponse; +import lombok.RequiredArgsConstructor; +import net.minidev.json.JSONObject; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Service; + +import javax.transaction.Transactional; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +import static com.moing.backend.global.config.fcm.constant.NewCommentUploadMessage.NEW_COMMENT_UPLOAD_MESSAGE; + +@Service +@RequiredArgsConstructor +@Transactional +public class SendMissionCommentAlarmUseCase { + + private final ApplicationEventPublisher eventPublisher; + private final MissionCommentGetService missionCommentGetService; + + public void sendCommentAlarm(BaseMissionServiceResponse response, MissionComment comment) { + Member member = response.getMember(); + Team team = response.getTeam(); + MissionArchive missionArchive = response.getMissionArchive(); + Mission mission = missionArchive.getMission(); + + Optional> newUploadInfos = missionCommentGetService.getNewUploadInfo(member.getMemberId(), missionArchive.getId()); + String title = NEW_COMMENT_UPLOAD_MESSAGE.title(comment.getContent()); + String body = NEW_COMMENT_UPLOAD_MESSAGE.body(member.getNickName(), mission.getTitle()); + + sendMissionCommentWriter(mission, missionArchive, title, body, team, newUploadInfos); + sendMissionWriter(missionArchive, mission, member, title, body, team, newUploadInfos); + } + + + private void sendMissionWriter(MissionArchive missionArchive, Mission mission, + Member member, String title, String body, Team team, + Optional> newUploadInfos) { + Member receiver = missionArchive.getMember(); + if (checkMemberWriter(receiver, member, newUploadInfos)) { + eventPublisher.publishEvent(new SingleFcmEvent(receiver, title, body, createIdInfo(team.getTeamId(), mission.getId(), missionArchive.getId()), team.getName(), AlarmType.COMMENT, PagePath.NOTICE_PATH.getValue(), receiver.isCommentPush())); + } + } + + private void sendMissionCommentWriter(Mission mission, MissionArchive missionArchive, + String title, String body, Team team, + Optional> newUploadInfos) { + Optional> memberIdAndTokensByPush = AlarmHistoryMapper.getNewUploadPushInfo(newUploadInfos); + Optional> memberIdAndTokensBySave = AlarmHistoryMapper.getNewUploadSaveInfo(newUploadInfos); + + eventPublisher.publishEvent(new MultiFcmEvent(title, body, memberIdAndTokensByPush, memberIdAndTokensBySave, createIdInfo(team.getTeamId(), mission.getId(), missionArchive.getId()), team.getName(), AlarmType.COMMENT, PagePath.MISSION_PATH.getValue())); + } + + + private boolean checkMemberWriter(Member missionWriter, Member commentWriter, Optional> newUploadInfos) { + // 댓글 작성자와 미션 게시글 작성자가 동일한 경우 알림을 보내지 않는다. + if (Objects.equals(missionWriter.getMemberId(), commentWriter.getMemberId())) { + return false; + } + + // newUploadInfos 리스트에 missionWriter memberId가 없는 경우만 알림을 보낸다. + // 리스트가 비어있거나, missionWriter의 memberId가 리스트에 없으면 true를 반환. + return newUploadInfos + .map(infos -> infos.stream().noneMatch(info -> info.getMemberId().equals(missionWriter.getMemberId()))) + .orElse(true); + } + + + private String createIdInfo(Long teamId, Long missionId, Long missionArchiveId) { + JSONObject jo = new JSONObject(); + jo.put("missionArchiveId", missionArchiveId); + jo.put("teamId", teamId); + jo.put("missionId", missionId); + return jo.toJSONString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/moing/backend/domain/missionComment/domain/repository/MissionCommentCustomRepositoryImpl.java b/src/main/java/com/moing/backend/domain/missionComment/domain/repository/MissionCommentCustomRepositoryImpl.java index aecacdad..9e295ee7 100644 --- a/src/main/java/com/moing/backend/domain/missionComment/domain/repository/MissionCommentCustomRepositoryImpl.java +++ b/src/main/java/com/moing/backend/domain/missionComment/domain/repository/MissionCommentCustomRepositoryImpl.java @@ -69,7 +69,7 @@ public Optional> findNewUploadInfo(Long memberId, Long missi List result = queryFactory.select(Projections.constructor(NewUploadInfo.class, missionComment.teamMember.member.fcmToken, missionComment.teamMember.member.memberId, - missionComment.teamMember.member.isNewUploadPush, + missionComment.teamMember.member.isCommentPush, missionComment.teamMember.member.isSignOut)) .distinct() .from(missionComment) diff --git a/src/main/java/com/moing/backend/domain/mypage/application/dto/response/GetAlarmResponse.java b/src/main/java/com/moing/backend/domain/mypage/application/dto/response/GetAlarmResponse.java index 8d7e602c..9e858a34 100644 --- a/src/main/java/com/moing/backend/domain/mypage/application/dto/response/GetAlarmResponse.java +++ b/src/main/java/com/moing/backend/domain/mypage/application/dto/response/GetAlarmResponse.java @@ -4,7 +4,6 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import org.hibernate.annotations.ColumnDefault; @Builder @AllArgsConstructor @@ -15,4 +14,5 @@ public class GetAlarmResponse { private boolean isNewUploadPush; private boolean isRemindPush; private boolean isFirePush; + private boolean isCommentPush; } diff --git a/src/main/java/com/moing/backend/domain/mypage/application/service/AlarmUseCase.java b/src/main/java/com/moing/backend/domain/mypage/application/service/AlarmUseCase.java index e632e679..5d7c7e78 100644 --- a/src/main/java/com/moing/backend/domain/mypage/application/service/AlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/mypage/application/service/AlarmUseCase.java @@ -17,7 +17,7 @@ public class AlarmUseCase { @Transactional(readOnly = true) public GetAlarmResponse getAlarm(String socialId){ Member member=memberGetService.getMemberBySocialId(socialId); - return new GetAlarmResponse(member.isNewUploadPush(),member.isRemindPush(), member.isFirePush()); + return new GetAlarmResponse(member.isNewUploadPush(),member.isRemindPush(), member.isFirePush(), member.isCommentPush()); } @Transactional @@ -38,9 +38,11 @@ public GetAlarmResponse updateAlarm(String socialId, String type, String status) case "isFirePush": member.updateFirePush(push); break; + case "isCommentPush": + member.updateCommentPush(push); default: throw new AlarmInvalidException(); } - return new GetAlarmResponse(member.isNewUploadPush(),member.isRemindPush(), member.isFirePush()); + return new GetAlarmResponse(member.isNewUploadPush(),member.isRemindPush(), member.isFirePush(), member.isCommentPush()); } } diff --git a/src/main/java/com/moing/backend/domain/mypage/presentation/MyPageController.java b/src/main/java/com/moing/backend/domain/mypage/presentation/MyPageController.java index bea13408..f03563aa 100644 --- a/src/main/java/com/moing/backend/domain/mypage/presentation/MyPageController.java +++ b/src/main/java/com/moing/backend/domain/mypage/presentation/MyPageController.java @@ -107,7 +107,7 @@ public ResponseEntity> getAlarm(@Authenticatio /** * 알림정보 수정 - * [POST] api/mypage/alarm?type=all || isNewUploadPush || isRemindPush || isFirePush && status= on || off + * [POST] api/mypage/alarm?type=all || isNewUploadPush || isRemindPush || isFirePush || isCommentPush && status= on || off */ @PutMapping("/alarm") public ResponseEntity> updateAlarm(@AuthenticationPrincipal User user, diff --git a/src/test/java/com/moing/backend/domain/mypage/presentation/MypageControllerTest.java b/src/test/java/com/moing/backend/domain/mypage/presentation/MypageControllerTest.java index f4d06b55..d2ea767c 100644 --- a/src/test/java/com/moing/backend/domain/mypage/presentation/MypageControllerTest.java +++ b/src/test/java/com/moing/backend/domain/mypage/presentation/MypageControllerTest.java @@ -257,6 +257,7 @@ public void get_alarm() throws Exception { .isNewUploadPush(true) .isFirePush(true) .isRemindPush(true) + .isCommentPush(true) .build(); given(alarmUseCase.getAlarm(any())).willReturn(output); @@ -282,7 +283,8 @@ public void get_alarm() throws Exception { fieldWithPath("message").description("알람 정보를 조회했습니다"), fieldWithPath("data.newUploadPush").description("신규 공지 알림"), fieldWithPath("data.remindPush").description("미션 리마인드 알림"), - fieldWithPath("data.firePush").description("불 던지기 알림") + fieldWithPath("data.firePush").description("불 던지기 알림"), + fieldWithPath("data.commentPush").description("댓글 알림") ) ) ); @@ -295,6 +297,7 @@ public void update_alarm() throws Exception { .isNewUploadPush(true) .isFirePush(true) .isRemindPush(true) + .isCommentPush(true) .build(); given(alarmUseCase.updateAlarm(any(),any(),any())).willReturn(output); @@ -326,7 +329,9 @@ public void update_alarm() throws Exception { fieldWithPath("message").description("알람 정보를 수정했습니다"), fieldWithPath("data.newUploadPush").description("신규 공지 알림"), fieldWithPath("data.remindPush").description("미션 리마인드 알림"), - fieldWithPath("data.firePush").description("불 던지기 알림") + fieldWithPath("data.firePush").description("불 던지기 알림"), + fieldWithPath("data.commentPush").description("댓글 알림") + ) ) ); From 4a3950e0cf4efa81f4f76238f838ec9c37c7e699 Mon Sep 17 00:00:00 2001 From: minsu20 Date: Wed, 10 Jul 2024 22:44:44 +0900 Subject: [PATCH 14/21] =?UTF-8?q?MNG-28=20docs:=20=EB=8C=93=EA=B8=80=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EC=95=8C=EB=A6=BC=20Category=EC=97=90=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/AlarmHistory-API.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/docs/asciidoc/AlarmHistory-API.adoc b/src/docs/asciidoc/AlarmHistory-API.adoc index 5c31a28d..c3ee6871 100644 --- a/src/docs/asciidoc/AlarmHistory-API.adoc +++ b/src/docs/asciidoc/AlarmHistory-API.adoc @@ -24,6 +24,8 @@ operation::alarm-history-controller-test/get_all_alarm_history[snippets='http-re | `REJECT_TEAM` | 소모임 반려 +| `COMMENT` +| 댓글 생성 알림 |=== [[AlarmHistory-알림-단건-조회하기]] From ba7b49b8fd29f99e1c633dbdf5b00ca6e4ee0222 Mon Sep 17 00:00:00 2001 From: minsu20 Date: Mon, 22 Jul 2024 21:42:46 +0900 Subject: [PATCH 15/21] =?UTF-8?q?MNG-28=20fix:=20missionComment=20path=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/service/SendMissionCommentAlarmUseCase.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java b/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java index 5f5adadb..d25facf4 100644 --- a/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java @@ -47,18 +47,16 @@ public void sendCommentAlarm(BaseMissionServiceResponse response, MissionComment sendMissionCommentWriter(mission, missionArchive, title, body, team, newUploadInfos); sendMissionWriter(missionArchive, mission, member, title, body, team, newUploadInfos); } - - private void sendMissionWriter(MissionArchive missionArchive, Mission mission, Member member, String title, String body, Team team, Optional> newUploadInfos) { Member receiver = missionArchive.getMember(); if (checkMemberWriter(receiver, member, newUploadInfos)) { - eventPublisher.publishEvent(new SingleFcmEvent(receiver, title, body, createIdInfo(team.getTeamId(), mission.getId(), missionArchive.getId()), team.getName(), AlarmType.COMMENT, PagePath.NOTICE_PATH.getValue(), receiver.isCommentPush())); + eventPublisher.publishEvent(new SingleFcmEvent(receiver, title, body, createIdInfo(team.getTeamId(), mission.getId(), missionArchive.getId()), team.getName(), AlarmType.COMMENT, PagePath.MISSION_PATH.getValue(), receiver.isCommentPush())); } } - private void sendMissionCommentWriter(Mission mission, MissionArchive missionArchive, + private void sendMissionCommentWriter(Mission mission, MissionArchive missionArchive/ String title, String body, Team team, Optional> newUploadInfos) { Optional> memberIdAndTokensByPush = AlarmHistoryMapper.getNewUploadPushInfo(newUploadInfos); From e0dc9e0af6047b90021e0a61e1ca2c4450e848b9 Mon Sep 17 00:00:00 2001 From: minsu20 Date: Mon, 22 Jul 2024 21:45:27 +0900 Subject: [PATCH 16/21] =?UTF-8?q?MNG-28=20fix:=20=EC=98=A4=ED=83=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/service/SendMissionCommentAlarmUseCase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java b/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java index d25facf4..7a14209b 100644 --- a/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java @@ -56,7 +56,7 @@ private void sendMissionWriter(MissionArchive missionArchive, Mission mission, } } - private void sendMissionCommentWriter(Mission mission, MissionArchive missionArchive/ + private void sendMissionCommentWriter(Mission mission, MissionArchive missionArchive, String title, String body, Team team, Optional> newUploadInfos) { Optional> memberIdAndTokensByPush = AlarmHistoryMapper.getNewUploadPushInfo(newUploadInfos); From 9b3a08125703628390b9d661511f834d82d30045 Mon Sep 17 00:00:00 2001 From: minsu20 Date: Fri, 9 Aug 2024 13:38:18 +0900 Subject: [PATCH 17/21] =?UTF-8?q?MNG-28=20feat:=20=ED=91=B8=EC=8B=9C=20?= =?UTF-8?q?=EC=95=8C=EB=A6=BC=20=EB=B3=B4=EB=82=BC=20=EB=96=BC=20idInfo?= =?UTF-8?q?=EC=97=90=20type=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../board/application/service/SendBoardAlarmUseCase.java | 5 +++-- .../application/service/SendBoardCommentAlarmUseCase.java | 1 + .../fire/application/service/FireThrowAlarmUseCase.java | 5 +++-- .../application/service/SendMissionCreateAlarmUseCase.java | 5 +++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/moing/backend/domain/board/application/service/SendBoardAlarmUseCase.java b/src/main/java/com/moing/backend/domain/board/application/service/SendBoardAlarmUseCase.java index 3ed5f384..edb57a8c 100644 --- a/src/main/java/com/moing/backend/domain/board/application/service/SendBoardAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/board/application/service/SendBoardAlarmUseCase.java @@ -4,7 +4,6 @@ import com.moing.backend.domain.history.application.dto.response.MemberIdAndToken; import com.moing.backend.domain.history.application.dto.response.NewUploadInfo; import com.moing.backend.domain.history.application.mapper.AlarmHistoryMapper; -import com.moing.backend.domain.history.domain.entity.AlarmType; import com.moing.backend.domain.history.domain.entity.PagePath; import com.moing.backend.domain.member.domain.entity.Member; import com.moing.backend.domain.team.domain.entity.Team; @@ -20,6 +19,7 @@ import java.util.List; import java.util.Optional; +import static com.moing.backend.domain.history.domain.entity.AlarmType.NEW_UPLOAD; import static com.moing.backend.global.config.fcm.constant.NewNoticeUploadMessage.NEW_NOTICE_UPLOAD_MESSAGE; @Service @@ -41,7 +41,7 @@ public void sendNewUploadAlarm(BaseServiceResponse baseServiceResponse, Board bo Optional> memberIdAndTokensByPush = AlarmHistoryMapper.getNewUploadPushInfo(newUploadInfos); Optional> memberIdAndTokensBySave = AlarmHistoryMapper.getNewUploadSaveInfo(newUploadInfos); // 알림 보내기 - eventPublisher.publishEvent(new MultiFcmEvent(title, body, memberIdAndTokensByPush, memberIdAndTokensBySave, createIdInfo(team.getTeamId(), board.getBoardId()), team.getName(), AlarmType.NEW_UPLOAD, PagePath.NOTICE_PATH.getValue())); + eventPublisher.publishEvent(new MultiFcmEvent(title, body, memberIdAndTokensByPush, memberIdAndTokensBySave, createIdInfo(team.getTeamId(), board.getBoardId()), team.getName(), NEW_UPLOAD, PagePath.NOTICE_PATH.getValue())); } } @@ -49,6 +49,7 @@ private String createIdInfo(Long teamId, Long boardId) { JSONObject jo = new JSONObject(); jo.put("teamId", teamId); jo.put("boardId", boardId); + jo.put("type", "NEW_UPLOAD_BOARD"); return jo.toJSONString(); } diff --git a/src/main/java/com/moing/backend/domain/boardComment/application/service/SendBoardCommentAlarmUseCase.java b/src/main/java/com/moing/backend/domain/boardComment/application/service/SendBoardCommentAlarmUseCase.java index 42db80ac..974060ed 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/application/service/SendBoardCommentAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/boardComment/application/service/SendBoardCommentAlarmUseCase.java @@ -65,6 +65,7 @@ private String createIdInfo(Long teamId, Long boardId) { JSONObject jo = new JSONObject(); jo.put("teamId", teamId); jo.put("boardId", boardId); + jo.put("type", "COMMENT"); return jo.toJSONString(); } diff --git a/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowAlarmUseCase.java b/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowAlarmUseCase.java index ba2c35c4..b2451d61 100644 --- a/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowAlarmUseCase.java @@ -1,7 +1,6 @@ package com.moing.backend.domain.fire.application.service; import com.moing.backend.domain.fire.application.dto.req.FireThrowReq; -import com.moing.backend.domain.history.domain.entity.AlarmType; import com.moing.backend.domain.member.domain.entity.Member; import com.moing.backend.domain.mission.domain.entity.Mission; import com.moing.backend.domain.mission.domain.entity.constant.MissionType; @@ -15,6 +14,7 @@ import javax.transaction.Transactional; import java.util.Random; +import static com.moing.backend.domain.history.domain.entity.AlarmType.FIRE; import static com.moing.backend.domain.history.domain.entity.PagePath.MISSION_PATH; import static com.moing.backend.global.config.fcm.constant.FireThrowMessage.*; @@ -35,7 +35,7 @@ public void sendFireThrowAlarm(Member throwMember, Member receiveMember, Team te : getRandomMessage(throwMember.getNickName(), receiveMember.getNickName(), randomNum); String idInfo = createIdInfo(mission.getType() == MissionType.REPEAT, mission.getTeam().getTeamId(), mission.getId()); - eventPublisher.publishEvent(new SingleFcmEvent(receiveMember, title, message, idInfo, team.getName(), AlarmType.FIRE, MISSION_PATH.getValue(), receiveMember.isFirePush())); + eventPublisher.publishEvent(new SingleFcmEvent(receiveMember, title, message, idInfo, team.getName(), FIRE, MISSION_PATH.getValue(), receiveMember.isFirePush())); } public String getRandomMessage(String pusher, String receiver, int num) { @@ -65,6 +65,7 @@ private String createIdInfo(boolean isRepeated, Long teamId, Long missionId) { jo.put("isRepeated", isRepeated); jo.put("teamId", teamId); jo.put("missionId", missionId); + jo.put("type", "FIRE"); return jo.toJSONString(); } diff --git a/src/main/java/com/moing/backend/domain/mission/application/service/SendMissionCreateAlarmUseCase.java b/src/main/java/com/moing/backend/domain/mission/application/service/SendMissionCreateAlarmUseCase.java index aabe793f..029f5420 100644 --- a/src/main/java/com/moing/backend/domain/mission/application/service/SendMissionCreateAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/mission/application/service/SendMissionCreateAlarmUseCase.java @@ -3,7 +3,6 @@ import com.moing.backend.domain.history.application.dto.response.MemberIdAndToken; import com.moing.backend.domain.history.application.dto.response.NewUploadInfo; import com.moing.backend.domain.history.application.mapper.AlarmHistoryMapper; -import com.moing.backend.domain.history.domain.entity.AlarmType; import com.moing.backend.domain.history.domain.entity.PagePath; import com.moing.backend.domain.member.domain.entity.Member; import com.moing.backend.domain.mission.domain.entity.Mission; @@ -21,6 +20,7 @@ import java.util.List; import java.util.Optional; +import static com.moing.backend.domain.history.domain.entity.AlarmType.NEW_UPLOAD; import static com.moing.backend.global.config.fcm.constant.NewMissionTitle.NEW_SINGLE_MISSION_COMING; @Service @@ -43,7 +43,7 @@ public void sendNewMissionUploadAlarm(Member member, Mission mission) { Optional> memberIdAndTokensByPush = AlarmHistoryMapper.getNewUploadPushInfo(newUploadInfos); Optional> memberIdAndTokensBySave = AlarmHistoryMapper.getNewUploadSaveInfo(newUploadInfos); // 알림 보내기 - eventPublisher.publishEvent(new MultiFcmEvent(title, message, memberIdAndTokensByPush, memberIdAndTokensBySave, createIdInfo(team.getTeamId(), mission.getId(),mission.getType(),mission.getStatus()), team.getName(), AlarmType.NEW_UPLOAD, PagePath.MISSION_PATH.getValue())); + eventPublisher.publishEvent(new MultiFcmEvent(title, message, memberIdAndTokensByPush, memberIdAndTokensBySave, createIdInfo(team.getTeamId(), mission.getId(),mission.getType(),mission.getStatus()), team.getName(), NEW_UPLOAD, PagePath.MISSION_PATH.getValue())); } private String createIdInfo(Long teamId, Long missionId,MissionType type, MissionStatus status) { @@ -52,6 +52,7 @@ private String createIdInfo(Long teamId, Long missionId,MissionType type, Missio jo.put("teamId", teamId); jo.put("missionId", missionId); jo.put("status", status.name()); + jo.put("type", "NEW_UPLOAD_MISSION"); return jo.toJSONString(); } } From df1681e22b0bbf3c7b7c4bdbf8bc59ae27b19714 Mon Sep 17 00:00:00 2001 From: minsu20 Date: Fri, 9 Aug 2024 17:19:17 +0900 Subject: [PATCH 18/21] =?UTF-8?q?fix:=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=EC=8B=9C=20=EB=AF=B8=EC=85=98=EB=8C=93=EA=B8=80=20?= =?UTF-8?q?=EC=95=8C=EB=A6=BC=20=EC=97=AC=EB=B6=80=20true=EB=A1=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/moing/backend/domain/member/domain/entity/Member.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/moing/backend/domain/member/domain/entity/Member.java b/src/main/java/com/moing/backend/domain/member/domain/entity/Member.java index c06c7af6..206847e1 100644 --- a/src/main/java/com/moing/backend/domain/member/domain/entity/Member.java +++ b/src/main/java/com/moing/backend/domain/member/domain/entity/Member.java @@ -152,6 +152,7 @@ public void updateAllPush(boolean allPush) { this.isNewUploadPush = allPush; this.isRemindPush = allPush; this.isFirePush = allPush; + this.isCommentPush=allPush; } public void updateFcmToken(String fcmToken) { From 446e9aa69bc6442e1de6eb20a8124b689cdda062 Mon Sep 17 00:00:00 2001 From: minsu20 Date: Sun, 11 Aug 2024 21:58:16 +0900 Subject: [PATCH 19/21] =?UTF-8?q?MNG-28=20feat:=20=ED=91=B8=EC=8B=9C?= =?UTF-8?q?=EC=95=8C=EB=A6=BC=20=EB=B3=B4=EB=82=BC=20=EB=95=8C=20idInfo?= =?UTF-8?q?=EC=97=90=20tyep=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/SendBoardCommentAlarmUseCase.java | 2 +- .../application/service/FireThrowAlarmUseCase.java | 12 +++++++++--- .../SendMissionArchiveCreateAlarmUseCase.java | 2 +- .../service/SendMissionCommentAlarmUseCase.java | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/moing/backend/domain/boardComment/application/service/SendBoardCommentAlarmUseCase.java b/src/main/java/com/moing/backend/domain/boardComment/application/service/SendBoardCommentAlarmUseCase.java index 974060ed..7b6ae5e3 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/application/service/SendBoardCommentAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/boardComment/application/service/SendBoardCommentAlarmUseCase.java @@ -65,7 +65,7 @@ private String createIdInfo(Long teamId, Long boardId) { JSONObject jo = new JSONObject(); jo.put("teamId", teamId); jo.put("boardId", boardId); - jo.put("type", "COMMENT"); + jo.put("type", "COMMENT_BOARD"); return jo.toJSONString(); } diff --git a/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowAlarmUseCase.java b/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowAlarmUseCase.java index b2451d61..0566dea0 100644 --- a/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/fire/application/service/FireThrowAlarmUseCase.java @@ -33,7 +33,7 @@ public void sendFireThrowAlarm(Member throwMember, Member receiveMember, Team te : getRandomTitle(throwMember.getNickName(), receiveMember.getNickName(), randomNum); String message = fireThrowReq != null ? fireThrowReq.getMessage() : getRandomMessage(throwMember.getNickName(), receiveMember.getNickName(), randomNum); - String idInfo = createIdInfo(mission.getType() == MissionType.REPEAT, mission.getTeam().getTeamId(), mission.getId()); + String idInfo = createIdInfo(mission.getType() == MissionType.REPEAT, mission.getTeam().getTeamId(), mission.getId(), fireThrowReq == null); eventPublisher.publishEvent(new SingleFcmEvent(receiveMember, title, message, idInfo, team.getName(), FIRE, MISSION_PATH.getValue(), receiveMember.isFirePush())); } @@ -60,14 +60,20 @@ public String getRandomTitle(String pusher, String receiver, int num) { return NEW_FIRE_THROW_TITLE1.getMessage(); } - private String createIdInfo(boolean isRepeated, Long teamId, Long missionId) { + private String createIdInfo(boolean isRepeated, Long teamId, Long missionId, boolean isMessageNull) { JSONObject jo = new JSONObject(); jo.put("isRepeated", isRepeated); jo.put("teamId", teamId); jo.put("missionId", missionId); - jo.put("type", "FIRE"); + jo.put("type", getType(isMessageNull)); return jo.toJSONString(); } + private String getType(boolean isMessageNull){ + if(isMessageNull) + return "FIRE_MESSAGE_NULL"; + return "FIRE_MESSAGE_EXIST"; + } + } diff --git a/src/main/java/com/moing/backend/domain/missionArchive/application/service/SendMissionArchiveCreateAlarmUseCase.java b/src/main/java/com/moing/backend/domain/missionArchive/application/service/SendMissionArchiveCreateAlarmUseCase.java index 303ccc6b..fdba87a2 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/application/service/SendMissionArchiveCreateAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/application/service/SendMissionArchiveCreateAlarmUseCase.java @@ -23,7 +23,6 @@ import static com.moing.backend.domain.missionArchive.application.service.MissionArchiveCreateMessage.CREATOR_CREATE_MISSION_ARCHIVE; import static com.moing.backend.domain.missionArchive.application.service.MissionArchiveCreateMessage.TEAM_AND_TITLE; -import static com.moing.backend.global.config.fcm.constant.NewMissionTitle.NEW_SINGLE_MISSION_COMING; @Service @Transactional @@ -54,6 +53,7 @@ private String createIdInfo(Long teamId, Long missionId,MissionType type, Missio jo.put("teamId", teamId); jo.put("missionId", missionId); jo.put("status", status.name()); + jo.put("type", "COMPLETE_MISSION"); return jo.toJSONString(); } } diff --git a/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java b/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java index 7a14209b..2237fa11 100644 --- a/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java @@ -85,6 +85,7 @@ private String createIdInfo(Long teamId, Long missionId, Long missionArchiveId) jo.put("missionArchiveId", missionArchiveId); jo.put("teamId", teamId); jo.put("missionId", missionId); + jo.put("type", "COMMENT_MISSION"); return jo.toJSONString(); } } \ No newline at end of file From 8e7d9e23e07b2bfd1cfe5d3f439dee12b1e4c7ad Mon Sep 17 00:00:00 2001 From: seungueonn Date: Mon, 2 Sep 2024 22:55:21 +0900 Subject: [PATCH 20/21] =?UTF-8?q?fix/#307:=20=EC=8B=A0=EA=B3=A0=EB=90=9C?= =?UTF-8?q?=20=EC=9D=B8=EC=A6=9D=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20url=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/MissionArchiveCustomRepositoryImpl.java | 3 ++- .../report/presentation/constant/ReportResponseMessage.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveCustomRepositoryImpl.java b/src/main/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveCustomRepositoryImpl.java index 5ef4b1f3..8d751358 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveCustomRepositoryImpl.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveCustomRepositoryImpl.java @@ -329,7 +329,8 @@ public Optional> findTop5ArchivesByTeam(List .where(missionArchive.mission.team.teamId.in(teamIds), missionArchive.mission.way.eq(MissionWay.PHOTO), missionArchive.status.eq(MissionArchiveStatus.COMPLETE), - missionArchive.archive.ne("https://modagbul.s3.ap-northeast-2.amazonaws.com/reportImage.png")) + missionArchive.archive.ne("https://modagbul.s3.ap-northeast-2.amazonaws.com/reportImage.png"), + missionArchive.archive.ne("https://mo-ing.s3.ap-northeast-2.amazonaws.com/reportImage.png")) .orderBy(missionArchive.createdDate.desc()) .limit(14) .fetch(); diff --git a/src/main/java/com/moing/backend/domain/report/presentation/constant/ReportResponseMessage.java b/src/main/java/com/moing/backend/domain/report/presentation/constant/ReportResponseMessage.java index e5d9133a..a7332498 100644 --- a/src/main/java/com/moing/backend/domain/report/presentation/constant/ReportResponseMessage.java +++ b/src/main/java/com/moing/backend/domain/report/presentation/constant/ReportResponseMessage.java @@ -9,7 +9,7 @@ public enum ReportResponseMessage { CREATE_REPORT_SUCCESS("게시글 신고를 완료 했습니다."), REPORT_MESSAGE("신고 접수로 삭제되었습니다."), - REPORT_PHOTO("https://modagbul.s3.ap-northeast-2.amazonaws.com/reportImage.png"); + REPORT_PHOTO("https://mo-ing.s3.ap-northeast-2.amazonaws.com/reportImage.png"); private final String message; From ae59e523717d3bfc8064a286369988af17eea648 Mon Sep 17 00:00:00 2001 From: seungueonn Date: Mon, 2 Sep 2024 22:56:48 +0900 Subject: [PATCH 21/21] =?UTF-8?q?fix/#307:=20/mission/prove=20=EC=97=90=20?= =?UTF-8?q?=ED=95=B4=EB=8B=B9=ED=95=98=EB=8A=94=20idinfo=EC=97=90=20isRepe?= =?UTF-8?q?at=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/SendMissionCommentAlarmUseCase.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java b/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java index 2237fa11..ec809470 100644 --- a/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionCommentAlarmUseCase.java @@ -7,6 +7,7 @@ import com.moing.backend.domain.history.domain.entity.PagePath; import com.moing.backend.domain.member.domain.entity.Member; import com.moing.backend.domain.mission.domain.entity.Mission; +import com.moing.backend.domain.mission.domain.entity.constant.MissionType; import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive; import com.moing.backend.domain.missionComment.domain.entity.MissionComment; import com.moing.backend.domain.missionComment.domain.service.MissionCommentGetService; @@ -52,7 +53,7 @@ private void sendMissionWriter(MissionArchive missionArchive, Mission mission, Optional> newUploadInfos) { Member receiver = missionArchive.getMember(); if (checkMemberWriter(receiver, member, newUploadInfos)) { - eventPublisher.publishEvent(new SingleFcmEvent(receiver, title, body, createIdInfo(team.getTeamId(), mission.getId(), missionArchive.getId()), team.getName(), AlarmType.COMMENT, PagePath.MISSION_PATH.getValue(), receiver.isCommentPush())); + eventPublisher.publishEvent(new SingleFcmEvent(receiver, title, body, createIdInfo(team.getTeamId(), mission.getId(), missionArchive.getId(),mission.getType()), team.getName(), AlarmType.COMMENT, PagePath.MISSION_PATH.getValue(), receiver.isCommentPush())); } } @@ -62,7 +63,7 @@ private void sendMissionCommentWriter(Mission mission, MissionArchive missionArc Optional> memberIdAndTokensByPush = AlarmHistoryMapper.getNewUploadPushInfo(newUploadInfos); Optional> memberIdAndTokensBySave = AlarmHistoryMapper.getNewUploadSaveInfo(newUploadInfos); - eventPublisher.publishEvent(new MultiFcmEvent(title, body, memberIdAndTokensByPush, memberIdAndTokensBySave, createIdInfo(team.getTeamId(), mission.getId(), missionArchive.getId()), team.getName(), AlarmType.COMMENT, PagePath.MISSION_PATH.getValue())); + eventPublisher.publishEvent(new MultiFcmEvent(title, body, memberIdAndTokensByPush, memberIdAndTokensBySave, createIdInfo(team.getTeamId(), mission.getId(), missionArchive.getId(),mission.getType()), team.getName(), AlarmType.COMMENT, PagePath.MISSION_PATH.getValue())); } @@ -80,12 +81,13 @@ private boolean checkMemberWriter(Member missionWriter, Member commentWriter, Op } - private String createIdInfo(Long teamId, Long missionId, Long missionArchiveId) { + private String createIdInfo(Long teamId, Long missionId, Long missionArchiveId, MissionType missionType) { JSONObject jo = new JSONObject(); jo.put("missionArchiveId", missionArchiveId); jo.put("teamId", teamId); jo.put("missionId", missionId); jo.put("type", "COMMENT_MISSION"); + jo.put("isRepeated", missionType.equals(MissionType.REPEAT)); return jo.toJSONString(); } } \ No newline at end of file