-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from TEAMMatchDev/feature/issue-211
관리자 집행 수정 및 알림톡 전송기능 추가 배포
- Loading branch information
Showing
32 changed files
with
317 additions
and
43 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
34 changes: 34 additions & 0 deletions
34
Match-Api/src/main/java/com/example/matchapi/common/lisetner/ExecutionEvent.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,34 @@ | ||
package com.example.matchapi.common.lisetner; | ||
|
||
|
||
import com.example.matchdomain.donation.entity.DonationUser; | ||
import com.example.matchdomain.project.entity.Project; | ||
import org.springframework.context.ApplicationEvent; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ExecutionEvent extends ApplicationEvent { | ||
private final List<DonationUser> donationUsers; | ||
private final Project project; | ||
private final List<String> items; | ||
|
||
public ExecutionEvent(Object source, List<DonationUser> donationUsers, Project project, List<String> items) { | ||
super(source); | ||
this.donationUsers = donationUsers; | ||
this.project = project; | ||
this.items = items; | ||
} | ||
|
||
public List<DonationUser> getDonationUsers() { | ||
return donationUsers; | ||
} | ||
|
||
public Project getProject() { | ||
return project; | ||
} | ||
|
||
public List<String> getItems(){ | ||
return items; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
Match-Api/src/main/java/com/example/matchapi/common/lisetner/ExecutionEventListener.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,51 @@ | ||
package com.example.matchapi.common.lisetner; | ||
|
||
import com.example.matchapi.user.service.AligoService; | ||
import com.example.matchdomain.donation.entity.DonationUser; | ||
import com.example.matchdomain.project.entity.Project; | ||
import com.example.matchdomain.user.entity.User; | ||
import com.example.matchinfrastructure.aligo.converter.AligoConverter; | ||
import com.example.matchinfrastructure.aligo.dto.AlimType; | ||
import com.example.matchinfrastructure.aligo.service.AligoInfraService; | ||
import com.example.matchinfrastructure.match_aligo.dto.AlimTalkDto; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class ExecutionEventListener { | ||
private final AligoConverter aligoConverter; | ||
private final AligoService aligoService; | ||
@EventListener | ||
@Async("event-listener") | ||
public void onDonationExecution(ExecutionEvent event){ | ||
log.info("event start"); | ||
List<DonationUser> donationUsers = event.getDonationUsers(); | ||
|
||
Project project = event.getProject(); | ||
|
||
List<AlimTalkDto> alimTalkDtos = new ArrayList<>(); | ||
|
||
String article = getArticle(event.getItems()); | ||
|
||
for(DonationUser donationUser : donationUsers){ | ||
User user = donationUser.getUser(); | ||
alimTalkDtos.add(aligoConverter.convertToAlimTalkExecution(donationUser.getId(), user.getName(), user.getPhoneNumber(), article, project.getUsages())); | ||
} | ||
|
||
aligoService.sendAlimTalks(AlimType.EXECUTION, alimTalkDtos); | ||
log.info("event finish"); | ||
|
||
} | ||
|
||
private String getArticle(List<String> items) { | ||
return items.get(0) + " 외 " + items.size() + "개"; | ||
} | ||
} |
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
Oops, something went wrong.