Skip to content

Commit 2baf115

Browse files
committed
[Feat] #192 - 이미지 업로드 방식 필드 추가(어떤 값이 있는 지 몰라 일단 임시로 QR로 세팅)
1 parent bc9e402 commit 2baf115

7 files changed

Lines changed: 17 additions & 9 deletions

File tree

Neki-iOS/Features/Archive/Sources/Data/Sources/DefaultArchiveRepository.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ final actor DefaultArchiveRepository: ArchiveRepository {
4141
// MARK: - Create Logic
4242

4343
extension DefaultArchiveRepository {
44-
func registerPhoto(folderID: Int?, uploads: [(mediaID: Int, memo: String?)], favorite: Bool? = false) async throws {
45-
let uploadData = uploads.map { RegisterPhotoDTO.RegisterPhotoData(mediaID: $0.mediaID, memo: $0.memo, uploadMethod: "QR") }
44+
func registerPhoto(folderID: Int?, uploads: [(mediaID: Int, memo: String?, uploadMethod: PhotoUploadMethod)], favorite: Bool? = false) async throws {
45+
let uploadData = uploads.map {
46+
RegisterPhotoDTO.RegisterPhotoData(mediaID: $0.mediaID, memo: $0.memo, uploadMethod: $0.uploadMethod.rawValue)
47+
}
4648
let request = RegisterPhotoDTO.Request(folderID: folderID, uploads: uploadData, favorite: favorite)
4749
let endpoint = ArchiveEndpoint.registerPhoto(request: request)
4850
let _ = try await networkProvider.request(endpoint: endpoint)

Neki-iOS/Features/Archive/Sources/Domain/Sources/Client/ArchiveClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct ArchiveClient {
1414
public var fetchPhotoList: (_ folderId: Int?, _ size: Int?, _ sortOrder: String?) async throws -> [PhotoEntity]
1515
public var getAlbumList: () async throws -> [AlbumEntity]
1616
public var deletePhotoList: (_ photoIds: [Int]) async throws -> Void
17-
public var registerPhotos: (_ folderId: Int?, _ uploads: [(mediaID: Int, memo: String?)], _ favorite: Bool?) async throws -> Void
17+
public var registerPhotos: (_ folderId: Int?, _ uploads: [(mediaID: Int, memo: String?, uploadMethod: PhotoUploadMethod)], _ favorite: Bool?) async throws -> Void
1818
public var getFavoriteAlbumInfo: () async throws -> FavoriteAlbumEntity
1919
public var addFolder: (_ name: String) async throws -> Int
2020
public var deleteFolders: (_ folderIDs: [Int], _ deletePhotos: Bool) async throws -> Void

Neki-iOS/Features/Archive/Sources/Domain/Sources/Interfaces/Repositories/ArchiveRepository.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Foundation
1010
protocol ArchiveRepository: Sendable {
1111
// Create
1212
func addFolder(name: String) async throws -> Int
13-
func registerPhoto(folderID: Int?, uploads: [(mediaID: Int, memo: String?)], favorite: Bool?) async throws
13+
func registerPhoto(folderID: Int?, uploads: [(mediaID: Int, memo: String?, uploadMethod: PhotoUploadMethod)], favorite: Bool?) async throws
1414

1515
// Read
1616
func fetchPhotoList(folderID: Int?, size: Int?, sortOrder: String?) async throws -> [PhotoEntity]
@@ -27,3 +27,9 @@ protocol ArchiveRepository: Sendable {
2727
func deletePhotoList(photoIDs: [Int]) async throws
2828
func deleteFolders(folderIDs: [Int], deletePhotos: Bool) async throws
2929
}
30+
31+
public enum PhotoUploadMethod: String, Sendable {
32+
case qr = "QR"
33+
case gallery = "GALLERY"
34+
case share = "SHARE"
35+
}

Neki-iOS/Features/Archive/Sources/Presentation/Sources/Feature/ArchiveAlbumDetailFeature.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ struct ArchiveAlbumDetailFeature {
151151
await send(.registerPhotosResponse(
152152
Result {
153153
let mediaIds = try await imageUploadClient.upload(entities, .photoBooth)
154-
let uploads = mediaIds.map { (mediaID: $0, memo: String?.none) }
155-
try await archiveClient.registerPhotos(folderId: albumId, uploads: uploads, favorite: false)
154+
let uploads = mediaIds.map { (mediaID: $0, memo: String?.none, uploadMethod: PhotoUploadMethod.qr) }
155+
try await archiveClient.registerPhotos(folderId: albumId, uploads: uploads ,favorite: false)
156156
}
157157
))
158158
}

Neki-iOS/Features/Archive/Sources/Presentation/Sources/Feature/ArchiveFavoriteAlbumFeature.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ struct ArchiveFavoriteAlbumFeature {
134134
await send(.registerPhotosResponse(
135135
Result {
136136
let mediaIds = try await imageUploadClient.upload(entities, .photoBooth)
137-
let uploads = mediaIds.map { (mediaID: $0, memo: String?.none) }
137+
let uploads = mediaIds.map { (mediaID: $0, memo: String?.none, uploadMethod: PhotoUploadMethod.qr) }
138138
try await archiveClient.registerPhotos(folderId: nil, uploads: uploads, favorite: true)
139139
}
140140
))

Neki-iOS/Features/Archive/Sources/Presentation/Sources/Feature/ArchiveFeature.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ struct ArchiveFeature {
256256

257257
case let .addPhotoFromQRScanner(imageID):
258258
return .run { send in
259-
try await archiveClient.registerPhotos(nil, [(imageID, nil)], false)
259+
try await archiveClient.registerPhotos(nil, [(imageID, nil, PhotoUploadMethod.qr)], false)
260260
await send(.delegate(.showToast(NekiToastItem("이미지를 추가했어요", style: .success))))
261261
await send(.fetchPhotos)
262262
} catch: { error, send in

Neki-iOS/Features/Archive/Sources/Presentation/Sources/Feature/SelectUploadAlbumFeature.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct SelectUploadAlbumFeature {
7777
await send(.uploadResponse(
7878
Result {
7979
let mediaIds = try await imageUploadClient.upload(entities, .photoBooth)
80-
let uploads = mediaIds.map { (mediaID: $0, memo: String?.none) }
80+
let uploads = mediaIds.map { (mediaID: $0, memo: String?.none, uploadMethod: PhotoUploadMethod.qr) }
8181
try await archiveClient.registerPhotos(folderId: albumId, uploads: uploads, favorite: false)
8282
return albumId
8383
}

0 commit comments

Comments
 (0)