-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[요양보호사 / 보호자] Line messaging API를 활용하여 알림 서비스 구현하기 (#42)
* feat : 의존성 추가 * feat : line api 의존성 추가 및 exception 디렉토리 위치 변경 * feat : 웰컴 메시지 및 사용자 입력 메시지 받기 완료!! * feat : 알림 메시지 구현 완료!! * refactor : Stranger 웰컴 메시지 변경 * refactor : 디렉토리 위치 변경 * refactor : 30분 단위도 가능하게 변경, 웰컴 메시지 변경 * refactor : unfollow 이벤트 대처 * [관리자 페이지] 요양원 도메인 CRUD (#39) * feat: 요양원 도메인 * refactor: admin에서 developer로 변경 * refactor: developer -> admin * refactor: admin->institution 요양원이 관리하는 부분 * refactor : 파일 분리 * refactor : baseEntity 위치 변경 * feat : 기본값 초기화 * feat : 기본값 초기화 * refactor : 전화번호 입력 로직 구체화 * refactor : Optional 제거 * refactor : 예외 케이스 대처 * refactor : 메서드 분리 * refactor : mapper 리팩토링 * refactor : 순환 참조 해결 * refactor : 디렉토리명 정의 * test : 테스트 완료! * refactor : private으로 바꾸기 --------- Co-authored-by: hyyyh0x <[email protected]>
- Loading branch information
Showing
37 changed files
with
599 additions
and
62 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
54 changes: 54 additions & 0 deletions
54
src/main/java/dbdr/domain/careworker/service/CareworkerMessagingService.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,54 @@ | ||
package dbdr.domain.careworker.service; | ||
|
||
import java.time.LocalTime; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import dbdr.domain.careworker.entity.Careworker; | ||
import dbdr.domain.careworker.repository.CareworkerRepository; | ||
|
||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import dbdr.global.util.line.LineMessagingUtil; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class CareworkerMessagingService { | ||
|
||
private final CareworkerService careworkerService; | ||
private final CareworkerRepository careworkerRepository; | ||
private final LineMessagingUtil lineMessagingUtil; | ||
|
||
@Transactional | ||
public void handleCareworkerPhoneMessage(String userId, String phoneNumber) { | ||
Careworker careworker = careworkerService.findByPhone(phoneNumber); | ||
String userName = careworker.getName(); | ||
careworker.updateLineUserId(userId); | ||
careworkerRepository.save(careworker); | ||
|
||
String welcomeMessage = | ||
" " + userName + " 요양보호사님, 안녕하세요! 🌸 \n" + | ||
" 최고의 요양원 서비스 돌봄다리입니다. 🤗\n" + | ||
" 저희와 함께 해주셔서 정말 감사합니다! 🙏\n" + | ||
" 기본적인 알림 시간은 매일 오후 5시로 설정되어있습니다. 😄\n" + | ||
" 알림을 받고 싶은 시간을 수정하고 싶으시다면 알려주세요! 💬\n" + | ||
" 예 : `오후 7시' 혹은 '오후 7시 30분'"; | ||
|
||
log.info("Careworker {} has been registered with Line ID {}", userName, userId); | ||
log.info("Sending welcome message to CareworkerPhone {}", careworker.getPhone()); | ||
|
||
lineMessagingUtil.sendMessageToUser(userId, welcomeMessage); | ||
} | ||
|
||
@Transactional | ||
public void updateCareworkerAlertTime(String userId, String ampm, String hour, String minute) { | ||
Careworker careworker = careworkerService.findByLineUserId(userId); | ||
int minuteValue = (minute != null) ? Integer.parseInt(minute) : 0; // minute이 null이면 0으로 처리 | ||
LocalTime alertTime = lineMessagingUtil.convertToLocalTime(ampm, Integer.parseInt(hour), minuteValue); | ||
careworker.updateAlertTime(alertTime); | ||
careworkerRepository.save(careworker); | ||
} | ||
} |
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
4 changes: 2 additions & 2 deletions
4
src/main/java/dbdr/domain/chart/controller/CareWorkerChartController.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
4 changes: 2 additions & 2 deletions
4
src/main/java/dbdr/domain/chart/controller/GuardianChartController.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
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
12 changes: 8 additions & 4 deletions
12
src/main/java/dbdr/domain/chart/dto/request/ChartDetailRequest.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,9 +1,13 @@ | ||
package dbdr.domain.chart.dto.request; | ||
|
||
import dbdr.domain.recipient.entity.Recipient; | ||
|
||
public record ChartDetailRequest( | ||
BodyManagementRequest bodyManagement, | ||
NursingManagementRequest nursingManagement, | ||
CognitiveManagementRequest cognitiveManagement, | ||
RecoveryTrainingRequest recoveryTraining | ||
String conditionDisease, | ||
Recipient recipient, | ||
BodyManagementRequest bodyManagement, | ||
NursingManagementRequest nursingManagement, | ||
CognitiveManagementRequest cognitiveManagement, | ||
RecoveryTrainingRequest recoveryTraining | ||
) { | ||
} |
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
9 changes: 5 additions & 4 deletions
9
src/main/java/dbdr/domain/chart/entity/CognitiveManagement.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
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
2 changes: 1 addition & 1 deletion
2
...a/dbdr/domain/core/entity/BaseEntity.java → ...r/domain/core/base/entity/BaseEntity.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
22 changes: 22 additions & 0 deletions
22
src/main/java/dbdr/domain/core/messaging/controller/LineMessagingController.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,22 @@ | ||
package dbdr.domain.core.messaging.controller; | ||
|
||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import dbdr.domain.core.messaging.service.LineMessagingService; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
|
||
@RestController | ||
@RequestMapping("/line") | ||
@RequiredArgsConstructor | ||
public class LineMessagingController { | ||
private final LineMessagingService lineMessagingService; | ||
|
||
@PostMapping | ||
public void handleLineEvent(@RequestBody String requestBody) { | ||
lineMessagingService.handleLineEvent(requestBody); | ||
} | ||
} |
Oops, something went wrong.