Skip to content

Commit 61667f3

Browse files
authored
Merge pull request #25 from team-gogo/develop
v2025.4.12
2 parents 75a9040 + 855dbb0 commit 61667f3

File tree

11 files changed

+133
-9
lines changed

11 files changed

+133
-9
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: GOGO Betting On-premise stage CD Workflow
2+
3+
on:
4+
push:
5+
branches:
6+
- 'develop'
7+
workflow_dispatch:
8+
9+
jobs:
10+
CI:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v3
19+
with:
20+
java-version: '17'
21+
distribution: 'temurin'
22+
cache: gradle
23+
24+
- name: Setup Gradle
25+
uses: gradle/gradle-build-action@v2
26+
27+
- name: Setup Gradle's permission
28+
run: chmod +x gradlew
29+
30+
- name: Build with Gradle
31+
run: ./gradlew clean build
32+
33+
deploy:
34+
needs: CI
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@v3
39+
40+
- name: Install sshpass and OpenSSH
41+
run: |
42+
sudo apt-get update && sudo apt-get install -y sshpass openssh-client
43+
44+
- name: SSH Command to Deploy using Bastion and Target Instance
45+
run: |
46+
sshpass -p "${{ secrets.STAGE_ON_PREMISE_PASSWORD }}" ssh -o StrictHostKeyChecking=no ubuntu@${{ secrets.STAGE_ON_PREMISE_HOST }} << 'EOF'
47+
mkdir -p /home/ubuntu/gogo-betting
48+
cd /home/ubuntu/gogo-betting
49+
50+
if [ ! -d ".git" ]; then
51+
git clone -b develop https://github.com/team-gogo/gogo-betting.git .
52+
else
53+
git pull origin develop
54+
fi
55+
56+
./gradlew clean build
57+
58+
docker build -f DockerFileStage -t gogo-betting-stage .
59+
60+
docker stop gogo-betting-stage || true
61+
docker rm gogo-betting-stage || true
62+
63+
docker run -d -p 8083:8083 --add-host host.docker.internal:host-gateway --name gogo-betting-stage gogo-betting-stage
64+
65+
- name: SSH Success Notification
66+
if: success()
67+
uses: sarisia/actions-status-discord@v1
68+
with:
69+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
70+
color: 0x4CAF50
71+
title: "배포 성공"
72+
message: "GOGO User On-premise stage deployment completed successfully."
73+
74+
- name: SSH Failure Notification
75+
if: failure()
76+
uses: sarisia/actions-status-discord@v1
77+
with:
78+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
79+
color: 0xFF4C4C
80+
title: "배포 실패"
81+
message: "GOGO User On-premise stage deployment failed. Check the logs for details."

.github/workflows/gogo-betting-stage-cd.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: GOGO Betting stage CD Workflow
22

3-
on:
4-
push:
5-
branches:
6-
- 'develop'
7-
workflow_dispatch:
3+
#on:
4+
# push:
5+
# branches:
6+
# - 'develop'
7+
# workflow_dispatch:
88

99
jobs:
1010
CI:

src/main/kotlin/gogo/gogobetting/domain/betting/root/application/BettingMapper.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package gogo.gogobetting.domain.betting.root.application
22

33
import gogo.gogobetting.domain.betting.result.persistence.BettingResultRepository
4-
import gogo.gogobetting.domain.betting.root.application.dto.BettingBundleDto
5-
import gogo.gogobetting.domain.betting.root.application.dto.BettingBundleInfoDto
6-
import gogo.gogobetting.domain.betting.root.application.dto.BettingInfoDto
7-
import gogo.gogobetting.domain.betting.root.application.dto.BettingResultInfoDto
4+
import gogo.gogobetting.domain.betting.root.application.dto.*
85
import gogo.gogobetting.domain.betting.root.persistence.Betting
96
import org.springframework.stereotype.Component
107

@@ -35,5 +32,9 @@ class BettingMapper(
3532
return BettingBundleDto(bundleInfo)
3633
}
3734

35+
fun mapBettingPoint(bettingList: List<Betting>): TotalBettingPointDto =
36+
TotalBettingPointDto(
37+
bettingPoint = bettingList.sumOf { it.point }
38+
)
3839

3940
}

src/main/kotlin/gogo/gogobetting/domain/betting/root/application/BettingReader.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ class BettingReader(
1212
fun readBundleInfo(matchIds: List<Long>, studentId: Long): List<Betting> =
1313
bettingRepository.findBettingBundleInfo(matchIds, studentId)
1414

15+
fun readBundleActiveInfo(matchIds: List<Long>, studentId: Long): List<Betting> =
16+
bettingRepository.findBettingActiveBundleInfo(matchIds, studentId)
17+
1518
}

