Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c49a93a
Update README.md
waterricecake Oct 14, 2024
e1cc616
Update README.md
waterricecake Oct 14, 2024
39847bd
[feature] 전체적으로 디스코드를 연동한다. (#135)
kpeel5839 Oct 18, 2024
bdbcf61
fix : 게임 종료 이후 sse 구독자에게 wait 발행
waterricecake Oct 18, 2024
87b9d4e
feat : redis lock 구현
waterricecake Oct 21, 2024
b2f2d3e
test : lobby 동시입장 테스트 구현
waterricecake Oct 21, 2024
ecd240a
feat : RedissonMultiLock을 통해 다중락 동시성 문제 해결
waterricecake Oct 21, 2024
076f8be
refactor : 필요없는 출력 제거
waterricecake Oct 21, 2024
388bf58
refactor : testService 접근자 변경
waterricecake Oct 21, 2024
62a9674
refactor : RedisLockAspect 이름 변경
waterricecake Oct 21, 2024
71b2d45
refactor : aspect 내 static 변수 접근자 변경
waterricecake Oct 22, 2024
9af901e
refactor : @Link를 통한 대상 링크 수정
waterricecake Oct 22, 2024
5170e00
docs : @exception을 통해 예외사항 정리
waterricecake Oct 23, 2024
7468f93
feat : @TestComponent를 통해 테스트 환경에서 어노테이션이 적용안되던 것을 수정
waterricecake Oct 23, 2024
14f36dd
refactor: change field name [contents --> content] (#141)
kpeel5839 Oct 27, 2024
a221af4
#142 - 대기방에서 SSE를 통해 인원을 받아온다. (#143)
kpeel5839 Oct 31, 2024
d396dfe
hotfix : 참가자가 sse구독전에 요청하던 에러 수정 (#148)
waterricecake Nov 5, 2024
217de8e
feat: 직업 스킬 사용을 웹소켓으로 변경 (#146)
thdwoqor Nov 6, 2024
a1b3e8b
#144 - SSE를 Game에서 분리한다
waterricecake Nov 11, 2024
f470eae
#150 - 레거시 코드 제거 (#151)
kpeel5839 Nov 15, 2024
93c9334
chore: 404 알림 제외 처리 (#153)
thdwoqor Nov 15, 2024
6099ce1
#155 - ci 라벨 삭제 및 빌드 오류 수정 (#156)
thdwoqor Nov 15, 2024
714a7d6
feat: NoResourceFoundException 에러 핸들링 추가 (#158)
thdwoqor Nov 28, 2024
5b51230
feat: 웹소켓 채팅 리팩터링 (#162)
thdwoqor Dec 6, 2024
4ad0bd1
직업 스킬 response 형식 변경 (#163)
thdwoqor Dec 6, 2024
0cb1952
Hotfix/#1 sse connect (#164)
waterricecake Dec 22, 2024
501f1d4
웹소켓 채팅 리팩터링 (#160)
thdwoqor Dec 26, 2024
238db16
fix: skill 구독 url 수정 (#168)
thdwoqor Dec 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 68 additions & 3 deletions .github/workflows/backend-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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을 설치합니다.
Expand All @@ -34,3 +33,69 @@ jobs:

- name: Gradle을 통해 빌드합니다.
run: ./gradlew build

- name: 성공 메시지 전송
if: ${{ success() }}
uses: Ilshidur/action-discord@0.3.2
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/action-discord@0.3.2
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
}
]
}
]
71 changes: 69 additions & 2 deletions .github/workflows/backend-dev-CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Dev CI/CD

on:
push:
branches: [dev]
branches: [ dev ]

permissions:
contents: read
Expand Down Expand Up @@ -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/action-discord@0.3.2
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/action-discord@0.3.2
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
}
]
}
]

69 changes: 68 additions & 1 deletion .github/workflows/backend-prod-CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Prod CI/CD

on:
push:
branches: [prod]
branches: [ prod ]

permissions:
contents: read
Expand Down Expand Up @@ -58,3 +58,70 @@ jobs:
script: |
cd ~/deploy
sh deploy.sh

- name: 성공 메시지 전송
if: ${{ success() }}
uses: Ilshidur/action-discord@0.3.2
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/action-discord@0.3.2
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
}
]
}
]

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@

## 기술 스택
---
![Skill](https://github.com/user-attachments/assets/e5b18101-c81d-4c54-9001-e9d5772c4c5f)
![Skill](https://github.com/user-attachments/assets/4695beb1-2ff3-4649-b6ee-80c67900a2a9)


## 인프라 아키텍쳐
---
![infra-architecture](https://github.com/user-attachments/assets/e7db379d-8218-47f1-995c-9fa7efd4ce38)
![infra-architecture](https://github.com/user-attachments/assets/ffc7e50e-a9b1-4168-9969-42f554551790)


## 실시간 통신
---
Expand Down
2 changes: 1 addition & 1 deletion backend-submodule
16 changes: 13 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,19 @@ repositories {
mavenCentral()
}

ext {
set('springCloudVersion', "2021.0.4")
}

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.redisson:redisson-spring-boot-starter:3.37.0'
testImplementation 'org.testcontainers:testcontainers'

implementation 'org.springframework.boot:spring-boot-starter-validation'
Expand All @@ -35,11 +46,10 @@ dependencies {

implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'

implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'

implementation 'org.springframework.boot:spring-boot-starter-websocket'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'

testImplementation 'org.mockito:mockito-core:5.10.0'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public class MafiaTogetherApplication {
public static void main(String[] args) {
SpringApplication.run(MafiaTogetherApplication.class, args);
}

}
50 changes: 30 additions & 20 deletions src/main/java/mafia/mafiatogether/chat/application/ChatService.java
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;
}


}
Loading