-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mafia-together ver 2.0 prod deploy (#165)
* Update README.md * Update README.md * [feature] 전체적으로 디스코드를 연동한다. (#135) * chore: CI/CD에도 깃허브 연동 추가 * chore: FeignClient 의존성 추가 * feat: Service 구성 * feat: Exception Handler에 연결 * chore: discord 적용 * chore: 문구 수정 * chore: build.gradle 코드들과 컨벤션 일치 * refactor: 코드 정리 * refactor: Component Annotation 제거 * fix : 게임 종료 이후 sse 구독자에게 wait 발행 * feat : redis lock 구현 * test : lobby 동시입장 테스트 구현 * feat : RedissonMultiLock을 통해 다중락 동시성 문제 해결 * refactor : 필요없는 출력 제거 * refactor : testService 접근자 변경 * refactor : RedisLockAspect 이름 변경 * refactor : aspect 내 static 변수 접근자 변경 * refactor : @link를 통한 대상 링크 수정 * docs : @exception을 통해 예외사항 정리 * feat : @TestComponent를 통해 테스트 환경에서 어노테이션이 적용안되던 것을 수정 * refactor: change field name [contents --> content] (#141) * #142 - 대기방에서 SSE를 통해 인원을 받아온다. (#143) * refactor: findByCodeAndName 메서드 추가 * feat: ParticipantJoinEvent 추가하여 접속 시 SSE 요청 보낼 수 있도록 설정 * test: InMemorySseEmitterRepository Test 추가 * test: EventListener Test 추가 * test: LobbyInfoResponse Test 수정 및, EventListener MockBean 처리를 통해 에러 해결 * refactor: 패키지 이동 * refactor: 예외 변경 * refactor: Suppress 추가하여 Ascii Code Error 해결 * refactor: Lobby에 isMaster 구현 * hotfix : 참가자가 sse구독전에 요청하던 에러 수정 (#148) * feat: 직업 스킬 사용을 웹소켓으로 변경 (#146) * feat: 직업 스킬 사용을 웹소켓으로 변경 * refactor: JobController 통일 및 테스트 수정 * #144 - SSE를 Game에서 분리한다 * refactor : SSE 로직 Game에서 분리 * refactor : SSE event publish 로직 bean을 통해 common으로 이동 * refactor : sse disconnect 로직 common으로 이동 * refactor : SseRepository 명 Session 변경 및 infra package로 이동 * Test : SseEventPublisher 테스트 작성 * test : SseAspectTest 구현 * refactor : 상수 함수 내부 변수로 변경 * refactor : final 키워드 추가 및 SseEventBuilder import 추가 * refactor : 메서드 네임 수정 및 Sse 생성 매서드 위치 이동 * refactor : aspect test 수정 * refactor : aspect test method 모킹 * refactor : mockito 버전 문제 해결 * #150 - 레거시 코드 제거 (#151) * refactor: status 제거 * refactor: Mafia 결과 조회 제거 및 v2 명시 제거 * refactor: Http 통신 제거 및 버전 표식 제거 * refactor: 테스트 수정 * chore: 404 알림 제외 처리 (#153) * #155 - ci 라벨 삭제 및 빌드 오류 수정 (#156) * chore: ci시 라벨 체크 삭제 * fix: import 추가 * feat: NoResourceFoundException 에러 핸들링 추가 (#158) * feat: 웹소켓 채팅 리팩터링 (#162) * 직업 스킬 response 형식 변경 (#163) * feat: 웹소켓 채팅 리팩터링 * feat: 웹소켓 스킬 response 변경 * Hotfix/#1 sse connect (#164) * fix: 게임 종료시 sse connect 유지 * fix: 게임 상태 delete event 송신하지 않게 수정 --------- Co-authored-by: kpeel5839 <[email protected]> Co-authored-by: Jae-Baek Song <[email protected]>
- Loading branch information
1 parent
3bc5277
commit b5db613
Showing
60 changed files
with
1,630 additions
and
739 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,13 @@ name: Java CI with Gradle | |
|
||
on: | ||
pull_request: | ||
branches: [dev] | ||
branches: [ dev ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
if: contains(github.event.pull_request.labels.*.name, 'Backend') | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
pull-requests: write | ||
|
@@ -20,7 +19,7 @@ jobs: | |
with: | ||
fetch-depth: 3 | ||
token: ${{ secrets.SUBMODULE_TOKEN }} | ||
submodules: true | ||
submodules: true | ||
- run: git log --pretty=oneline | ||
|
||
- name: JDK 21을 설치합니다. | ||
|
@@ -34,3 +33,69 @@ jobs: | |
|
||
- name: Gradle을 통해 빌드합니다. | ||
run: ./gradlew build | ||
|
||
- name: 성공 메시지 전송 | ||
if: ${{ success() }} | ||
uses: Ilshidur/[email protected] | ||
env: | ||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_GITHUB_WEBHOOK }} | ||
DISCORD_USERNAME: Mafia-Together-BOT | ||
DISCORD_AVATAR: https://i.namu.wiki/i/vMYV9DNseNCfKzaPIDshk7eG_7pAZm8BG6c2I_s6XXwyreDbpu3A1nDRUpbqvycQrRvgbSJeg15iXSSiGK5xyw.webp | ||
DISCORD_EMBEDS: | | ||
[ | ||
{ | ||
"author": { | ||
"name": "${{ github.event.pull_request.user.login }}", | ||
"url": "https://github.com/pknu-wap/WAPP/blob/main/image/icon.png?raw=true", | ||
"icon_url": "${{ github.event.pull_request.user.avatar_url }}" | ||
}, | ||
"title": "테스트 성공 ~ 파워 엉덩이 확인하자 ~ 🥰🥰 \n#${{ github.event.pull_request.number }} : ${{ github.event.pull_request.title }}", | ||
"color": 10478271, | ||
"description": "${{ github.event.pull_request.html_url }}", | ||
"fields": [ | ||
{ | ||
"name": "Base Branch", | ||
"value": "${{ github.base_ref }}", | ||
"inline": true | ||
}, | ||
{ | ||
"name": "Compare Branch", | ||
"value": "${{ github.head_ref }}", | ||
"inline": true | ||
} | ||
] | ||
} | ||
] | ||
- name: 실패 메시지 전송 | ||
if: ${{ failure() }} | ||
uses: Ilshidur/[email protected] | ||
env: | ||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_GITHUB_WEBHOOK }} | ||
DISCORD_USERNAME: Mafia-Together-BOT | ||
DISCORD_AVATAR: https://i.namu.wiki/i/vMYV9DNseNCfKzaPIDshk7eG_7pAZm8BG6c2I_s6XXwyreDbpu3A1nDRUpbqvycQrRvgbSJeg15iXSSiGK5xyw.webp | ||
DISCORD_EMBEDS: | | ||
[ | ||
{ | ||
"author": { | ||
"name": "${{ github.event.pull_request.user.login }}", | ||
"url": "https://github.com/pknu-wap/WAPP/blob/main/image/icon.png?raw=true", | ||
"icon_url": "${{ github.event.pull_request.user.avatar_url }}" | ||
}, | ||
"title": "테스트 실패... 달리 엉덩이 가져와 \n#${{ github.event.pull_request.number }} : ${{ github.event.pull_request.title }}", | ||
"color": 13458524, | ||
"description": "${{ github.event.pull_request.html_url }}", | ||
"fields": [ | ||
{ | ||
"name": "Base Branch", | ||
"value": "${{ github.base_ref }}", | ||
"inline": true | ||
}, | ||
{ | ||
"name": "Compare Branch", | ||
"value": "${{ github.head_ref }}", | ||
"inline": true | ||
} | ||
] | ||
} | ||
] |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Dev CI/CD | |
|
||
on: | ||
push: | ||
branches: [dev] | ||
branches: [ dev ] | ||
|
||
permissions: | ||
contents: read | ||
|
@@ -38,6 +38,73 @@ jobs: | |
run: cp -f build/libs/*.jar /home/ubuntu/deploy/ | ||
|
||
- name: 배포 스크립트 실행 | ||
run: | | ||
run: | | ||
cd /home/ubuntu/deploy | ||
sh deploy.sh | ||
- name: 성공 메시지 전송 | ||
if: ${{ success() }} | ||
uses: Ilshidur/[email protected] | ||
env: | ||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_GITHUB_WEBHOOK }} | ||
DISCORD_USERNAME: Mafia-Together-BOT | ||
DISCORD_AVATAR: https://i.namu.wiki/i/vMYV9DNseNCfKzaPIDshk7eG_7pAZm8BG6c2I_s6XXwyreDbpu3A1nDRUpbqvycQrRvgbSJeg15iXSSiGK5xyw.webp | ||
DISCORD_EMBEDS: | | ||
[ | ||
{ | ||
"author": { | ||
"name": "${{ github.event.pull_request.user.login }}", | ||
"url": "https://github.com/pknu-wap/WAPP/blob/main/image/icon.png?raw=true", | ||
"icon_url": "${{ github.event.pull_request.user.avatar_url }}" | ||
}, | ||
"title": "배포 성공 ~ 파워 엉덩이 확인하자 ~ 🥰🥰 \n#${{ github.event.pull_request.number }} : ${{ github.event.pull_request.title }}", | ||
"color": 10478271, | ||
"description": "${{ github.event.pull_request.html_url }}", | ||
"fields": [ | ||
{ | ||
"name": "Base Branch", | ||
"value": "${{ github.base_ref }}", | ||
"inline": true | ||
}, | ||
{ | ||
"name": "Compare Branch", | ||
"value": "${{ github.head_ref }}", | ||
"inline": true | ||
} | ||
] | ||
} | ||
] | ||
- name: 실패 메시지 전송 | ||
if: ${{ failure() }} | ||
uses: Ilshidur/[email protected] | ||
env: | ||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_GITHUB_WEBHOOK }} | ||
DISCORD_USERNAME: Mafia-Together-BOT | ||
DISCORD_AVATAR: https://i.namu.wiki/i/vMYV9DNseNCfKzaPIDshk7eG_7pAZm8BG6c2I_s6XXwyreDbpu3A1nDRUpbqvycQrRvgbSJeg15iXSSiGK5xyw.webp | ||
DISCORD_EMBEDS: | | ||
[ | ||
{ | ||
"author": { | ||
"name": "${{ github.event.pull_request.user.login }}", | ||
"url": "https://github.com/pknu-wap/WAPP/blob/main/image/icon.png?raw=true", | ||
"icon_url": "${{ github.event.pull_request.user.avatar_url }}" | ||
}, | ||
"title": "배포 실패... 달리 엉덩이 가져와 \n#${{ github.event.pull_request.number }} : ${{ github.event.pull_request.title }}", | ||
"color": 13458524, | ||
"description": "${{ github.event.pull_request.html_url }}", | ||
"fields": [ | ||
{ | ||
"name": "Base Branch", | ||
"value": "${{ github.base_ref }}", | ||
"inline": true | ||
}, | ||
{ | ||
"name": "Compare Branch", | ||
"value": "${{ github.head_ref }}", | ||
"inline": true | ||
} | ||
] | ||
} | ||
] | ||
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Prod CI/CD | |
|
||
on: | ||
push: | ||
branches: [prod] | ||
branches: [ prod ] | ||
|
||
permissions: | ||
contents: read | ||
|
@@ -58,3 +58,70 @@ jobs: | |
script: | | ||
cd ~/deploy | ||
sh deploy.sh | ||
- name: 성공 메시지 전송 | ||
if: ${{ success() }} | ||
uses: Ilshidur/[email protected] | ||
env: | ||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_GITHUB_WEBHOOK }} | ||
DISCORD_USERNAME: Mafia-Together-BOT | ||
DISCORD_AVATAR: https://i.namu.wiki/i/vMYV9DNseNCfKzaPIDshk7eG_7pAZm8BG6c2I_s6XXwyreDbpu3A1nDRUpbqvycQrRvgbSJeg15iXSSiGK5xyw.webp | ||
DISCORD_EMBEDS: | | ||
[ | ||
{ | ||
"author": { | ||
"name": "${{ github.event.pull_request.user.login }}", | ||
"url": "https://github.com/pknu-wap/WAPP/blob/main/image/icon.png?raw=true", | ||
"icon_url": "${{ github.event.pull_request.user.avatar_url }}" | ||
}, | ||
"title": "배포 성공 ~ 파워 엉덩이 확인하자 ~ 🥰🥰 \n#${{ github.event.pull_request.number }} : ${{ github.event.pull_request.title }}", | ||
"color": 10478271, | ||
"description": "${{ github.event.pull_request.html_url }}", | ||
"fields": [ | ||
{ | ||
"name": "Base Branch", | ||
"value": "${{ github.base_ref }}", | ||
"inline": true | ||
}, | ||
{ | ||
"name": "Compare Branch", | ||
"value": "${{ github.head_ref }}", | ||
"inline": true | ||
} | ||
] | ||
} | ||
] | ||
- name: 실패 메시지 전송 | ||
if: ${{ failure() }} | ||
uses: Ilshidur/[email protected] | ||
env: | ||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_GITHUB_WEBHOOK }} | ||
DISCORD_USERNAME: Mafia-Together-BOT | ||
DISCORD_AVATAR: https://i.namu.wiki/i/vMYV9DNseNCfKzaPIDshk7eG_7pAZm8BG6c2I_s6XXwyreDbpu3A1nDRUpbqvycQrRvgbSJeg15iXSSiGK5xyw.webp | ||
DISCORD_EMBEDS: | | ||
[ | ||
{ | ||
"author": { | ||
"name": "${{ github.event.pull_request.user.login }}", | ||
"url": "https://github.com/pknu-wap/WAPP/blob/main/image/icon.png?raw=true", | ||
"icon_url": "${{ github.event.pull_request.user.avatar_url }}" | ||
}, | ||
"title": "배포 실패... 달리 엉덩이 가져와 \n#${{ github.event.pull_request.number }} : ${{ github.event.pull_request.title }}", | ||
"color": 13458524, | ||
"description": "${{ github.event.pull_request.html_url }}", | ||
"fields": [ | ||
{ | ||
"name": "Base Branch", | ||
"value": "${{ github.base_ref }}", | ||
"inline": true | ||
}, | ||
{ | ||
"name": "Compare Branch", | ||
"value": "${{ github.head_ref }}", | ||
"inline": true | ||
} | ||
] | ||
} | ||
] | ||
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
Submodule backend-submodule
updated
from 7ebcff to 6ea3cb
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
50 changes: 30 additions & 20 deletions
50
src/main/java/mafia/mafiatogether/chat/application/ChatService.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,51 +1,61 @@ | ||
package mafia.mafiatogether.chat.application; | ||
|
||
import java.time.Clock; | ||
import java.util.List; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import mafia.mafiatogether.chat.application.dto.request.ChatRequest; | ||
import mafia.mafiatogether.chat.application.dto.response.ChatResponse; | ||
import mafia.mafiatogether.chat.domain.Chat; | ||
import mafia.mafiatogether.chat.domain.ChatRepository; | ||
import mafia.mafiatogether.chat.domain.Message; | ||
import mafia.mafiatogether.common.exception.ExceptionCode; | ||
import mafia.mafiatogether.common.exception.GameException; | ||
import mafia.mafiatogether.job.domain.PlayerJob; | ||
import mafia.mafiatogether.job.domain.PlayerJobRepository; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
import java.util.NoSuchElementException; | ||
import java.util.function.Supplier; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ChatService { | ||
|
||
private final PlayerJobRepository playerJobRepository; | ||
private final ChatRepository chatRepository; | ||
|
||
@Transactional(readOnly = true) | ||
public List<ChatResponse> findAllChat(final String code, final String name) { | ||
final PlayerJob playerJobs = playerJobRepository.findById(code) | ||
.orElseThrow(() -> new GameException(ExceptionCode.INVALID_NOT_FOUND_ROOM_CODE)); | ||
final Chat chat = chatRepository.findById(code) | ||
.orElseThrow(() -> new GameException(ExceptionCode.INVALID_NOT_FOUND_ROOM_CODE)); | ||
final boolean isMafia = playerJobs.isMafia(name); | ||
return chat.getMessages().stream() | ||
|
||
return chat.getMessages() | ||
.stream() | ||
.map(message -> ChatResponse.of( | ||
message, | ||
message.getName().equals(name), | ||
isMafia, | ||
playerJobs.findJobByName(message.getName()).getJobType() | ||
)) | ||
.toList(); | ||
message.getName().equals(name) | ||
)).toList(); | ||
} | ||
|
||
@Transactional | ||
public void saveChat(final String code, final String name, final ChatRequest chatRequest) { | ||
final Chat chat = chatRepository.findById(code) | ||
.orElseThrow(() -> new GameException(ExceptionCode.INVALID_NOT_FOUND_ROOM_CODE)); | ||
final Message message = Message.ofChat(name, chatRequest.content()); | ||
public Message enter(final String name, final String code) { | ||
return saveChat(code, () -> Message.fromEnter(name)); | ||
} | ||
|
||
@Transactional | ||
public Message leave(final String name, final String code) { | ||
return saveChat(code, () -> Message.fromLeave(name)); | ||
} | ||
|
||
@Transactional | ||
public Message chat(final String name, final String code, final String content) { | ||
return saveChat(code, () -> Message.ofChat(name, content)); | ||
} | ||
|
||
private Message saveChat(final String code, Supplier<Message> messageFunction) { | ||
Chat chat = chatRepository.findById(code) | ||
.orElseThrow(NoSuchElementException::new); | ||
Message message = messageFunction.get(); | ||
chat.saveMessage(message); | ||
chatRepository.save(chat); | ||
return message; | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.