Skip to content

Commit 12683ab

Browse files
authored
Merge pull request #5 from 0361Team/myBranch
My branch
2 parents 9305019 + 157dba5 commit 12683ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3808
-542
lines changed

.DS_Store

0 Bytes
Binary file not shown.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "kakaoLogo.pdf",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
}
12+
}
Binary file not shown.

Sources/CourseAPI/CourseAPI.swift

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
//
2+
// CourseAPI.swift
3+
// Lecture2Quiz
4+
//
5+
// Created by 바견규 on 5/24/25.
6+
//
7+
8+
import Foundation
9+
import Moya
10+
11+
// 수업 및 텍스트 관련 API 라우터
12+
enum CourseAPI {
13+
14+
// 수업 생성
15+
case createCourse(userId: Int, title: String, description: String)
16+
17+
// 수업 ID로 주차 목록 조회
18+
// - 사용처: 녹음 종료 시 수업 선택 뷰 등에서 호출
19+
case getCourseWeeks(courseId: Int)
20+
21+
// 주차 ID로 텍스트 조회
22+
// - 사용처: 텍스트 상세 열람 시 사용
23+
case getWeekText(weekId: Int)
24+
25+
// 주차 생성
26+
// - 사용처: 주차 선택 뷰에서 새 주차 생성 시
27+
case createWeek(courseId: Int, title: String, weekNumber: Int)
28+
29+
// 텍스트 ID로 키워드 조회
30+
case getKeywords(textId: Int)
31+
32+
// 키워드 생성 요청
33+
case createKeyword(textId: Int)
34+
35+
// 텍스트 요약 생성 요청
36+
case summarizeText(textId: Int)
37+
38+
// 사용자별 수업 목록 조회
39+
// - 사용처: 수업 선택 뷰 최초 로딩 시
40+
case getUserCourses(userId: Int)
41+
42+
// 녹음 내용을 주차에 제출
43+
// - 사용처: 녹음 종료 후 내용 업로드
44+
case submitTranscript(weekId: Int, content: String, type: String)
45+
46+
// 텍스트 ID로 텍스트 단건 조회
47+
// - 사용처: 퀴즈 생성 시 텍스트 내용 기반 활용
48+
case getTextById(id: Int)
49+
50+
// 수업 삭제
51+
case deleteCourse(courseId: Int)
52+
53+
// 주차 삭제
54+
case deleteWeek(weekId: Int)
55+
56+
// 텍스트 삭제
57+
case deleteText(textId: Int)
58+
59+
// 텍스트 수정
60+
case updateText(textId: Int, content: String, type: String)
61+
}
62+
63+
64+
extension CourseAPI: TargetType {
65+
var baseURL: URL {
66+
let baseURL = Bundle.main.object(forInfoDictionaryKey: "API_URL") as! String
67+
return URL(string: baseURL)!
68+
}
69+
70+
var path: String {
71+
switch self {
72+
case .createCourse:
73+
return "/v1/course"
74+
case .getCourseWeeks(let courseId):
75+
return "/v1/course/\(courseId)"
76+
case .getWeekText(let weekId):
77+
return "/v1/texts/weeks/\(weekId)"
78+
case .createWeek:
79+
return "/weeks"
80+
case .getKeywords(let textId), .createKeyword(let textId):
81+
return "/v1/texts/keywords/\(textId)"
82+
case .summarizeText(let textId):
83+
return "/v1/texts/summation/\(textId)"
84+
case .getUserCourses(let userId):
85+
return "/v1/course/user/\(userId)/courses"
86+
case .submitTranscript:
87+
return "/v1/texts"
88+
case .getTextById(let id):
89+
return "/v1/texts/\(id)"
90+
case .deleteCourse(let courseId):
91+
return "/v1/course/\(courseId)"
92+
case .deleteWeek(let weekId):
93+
return "/api/weeks/\(weekId)"
94+
case .deleteText(let textId), .updateText(let textId, _, _):
95+
return "/v1/texts/\(textId)"
96+
97+
}
98+
}
99+
100+
var method: Moya.Method {
101+
switch self {
102+
case .createCourse, .createWeek, .createKeyword, .summarizeText, .submitTranscript:
103+
return .post
104+
case .getCourseWeeks, .getWeekText, .getKeywords, .getUserCourses, .getTextById:
105+
return .get
106+
case .deleteCourse, .deleteWeek, .deleteText:
107+
return .delete
108+
case .updateText:
109+
return .put
110+
}
111+
}
112+
113+
var task: Task {
114+
switch self {
115+
case let .createCourse(userId, title, description):
116+
return .requestParameters(parameters: [
117+
"userId": userId,
118+
"title": title,
119+
"description": description
120+
], encoding: JSONEncoding.default)
121+
case let .createWeek(courseId, title, weekNumber):
122+
return .requestParameters(parameters: [
123+
"courseId": courseId,
124+
"title": title,
125+
"weekNumber": weekNumber
126+
], encoding: JSONEncoding.default)
127+
case .createKeyword, .summarizeText:
128+
return .requestPlain
129+
case let .submitTranscript(weekId, content, type):
130+
return .requestParameters(
131+
parameters: [
132+
"weekId": weekId,
133+
"content": content,
134+
"type": type
135+
],
136+
encoding: JSONEncoding.default
137+
)
138+
case .updateText(_, let content, let type):
139+
return .requestParameters(parameters: [
140+
"content": content,
141+
"type": type
142+
], encoding: JSONEncoding.default)
143+
144+
default:
145+
return .requestPlain
146+
}
147+
}
148+
149+
var headers: [String: String]? {
150+
return [
151+
"accept": "*/*",
152+
"content-type": "application/json"
153+
]
154+
}
155+
}

