-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
122 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/com/moing/backend/domain/team/application/service/SendTeamAlarmUserCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.moing.backend.domain.team.application.service; | ||
|
||
import com.moing.backend.domain.teamMember.domain.service.TeamMemberGetService; | ||
import com.moing.backend.global.config.fcm.dto.request.MultiRequest; | ||
import com.moing.backend.global.config.fcm.service.FcmService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import javax.transaction.Transactional; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import static com.moing.backend.global.config.fcm.constant.NewUploadTitle.UPLOAD_NOTICE_NEW_TITLE; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class SendTeamAlarmUserCase { | ||
private final TeamMemberGetService teamMemberGetService; | ||
private final FcmService fcmService; | ||
|
||
public void sendApprovalAlarm(Long teamId) { | ||
//TODO: 승인, 반려 문구 constant로 | ||
String title = "소모임 승인 안내"; | ||
String message = "소모임이 승인되었습니다."; | ||
sendAlarm(teamId, title, message); | ||
} | ||
|
||
public void sendRejectionAlarm(Long teamId) { | ||
String title = "소모임 반려 안내"; | ||
String message = "소모임이 반려되었습니다."; | ||
sendAlarm(teamId, title, message); | ||
} | ||
|
||
private void sendAlarm(Long teamId, String title, String message) { | ||
Optional<List<String>> fcmTokens = teamMemberGetService.getFcmTokens(teamId); | ||
if(fcmTokens.isPresent() && !fcmTokens.get().isEmpty()) { | ||
MultiRequest toMultiRequest = new MultiRequest(fcmTokens.get(), title, message); | ||
fcmService.sendMultipleDevices(toMultiRequest); | ||
} | ||
} | ||
} | ||
|
33 changes: 30 additions & 3 deletions
33
src/main/java/com/moing/backend/domain/team/presentation/AdminTeamController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,45 @@ | ||
package com.moing.backend.domain.team.presentation; | ||
|
||
import com.moing.backend.domain.team.application.service.CreateTeamUserCase; | ||
import com.moing.backend.domain.team.application.service.SendTeamAlarmUserCase; | ||
import com.moing.backend.global.response.SuccessResponse; | ||
import lombok.AllArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import static com.moing.backend.domain.team.presentation.constant.TeamResponseMessage.*; | ||
|
||
@RestController | ||
@AllArgsConstructor | ||
@RequestMapping("/api/admin/team") | ||
public class AdminTeamController { | ||
|
||
//TODO 소모임 승인, 반려하기 | ||
|
||
private final CreateTeamUserCase createTeamService; | ||
private final SendTeamAlarmUserCase sendTeamAlarmUserCase; | ||
|
||
/** | ||
* 소모임 승인 알림 보내기 | ||
* [POST] api/admin/team/approval/{teamId} | ||
* 작성자 : 김민수 | ||
*/ | ||
|
||
@PostMapping("/approval/{teamId}") | ||
public ResponseEntity<SuccessResponse> sendApproveAlarm(@PathVariable Long teamId) { | ||
this.sendTeamAlarmUserCase.sendApprovalAlarm(teamId); | ||
return ResponseEntity.ok(SuccessResponse.create(SEND_APPROVAL_ALARM_SUCCESS.getMessage())); | ||
} | ||
|
||
/** | ||
* 소모임 반려 알림 보내기 | ||
* [POST] api/admin/team/rejection/{teamId} | ||
* 작성자: 김민수 | ||
*/ | ||
@PostMapping("/rejection/{teamId}") | ||
public ResponseEntity<SuccessResponse> sendRejectionAlarm(@PathVariable Long teamId){ | ||
this.sendTeamAlarmUserCase.sendRejectionAlarm(teamId); | ||
return ResponseEntity.ok(SuccessResponse.create(SEND_REJECTION_ALARM_SUCCESS.getMessage())); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters