-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π :: (#121) νμκ°μ
μ±λ³ & νλ‘ν μΆκ°
- Loading branch information
Showing
46 changed files
with
1,119 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import RxFlow | ||
|
||
public enum GenderSettingStep: Step { | ||
case tabsIsRequired | ||
case genderSettingIsRequired(name: String, gcn: Int, email: String, password: String) | ||
case profileSettingIsRequired(name: String, gcn: Int, email: String, password: String, isMan: Bool) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import RxFlow | ||
|
||
public enum ProfileSettingStep: Step { | ||
case tabsIsRequired | ||
case profileSettingIsRequired(name: String, gcn: Int, email: String, password: String, isMan: Bool) | ||
case privacyIsRequired( | ||
name: String, | ||
gcn: Int, | ||
email: String, | ||
password: String, | ||
isMan: Bool, | ||
profileImageURL: String? | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 21 additions & 2 deletions
23
Projects/Data/Sources/DTO/Files/UploadFilesResponseDTO.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,24 @@ | ||
import Foundation | ||
import Domain | ||
|
||
struct UploadFilesResponseDTO: Decodable { | ||
let urls: [String] | ||
struct FetchPresignedURLResponseDTO: Decodable { | ||
let urls: [URLsResponseDTO] | ||
} | ||
|
||
struct URLsResponseDTO: Decodable { | ||
let filePath: String | ||
let presignedUrl: String | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case filePath = "file_path" | ||
case presignedUrl = "pre_signed_url" | ||
} | ||
} | ||
|
||
extension FetchPresignedURLResponseDTO { | ||
func toDomain() -> [PresignedURLEntity] { | ||
self.urls.map { | ||
.init(filePath: $0.filePath, presignedUrl: $0.presignedUrl) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,39 @@ | ||
import Moya | ||
import Foundation | ||
import Domain | ||
import Foundation | ||
import Moya | ||
import AppNetwork | ||
|
||
enum FilesAPI { | ||
case uploadFiles(data: [Data], fileName: String) | ||
public enum FilesAPI { | ||
case fetchPresignedURL(req: UploadFilesRequestDTO) | ||
} | ||
|
||
extension FilesAPI: JobisAPI { | ||
typealias ErrorType = JobisError | ||
public typealias ErrorType = JobisError | ||
|
||
var domain: JobisDomain { | ||
public var domain: JobisDomain { | ||
.files | ||
} | ||
|
||
var urlPath: String { | ||
return "" | ||
public var urlPath: String { | ||
return "/pre-signed" | ||
} | ||
|
||
var method: Moya.Method { | ||
public var method: Moya.Method { | ||
return .post | ||
} | ||
|
||
var task: Moya.Task { | ||
public var task: Moya.Task { | ||
switch self { | ||
case let .uploadFiles(data, fileName): | ||
var multipartData: [MultipartFormData] { | ||
data.map { | ||
MultipartFormData( | ||
provider: .data($0), | ||
name: "file", | ||
fileName: fileName | ||
) | ||
} | ||
} | ||
|
||
return .uploadCompositeMultipart( | ||
multipartData, | ||
urlParameters: ["type": "EXTENSION_FILE"] | ||
) | ||
case let .fetchPresignedURL(req): | ||
return .requestJSONEncodable(req) | ||
} | ||
} | ||
|
||
var jwtTokenType: JwtTokenType { | ||
public var jwtTokenType: JwtTokenType { | ||
.none | ||
} | ||
|
||
var errorMap: [Int: ErrorType]? { | ||
public var errorMap: [Int: ErrorType]? { | ||
return [:] | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
Projects/Data/Sources/DataSource/API/PresignedURLAPI.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import Moya | ||
import Foundation | ||
import AppNetwork | ||
import Domain | ||
|
||
public enum PresignedURLAPI { | ||
case uploadImageToS3(presignedURL: String, data: Data) | ||
} | ||
|
||
extension PresignedURLAPI: JobisAPI { | ||
public typealias ErrorType = JobisError | ||
|
||
public var domain: JobisDomain { | ||
.presignedURL | ||
} | ||
|
||
public var urlPath: String { | ||
"" | ||
} | ||
|
||
public var baseURL: URL { | ||
switch self { | ||
case let .uploadImageToS3(presignedURL, _): | ||
return URL(string: presignedURL)! | ||
} | ||
} | ||
|
||
public var path: String { | ||
return "" | ||
} | ||
|
||
public var method: Moya.Method { | ||
return .put | ||
} | ||
|
||
public var task: Moya.Task { | ||
switch self { | ||
case let .uploadImageToS3(_, data): | ||
return .requestData(data) | ||
} | ||
} | ||
|
||
public var headers: [String: String]? { | ||
return ["Content-Type": "image/jpg"] | ||
} | ||
|
||
public var jwtTokenType: JwtTokenType { | ||
.none | ||
} | ||
|
||
public var errorMap: [Int: JobisError]? { | ||
[:] | ||
} | ||
} |
12 changes: 6 additions & 6 deletions
12
Projects/Data/Sources/DataSource/Remote/RemoteFilesDataSource.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import RxSwift | ||
import Foundation | ||
import AppNetwork | ||
import Domain | ||
|
||
protocol RemoteFilesDataSource { | ||
func uploadFiles(data: [Data], fileName: String) -> Single<[String]> | ||
func fetchPresignedURL(req: UploadFilesRequestDTO) -> Single<[PresignedURLEntity]> | ||
} | ||
|
||
final class RemoteFilesDataSourceImpl: RemoteBaseDataSource<FilesAPI>, RemoteFilesDataSource { | ||
func uploadFiles(data: [Data], fileName: String) -> Single<[String]> { | ||
request(.uploadFiles(data: data, fileName: fileName)) | ||
.map(UploadFilesResponseDTO.self) | ||
.map(\.urls) | ||
func fetchPresignedURL(req: UploadFilesRequestDTO) -> Single<[PresignedURLEntity]> { | ||
request(.fetchPresignedURL(req: req)) | ||
.map(FetchPresignedURLResponseDTO.self) | ||
.map { $0.toDomain() } | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Projects/Data/Sources/DataSource/Remote/RemotePresignedURLDataSource.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import RxSwift | ||
import Foundation | ||
import AppNetwork | ||
import Domain | ||
|
||
protocol RemotePresignedURLDataSource { | ||
func uploadImageToS3(presignedURL: String, data: Data) -> Completable | ||
} | ||
|
||
final class RemotePresignedURLDataSourceImpl: RemoteBaseDataSource<PresignedURLAPI>, | ||
RemotePresignedURLDataSource { | ||
func uploadImageToS3(presignedURL: String, data: Data) -> Completable { | ||
request(.uploadImageToS3(presignedURL: presignedURL, data: data)) | ||
.asCompletable() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Projects/Data/Sources/Repositories/PresignedURLRepositoryImpl.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import RxSwift | ||
import Domain | ||
import Foundation | ||
|
||
struct PresignedURLRepositoryImpl: PresignedURLRepository { | ||
private let remotePresignedURLDataSource: any RemotePresignedURLDataSource | ||
|
||
init(remotePresignedURLDataSource: any RemotePresignedURLDataSource) { | ||
self.remotePresignedURLDataSource = remotePresignedURLDataSource | ||
} | ||
|
||
func uploadImageToS3(presignedURL: String, data: Data) -> Completable { | ||
remotePresignedURLDataSource.uploadImageToS3(presignedURL: presignedURL, data: data) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Projects/Domain/Sources/Entities/Files/PresignedEntity.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Foundation | ||
|
||
public struct PresignedURLEntity: Equatable { | ||
public let filePath: String | ||
public let presignedUrl: String | ||
|
||
public init(filePath: String, presignedUrl: String) { | ||
self.filePath = filePath | ||
self.presignedUrl = presignedUrl | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
Projects/Domain/Sources/Parameters/Files/UploadFilesRequestQuery.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import Foundation | ||
|
||
public struct UploadFileModel { | ||
public let file: Data | ||
public let fileName: String | ||
|
||
public init(file: Data, fileName: String) { | ||
self.file = file | ||
self.fileName = fileName | ||
} | ||
} | ||
|
||
public struct UploadFilesRequestDTO: Encodable { | ||
public let files: [FileRequestDTO] | ||
|
||
public init(files: [FileRequestDTO]) { | ||
self.files = files | ||
} | ||
} | ||
|
||
public struct FileRequestDTO: Encodable { | ||
public let type = "EXTENSION_FILE" | ||
public let fileName: String | ||
|
||
public init(fileName: String) { | ||
self.fileName = fileName | ||
} | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case fileName = "file_name" | ||
case type | ||
} | ||
} | ||
|
||
public extension [UploadFileModel] { | ||
func toRequestDTO() -> [FileRequestDTO] { | ||
self.map { .init(fileName: $0.fileName) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.