Sources/CourseAPI/CouseResponse.swift

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
//
2+
// response.swift
3+
// Lecture2Quiz
4+
//
5+
// Created by 바견규 on 5/24/25.
6+
//
7+
8+
import Foundation
9+
10+
// MARK: - 수업(Course)
11+
12+
struct CreateCourseRequest: Codable {
13+
let userId: Int
14+
let title: String
15+
let description: String
16+
}
17+
18+
struct CourseResponse: Codable {
19+
let id: Int
20+
let userId: Int
21+
let title: String
22+
let description: String
23+
let weeks: [WeekResponse]? // 주차 정보 포함 가능
24+
}
25+
26+
// MARK: - 주차(Week)
27+
28+
struct CreateWeekRequest: Codable {
29+
let courseId: Int
30+
let title: String
31+
let weekNumber: Int
32+
}
33+
34+
struct WeekResponse: Codable {
35+
let id: Int
36+
let courseId: Int
37+
let title: String
38+
let weekNumber: Int
39+
}
40+
41+
// MARK: - 텍스트(Text)
42+
43+
struct WeekTextResponse: Codable, Identifiable {
44+
let id: Int
45+
let weekId: Int
46+
let content: String
47+
let summation: String?
48+
}
49+
50+
51+
// MARK: - 사용자 수업 목록 조회
52+
struct CourseResponseByUserID: Decodable, Identifiable,Hashable {
53+
let id: Int
54+
let title: String
55+
let description: String
56+
let weeks: [WeekResponseByUserID]
57+
}
58+
59+
struct WeekResponseByUserID: Decodable,Identifiable,Hashable {
60+
let id: Int
61+
let courseId: Int
62+
let title: String
63+
}
64+
65+
66+
// MARK: - 텍스트 ID로 get
67+
struct TextDetailResponse: Codable {
68+
let id: Int
69+
let weekId: Int
70+
let content: String
71+
let type: String
72+
let summation: String?
73+
}

Sources/Lecture2QuizApp.swift

Lines changed: 0 additions & 11 deletions
This file was deleted.

Sources/Models/ColorHexExtend.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// ColorHexExtend.swift
3+
// Starbucks
4+
//
5+
// Created by 박현규 on 3/19/25.
6+
//
7+
8+
import SwiftUI
9+
10+
extension Color {
11+
init(hex: String) {
12+
let hex = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
13+
var int: UInt64 = 0
14+
Scanner(string: hex).scanHexInt64(&int)
15+
let a, r, g, b: UInt64
16+
switch hex.count {
17+
case 6: // RGB (예: #01A862)
18+
(a, r, g, b) = (255, (int >> 16) & 0xFF, (int >> 8) & 0xFF, int & 0xFF)
19+
case 8: // ARGB (예: #FF01A862)
20+
(a, r, g, b) = ((int >> 24) & 0xFF, (int >> 16) & 0xFF, (int >> 8) & 0xFF, int & 0xFF)
21+
default:
22+
(a, r, g, b) = (255, 0, 0, 0) // 기본값: 검정색
23+
}
24+
self.init(
25+
.sRGB,
26+
red: Double(r) / 255,
27+
green: Double(g) / 255,
28+
blue: Double(b) / 255,
29+
opacity: Double(a) / 255
30+
)
31+
}
32+
}
33+

0 commit comments

Comments
 (0)