Skip to content

Commit 80cd9bb

Browse files
authored
#183 [Merge] main 병합 충돌 해결 (dev 기준) (#186)
1 parent 39b4cd2 commit 80cd9bb

19 files changed

Lines changed: 922 additions & 0 deletions

File tree

‎.github/workflows/deploy.yml‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Java CI/CD with Gradle
2+
3+
on:
4+
push:
5+
branches: [ "dev" ] # dev 브랜치에 푸시할 때 작동
6+
workflow_dispatch: #
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Set up JDK 21
15+
uses: actions/setup-java@v4
16+
with:
17+
java-version: '21'
18+
distribution: 'temurin'
19+
cache: 'gradle' # 캐싱 추가: 빌드 속도가 훨씬 빨라집니다.
20+
21+
- name: Build with Gradle
22+
run: |
23+
chmod +x ./gradlew
24+
./gradlew build -x test
25+
26+
- name: Create .env file from Secret
27+
run: |
28+
cat <<'EOF' > .env
29+
${{ secrets.ENV_VARIABLES }}
30+
EOF
31+
32+
- name: Copy JAR and .env to EC2
33+
uses: appleboy/scp-action@v0.1.7
34+
with:
35+
host: ${{ secrets.EC2_HOST }}
36+
username: ${{ secrets.EC2_USERNAME }}
37+
key: ${{ secrets.EC2_SSH_KEY }}
38+
# -plain.jar는 배포에 필요 없으므로 제외합니다.
39+
source: "build/libs/*-SNAPSHOT.jar, .env"
40+
target: "~/"
41+
strip_components: 2
42+
43+
- name: Deploy to EC2
44+
uses: appleboy/ssh-action@v1.0.3
45+
with:
46+
host: ${{ secrets.EC2_HOST }}
47+
username: ${{ secrets.EC2_USERNAME }}
48+
key: ${{ secrets.EC2_SSH_KEY }}
49+
script: |
50+
fuser -k 8080/tcp || true
51+
52+
chmod +x ~/start.sh
53+
~/start.sh
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.swyp.picke.domain.battle.controller;
2+
3+
import com.swyp.picke.domain.battle.dto.request.AdminBattleCreateRequest;
4+
import com.swyp.picke.domain.battle.dto.request.AdminBattleUpdateRequest;
5+
import com.swyp.picke.domain.battle.dto.response.AdminBattleDeleteResponse;
6+
import com.swyp.picke.domain.battle.dto.response.AdminBattleDetailResponse;
7+
import com.swyp.picke.domain.battle.service.BattleService;
8+
import com.swyp.picke.global.common.response.ApiResponse;
9+
import io.swagger.v3.oas.annotations.Operation;
10+
import io.swagger.v3.oas.annotations.tags.Tag;
11+
import jakarta.validation.Valid;
12+
import lombok.RequiredArgsConstructor;
13+
import org.springframework.security.access.prepost.PreAuthorize;
14+
import org.springframework.security.core.annotation.AuthenticationPrincipal;
15+
import org.springframework.web.bind.annotation.*;
16+
17+
@Tag(name = "배틀 API (관리자)", description = "배틀 생성/수정/삭제 (관리자 전용)")
18+
@RestController
19+
@RequestMapping("/api/v1/admin/battles")
20+
@RequiredArgsConstructor
21+
@PreAuthorize("hasRole('ADMIN')")
22+
public class AdminBattleController {
23+
24+
private final BattleService battleService;
25+
26+
@Operation(summary = "배틀 생성")
27+
@PostMapping
28+
public ApiResponse<AdminBattleDetailResponse> createBattle(
29+
@RequestBody @Valid AdminBattleCreateRequest request,
30+
@AuthenticationPrincipal Long adminUserId
31+
) {
32+
return ApiResponse.onSuccess(battleService.createBattle(request, adminUserId));
33+
}
34+
35+
@Operation(summary = "배틀 수정 (변경 필드만 포함)")
36+
@PatchMapping("/{battleId}")
37+
public ApiResponse<AdminBattleDetailResponse> updateBattle(
38+
@PathVariable Long battleId,
39+
@RequestBody @Valid AdminBattleUpdateRequest request
40+
) {
41+
return ApiResponse.onSuccess(battleService.updateBattle(battleId, request));
42+
}
43+
44+
@Operation(summary = "배틀 삭제")
45+
@DeleteMapping("/{battleId}")
46+
public ApiResponse<AdminBattleDeleteResponse> deleteBattle(
47+
@PathVariable Long battleId
48+
) {
49+
return ApiResponse.onSuccess(battleService.deleteBattle(battleId));
50+
}
51+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.swyp.picke.domain.battle.dto.request;
2+
3+
import com.swyp.picke.domain.battle.enums.BattleStatus;
4+
import com.swyp.picke.domain.battle.enums.BattleType;
5+
import java.time.LocalDate;
6+
import java.util.List;
7+
8+
public record AdminBattleCreateRequest(
9+
String title,
10+
String titlePrefix,
11+
String titleSuffix,
12+
String summary,
13+
String description,
14+
String thumbnailUrl,
15+
BattleType type,
16+
BattleStatus status,
17+
String itemA,
18+
String itemADesc,
19+
String itemB,
20+
String itemBDesc,
21+
LocalDate targetDate,
22+
List<Long> tagIds,
23+
List<AdminBattleOptionRequest> options
24+
) {}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.swyp.picke.domain.battle.dto.request;
2+
3+
import com.swyp.picke.domain.battle.enums.BattleOptionLabel;
4+
5+
import java.util.List;
6+
7+
public record AdminBattleOptionRequest(
8+
BattleOptionLabel label,
9+
String title,
10+
String stance,
11+
String representative,
12+
String quote,
13+
String imageUrl,
14+
Boolean isCorrect,
15+
List<Long> tagIds // 옵션 전용 태그 (철학자, 가치관 - 추후 사용자 유형 분석에 사용)
16+
) {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.swyp.picke.domain.battle.dto.request;
2+
3+
import com.swyp.picke.domain.battle.enums.BattleStatus;
4+
import java.time.LocalDate;
5+
import java.util.List;
6+
7+
public record AdminBattleUpdateRequest(
8+
String title,
9+
String titlePrefix,
10+
String titleSuffix,
11+
String summary,
12+
String description,
13+
String thumbnailUrl,
14+
String itemA,
15+
String itemADesc,
16+
String itemB,
17+
String itemBDesc,
18+
LocalDate targetDate,
19+
Integer audioDuration,
20+
BattleStatus status,
21+
List<Long> tagIds,
22+
List<AdminBattleOptionRequest> options
23+
) {}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.swyp.picke.domain.battle.dto.response;
2+
3+
import java.time.LocalDateTime;
4+
5+
/**
6+
* 관리자 - 배틀 삭제 응답
7+
* 역할: 배틀이 성공적으로 소프트 딜리트 되었는지 확인하고 삭제 시점을 반환합니다.
8+
*/
9+
10+
public record AdminBattleDeleteResponse(
11+
Boolean success, // 삭제 성공 여부
12+
LocalDateTime deletedAt // 삭제 처리된 일시 (Soft Delete)
13+
) {}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.swyp.picke.domain.battle.dto.response;
2+
3+
import com.swyp.picke.domain.battle.enums.BattleCreatorType;
4+
import com.swyp.picke.domain.battle.enums.BattleStatus;
5+
import com.swyp.picke.domain.battle.enums.BattleType;
6+
7+
import java.time.LocalDate;
8+
import java.time.LocalDateTime;
9+
import java.util.List;
10+
11+
/**
12+
* 관리자 - 배틀 상세 상세 조회 응답
13+
* 역할: 관리자가 배틀의 모든 설정 값(상태, 생성자 타입, 수정일 등)을 확인하고 수정할 때 사용합니다.
14+
*/
15+
16+
public record AdminBattleDetailResponse(
17+
Long battleId,
18+
String title,
19+
String titlePrefix,
20+
String titleSuffix,
21+
String summary,
22+
String description,
23+
String thumbnailUrl,
24+
BattleType type,
25+
String itemA,
26+
String itemADesc,
27+
String itemB,
28+
String itemBDesc,
29+
LocalDate targetDate,
30+
BattleStatus status,
31+
BattleCreatorType creatorType,
32+
List<BattleTagResponse> tags,
33+
List<BattleOptionResponse> options,
34+
LocalDateTime createdAt,
35+
LocalDateTime updatedAt
36+
) {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.swyp.picke.domain.battle.enums;
2+
3+
public enum BattleType {
4+
BATTLE, QUIZ, VOTE
5+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.swyp.picke.domain.tag.dto.request;
2+
3+
import com.swyp.picke.domain.tag.enums.TagType;
4+
import jakarta.validation.constraints.NotBlank;
5+
import jakarta.validation.constraints.NotNull;
6+
7+
public record TagRequest(
8+
@NotBlank(message = "태그 이름을 입력해주세요.")
9+
String name,
10+
11+
@NotNull(message = "태그 타입을 선택해주세요.")
12+
TagType type
13+
) {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.swyp.picke.domain.tag.dto.response;
2+
3+
import java.time.LocalDateTime;
4+
5+
public record TagDeleteResponse(
6+
boolean success,
7+
LocalDateTime deletedAt
8+
) {}

0 commit comments

Comments
 (0)