src/main/kotlin/gogo/gogobetting/domain/betting/root/application/BettingService.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package gogo.gogobetting.domain.betting.root.application
22

33
import gogo.gogobetting.domain.betting.root.application.dto.BettingBundleDto
44
import gogo.gogobetting.domain.betting.root.application.dto.BettingDto
5+
import gogo.gogobetting.domain.betting.root.application.dto.TotalBettingPointDto
56

67
interface BettingService {
78
fun bet(matchId: Long, dto: BettingDto)
89
fun bundle(matchIds: List<Long>, studentId: Long): BettingBundleDto
10+
fun totalBettingPoint(matchIds: List<Long>, studentId: Long): TotalBettingPointDto
911
}

src/main/kotlin/gogo/gogobetting/domain/betting/root/application/BettingServiceImpl.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package gogo.gogobetting.domain.betting.root.application
22

33
import gogo.gogobetting.domain.betting.root.application.dto.BettingBundleDto
44
import gogo.gogobetting.domain.betting.root.application.dto.BettingDto
5+
import gogo.gogobetting.domain.betting.root.application.dto.TotalBettingPointDto
56
import gogo.gogobetting.domain.betting.root.event.MatchBettingEvent
67
import gogo.gogobetting.global.util.UserContextUtil
78
import org.springframework.context.ApplicationEventPublisher
@@ -43,4 +44,10 @@ class BettingServiceImpl(
4344
return bettingMapper.mapBundle(bettings)
4445
}
4546

47+
@Transactional(readOnly = true)
48+
override fun totalBettingPoint(matchIds: List<Long>, studentId: Long): TotalBettingPointDto {
49+
val bettings = bettingReader.readBundleActiveInfo(matchIds, studentId)
50+
return bettingMapper.mapBettingPoint(bettings)
51+
}
52+
4653
}

src/main/kotlin/gogo/gogobetting/domain/betting/root/application/dto/BettingDto.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ data class BettingResultInfoDto(
3434
val earnedPoint: Long,
3535
)
3636

37+
data class TotalBettingPointDto(
38+
val bettingPoint: Long,
39+
)

src/main/kotlin/gogo/gogobetting/domain/betting/root/persistence/BettingCustomRepository.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ import gogo.gogobetting.domain.betting.root.application.dto.MatchOddsDto
55
interface BettingCustomRepository {
66
fun calcOdds(matchId: Long, winTeamId: Long): MatchOddsDto
77
fun findBettingBundleInfo(matchIds: List<Long>, studentId: Long): List<Betting>
8+
fun findBettingActiveBundleInfo(matchIds: List<Long>, studentId: Long): List<Betting>
89
}

src/main/kotlin/gogo/gogobetting/domain/betting/root/persistence/BettingCustomRepositoryImpl.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,19 @@ class BettingCustomRepositoryImpl(
5959
)
6060
.fetch()
6161

62+
override fun findBettingActiveBundleInfo(matchIds: List<Long>, studentId: Long): List<Betting> =
63+
queryFactory
64+
.selectFrom(betting)
65+
.leftJoin(bettingResult)
66+
.on(
67+
bettingResult.bettingId.eq(betting.id)
68+
)
69+
.where(
70+
betting.matchId.`in`(matchIds)
71+
.and(betting.studentId.eq(studentId))
72+
.and(betting.status.eq(CONFIRMED))
73+
.and(bettingResult.isNull)
74+
)
75+
.fetch()
76+
6277
}

src/main/kotlin/gogo/gogobetting/domain/betting/root/presentation/BettingController.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package gogo.gogobetting.domain.betting.root.presentation
33
import gogo.gogobetting.domain.betting.root.application.BettingService
44
import gogo.gogobetting.domain.betting.root.application.dto.BettingBundleDto
55
import gogo.gogobetting.domain.betting.root.application.dto.BettingDto
6+
import gogo.gogobetting.domain.betting.root.application.dto.TotalBettingPointDto
67
import jakarta.validation.Valid
78
import jakarta.validation.constraints.NotNull
89
import org.springframework.http.HttpStatus
@@ -33,4 +34,13 @@ class BettingController(
3334
return ResponseEntity.ok(response)
3435
}
3536

37+
@GetMapping("/point")
38+
fun totalBettingPoint(
39+
@RequestParam @Valid @NotNull matchIds: List<Long>,
40+
@RequestParam @Valid @NotNull studentId: Long
41+
): ResponseEntity<TotalBettingPointDto> {
42+
val response = bettingService.totalBettingPoint(matchIds, studentId)
43+
return ResponseEntity.ok(response)
44+
}
45+
3646
}

0 commit comments

Comments
 (0)