Skip to content

Commit

Permalink
Merge branch 'Dev' into DY
Browse files Browse the repository at this point in the history
  • Loading branch information
doyeonk429 authored Aug 16, 2024
2 parents 58560ff + 63b8fe6 commit 6b889e4
Show file tree
Hide file tree
Showing 58 changed files with 1,917 additions and 362 deletions.
Binary file modified .DS_Store
Binary file not shown.
75 changes: 74 additions & 1 deletion Drink-EG/Drink-EG.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"originHash" : "ae843fcd9fde0e0eb90792d861b014bf16f661547950eb4147c039184b74fb38",
"originHash" : "a8561a89e8f67830f69988d3a168bbd94d5d7088705bdbb1ebac5fe0c3ef0104",
"pins" : [
{
"identity" : "alamofire",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Alamofire/Alamofire",
"location" : "https://github.com/Alamofire/Alamofire.git",
"state" : {
"revision" : "f455c2975872ccd2d9c81594c658af65716e9b9a",
"version" : "5.9.1"
Expand All @@ -31,7 +31,7 @@
{
"identity" : "kakao-ios-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kakao/kakao-ios-sdk",
"location" : "https://github.com/kakao/kakao-ios-sdk.git",
"state" : {
"revision" : "66b3bddc2657e8ccb7a16fa0264aac99c57be09b",
"version" : "2.22.5"
Expand Down Expand Up @@ -64,6 +64,15 @@
"version" : "6.7.1"
}
},
{
"identity" : "sdwebimage",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SDWebImage/SDWebImage.git",
"state" : {
"revision" : "5191b801aca999b704eb93f118f91468b4570571",
"version" : "5.19.6"
}
},
{
"identity" : "snapkit",
"kind" : "remoteSourceControl",
Expand Down
71 changes: 71 additions & 0 deletions Drink-EG/Drink-EG/Resources/APIs/SearchAPI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// SearchAPI.swift
// Drink-EG
//
// Created by 이현주 on 8/16/24.
//

import Foundation
import Moya

// JWT 토큰을 받을 수 있도록 BasicAPI 정의
/// 기능 하나 당 API 1개씩 만들기
/// - API 명세서 기준으로 1 명세서 당 1 API enum 정의하기
/// - 변경을 한 번 더 해보자.

enum SearchAPI {
case getWineName(wineName: String)
case getWineInfo(wineId: Int)
case getWineReview(wineId: Int)
}

extension SearchAPI: TargetType {
var baseURL: URL {
/// 기본 URL 작성
return URL(string: "https://drinkeg.com/")!

}

var path: String {
/// 기본 URL + path 로 URL 구성
switch self {
/// 동일한 path는 한 case로 처리 가능
case .getWineName:
return "wine"
case .getWineInfo(let wineId):
return "wine/\(wineId)"
case .getWineReview(let wineId):
return "wine/review/\(wineId)"
}
}

var method: Moya.Method {
/// 각 case 별로 적합한 method 배정
switch self {
case .getWineName, .getWineInfo, .getWineReview:
return .get
}
}

var task: Task {
switch self {
case .getWineName(let wineName):
return .requestParameters(parameters: ["searchName": wineName], encoding: URLEncoding.queryString)
case .getWineInfo, .getWineReview:
return .requestPlain
}
}

// API 호출 시, header에 token 넣어서 전달
var headers: [String : String]? {
let jwtToken = "jwt_token_here"
return [
"Authorization": "Bearer \(jwtToken)",
"Content-type": "application/json"
]
}

var validationType: ValidationType {
return .successCodes
}
}
69 changes: 59 additions & 10 deletions Drink-EG/Drink-EG/Resources/APIs/TastingNoteAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,90 @@ import Moya
enum TastingNoteAPI {
case getAllNotes
case getWineName(wineName: String)

case getNoteID(noteId: Int)
case postNewNote(wineId: Int, color: String, sugarContent: Int, acidity: Int, tannin: Int, body: Int, alcohol: Int, scentAroma: [String], scentTaste: [String], scentFinish: [String], satisfaction: Int, memo: String)
case patchNote(wineId: Int, color: String, sugarContent: Int, acidity: Int, tannin: Int, body: Int, alcohol: Int, scentAroma: [String], scentTaste: [String], scentFinish: [String], satisfaction: Int, review: String)
case deleteNote(noteId: Int)
}

extension TastingNoteAPI: TargetType {
var baseURL: URL {
/// 기본 URL 작성
return URL(string: "https://drinkeg.com/tasting-note/")!
return URL(string: "https://drinkeg.com/")!

}

var path: String {
/// 기본 URL + path 로 URL 구성
switch self {
/// 동일한 path는 한 case로 처리 가능
case .getWineName(let wineName):
return "\(wineName)"
case .getWineName:
return "wine"
case .getAllNotes:
return "all-note"
return "tasting-note/all-note"
case .getNoteID(let noteId):
return "tasting-note/\(noteId)"
case .postNewNote:
return "tasting-note/new-note"
case .patchNote(let wineId, let color, let sugarContent, let acidity, let tannin, let body, let alcohol, let scentAroma, let scentTaste, let scentFinish, let satisfaction, let review):
return "wine-note/\(wineId)"
case .deleteNote(let noteId):
return "tasting-note/\(noteId)"
}
}

var method: Moya.Method {
/// 각 case 별로 적합한 method 배정
switch self {
case .getWineName:
return .get
case .getAllNotes:
case .getWineName, .getAllNotes, .getNoteID:
return .get
case .postNewNote:
return .post
case .patchNote:
return .patch
case .deleteNote:
return .delete
}
}

var task: Task {
switch self {
case .getWineName(let wineName):
return .requestParameters(parameters: ["wineName": wineName], encoding: JSONEncoding.default)
case .getAllNotes:
return .requestParameters(parameters: ["searchName": wineName], encoding: URLEncoding.queryString)
case .getAllNotes, .getNoteID:
return .requestPlain
case .postNewNote(let wineId, let color, let sugarContent, let acidity, let tannin, let body, let alcohol, let scentAroma, let scentTaste, let scentFinish, let satisfaction, let review):
let parameters: [String: Any] = [
"wineId": wineId,
"color": color,
"sugarContent": sugarContent,
"acidity": acidity,
"tannin": tannin,
"body": body,
"alcohol": alcohol,
"scentAroma": scentAroma,
"scentTaste": scentTaste,
"scentFinish": scentFinish,
"satisfaction": satisfaction,
"review": review
]
return .requestParameters(parameters: parameters, encoding: JSONEncoding.default)
case .patchNote(_, let color, let sugarContent, let acidity, let tannin, let body, let alcohol, let scentAroma, let scentTaste, let scentFinish, let satisfaction, let review):
let parameters: [String: Any] = [
"color": color,
"sugarContent": sugarContent,
"acidity": acidity,
"tannin": tannin,
"body": body,
"alcohol": alcohol,
"scentAroma": scentAroma,
"scentTaste": scentTaste,
"scentFinish": scentFinish,
"satisfaction": satisfaction,
"review": review
]
return .requestParameters(parameters: parameters, encoding: JSONEncoding.default)
case .deleteNote:
return .requestPlain
}
}
Expand Down
Binary file not shown.
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"images" : [
{
"filename" : "1.png",
"filename" : "Group 415.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group [email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group [email protected]",
"idiom" : "universal",
"scale" : "3x"
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"images" : [
{
"filename" : "green.png",
"filename" : "Group 415.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group [email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group [email protected]",
"idiom" : "universal",
"scale" : "3x"
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"images" : [
{
"filename" : "blue.png",
"filename" : "Vector.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"scale" : "2x"
},
{
"filename" : "화이트.png",
"filename" : "Rectangle 111.png",
"idiom" : "universal",
"scale" : "3x"
}
Expand Down
30 changes: 30 additions & 0 deletions Drink-EG/Drink-EG/Sources/Datas/NoteResponse.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// NoteResponse.swift
// Drink-EG
//
// Created by 김도연 on 8/16/24.
//

import Foundation

struct NoteResponse : Codable {
let noteId : Int
let wineId : Int
let name : String
let picture : String
let color : String
let sugarContent : Int
let acidity : Int
let tannin : Int
let body : Int
let alcohol : Int
let scentAroma : [String]
let scentTaste : [String]
let scentFinish : [String]
let satisfaction : Double
let review : String?
}

struct ResponseWrap: Codable {
let result: NoteResponse
}
Loading

0 comments on commit 6b889e4

Please sign in to comment.