Skip to content

Commit

Permalink
Merge pull request #259 from boostcampwm2023/iOS/feat#236
Browse files Browse the repository at this point in the history
feat: 프로필 변경 화면 VIP 구현
  • Loading branch information
loinsir authored Dec 9, 2023
2 parents 11676c5 + abda7b7 commit ff95957
Show file tree
Hide file tree
Showing 19 changed files with 457 additions and 167 deletions.
24 changes: 5 additions & 19 deletions iOS/Layover/Layover.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
198167A32B20583D0032F563 /* SettingModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1981679E2B20583D0032F563 /* SettingModels.swift */; };
198167A42B20583D0032F563 /* SettingInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1981679F2B20583D0032F563 /* SettingInteractor.swift */; };
198167A62B20593B0032F563 /* SettingConfigurator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 198167A52B20593B0032F563 /* SettingConfigurator.swift */; };
198167A82B20DD670032F563 /* PresignedURLDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 198167A72B20DD670032F563 /* PresignedURLDTO.swift */; };
19A169232B176C5F00DB34C0 /* TagPlayListPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A1691D2B176C5F00DB34C0 /* TagPlayListPresenter.swift */; };
19A169242B176C5F00DB34C0 /* TagPlayListWorker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A1691E2B176C5F00DB34C0 /* TagPlayListWorker.swift */; };
19A169252B176C5F00DB34C0 /* TagPlayListRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A1691F2B176C5F00DB34C0 /* TagPlayListRouter.swift */; };
Expand Down Expand Up @@ -272,6 +273,7 @@
1981679E2B20583D0032F563 /* SettingModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingModels.swift; sourceTree = "<group>"; };
1981679F2B20583D0032F563 /* SettingInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingInteractor.swift; sourceTree = "<group>"; };
198167A52B20593B0032F563 /* SettingConfigurator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingConfigurator.swift; sourceTree = "<group>"; };
198167A72B20DD670032F563 /* PresignedURLDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresignedURLDTO.swift; sourceTree = "<group>"; };
19A1691D2B176C5F00DB34C0 /* TagPlayListPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagPlayListPresenter.swift; sourceTree = "<group>"; };
19A1691E2B176C5F00DB34C0 /* TagPlayListWorker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagPlayListWorker.swift; sourceTree = "<group>"; };
19A1691F2B176C5F00DB34C0 /* TagPlayListRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagPlayListRouter.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -627,6 +629,7 @@
FC4084C52B1F1C5B00CE4727 /* UploadPostDTO.swift */,
FC4084C92B1F291200CE4727 /* UploadVideoDTO.swift */,
1915D6E42B1FB82000CE1DD0 /* CheckSignUpDTO.swift */,
198167A72B20DD670032F563 /* PresignedURLDTO.swift */,
);
path = DTOs;
sourceTree = "<group>";
Expand Down Expand Up @@ -1042,15 +1045,14 @@
isa = PBXNativeTarget;
buildConfigurationList = FC7E45602AFEB62C004F155A /* Build configuration list for PBXNativeTarget "Layover" */;
buildPhases = (
FC182BD22B1D90C700051CBC /* SwiftLint Script */,
FC7E45322AFEB623004F155A /* Sources */,
FC7E45332AFEB623004F155A /* Frameworks */,
FC7E45342AFEB623004F155A /* Resources */,
FC182BD22B1D90C700051CBC /* SwiftLint Script */,
);
buildRules = (
);
dependencies = (
194552192B03DD7A00299768 /* PBXTargetDependency */,
);
name = Layover;
packageProductDependencies = (
Expand Down Expand Up @@ -1358,6 +1360,7 @@
FC68E2A52B0233D3001AABFF /* Provider.swift in Sources */,
FC930E7E2B0CDB2900AA48E3 /* ThumbnailCollectionViewCell.swift in Sources */,
194552112B03AF2B00299768 /* MainTabBarConfigurator.swift in Sources */,
198167A82B20DD670032F563 /* PresignedURLDTO.swift in Sources */,
8321A2F72B1E14A1000A12AF /* LOPopUpView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -1377,10 +1380,6 @@
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
194552192B03DD7A00299768 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = 194552182B03DD7A00299768 /* SwiftLintPlugin */;
};
FC7E454E2AFEB62C004F155A /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = FC7E45352AFEB623004F155A /* Layover */;
Expand Down Expand Up @@ -1668,14 +1667,6 @@
kind = branch;
};
};
FC7E456D2AFF6E44004F155A /* XCRemoteSwiftPackageReference "SwiftLint" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/realm/SwiftLint";
requirement = {
branch = main;
kind = branch;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand All @@ -1684,11 +1675,6 @@
package = 194551FB2B03863B00299768 /* XCRemoteSwiftPackageReference "kakao-ios-sdk" */;
productName = KakaoSDK;
};
194552182B03DD7A00299768 /* SwiftLintPlugin */ = {
isa = XCSwiftPackageProductDependency;
package = FC7E456D2AFF6E44004F155A /* XCRemoteSwiftPackageReference "SwiftLint" */;
productName = "plugin:SwiftLintPlugin";
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = FC7E452E2AFEB623004F155A /* Project object */;
Expand Down
9 changes: 7 additions & 2 deletions iOS/Layover/Layover/Network/DTOs/MemberDTO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation
struct MemberDTO: Decodable {
let id: Int
let username, introduce: String
let profileImageURL: String
let profileImageURL: String?

enum CodingKeys: String, CodingKey {
case id, username, introduce
Expand All @@ -21,11 +21,16 @@ struct MemberDTO: Decodable {

extension MemberDTO {
func toDomain() -> Member {
var imageURL: URL?
if let profileImageURL {
imageURL = URL(string: profileImageURL)
}

return Member(
identifier: id,
username: username,
introduce: introduce,
profileImageURL: URL(string: profileImageURL)
profileImageURL: imageURL
)
}
}
17 changes: 17 additions & 0 deletions iOS/Layover/Layover/Network/DTOs/PresignedURLDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// PresignedURLDTO.swift
// Layover
//
// Created by 김인환 on 12/7/23.
// Copyright © 2023 CodeBomber. All rights reserved.
//

import Foundation

struct PresignedURLDTO: Decodable {
let preSignedURL: String

enum CodingKeys: String, CodingKey {
case preSignedURL = "preSignedUrl"
}
}
8 changes: 0 additions & 8 deletions iOS/Layover/Layover/Network/DTOs/UploadVideoDTO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@

import Foundation

struct UploadVideoDTO: Decodable {
let preSignedURL: String

enum CodingKeys: String, CodingKey {
case preSignedURL = "preSignedUrl"
}
}

struct UploadVideoRequestDTO: Encodable {
let boardID: Int
let filetype: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ protocol UploadPostEndPointFactory {
latitude: Double,
longitude: Double,
tag: [String]) -> EndPoint<Response<UploadPostDTO>>
func makeUploadVideoEndPoint(boardID: Int, fileType: String) -> EndPoint<Response<UploadVideoDTO>>
func makeUploadVideoEndPoint(boardID: Int, fileType: String) -> EndPoint<Response<PresignedURLDTO>>
}

final class DefaultUploadPostEndPointFactory: UploadPostEndPointFactory {
Expand All @@ -33,7 +33,7 @@ final class DefaultUploadPostEndPointFactory: UploadPostEndPointFactory {
tag: tag))
}

func makeUploadVideoEndPoint(boardID: Int, fileType: String) -> EndPoint<Response<UploadVideoDTO>> {
func makeUploadVideoEndPoint(boardID: Int, fileType: String) -> EndPoint<Response<PresignedURLDTO>> {
return EndPoint(path: "/board/presigned-url",
method: .POST,
bodyParameters: UploadVideoRequestDTO(boardID: boardID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ protocol UserEndPointFactory {
func makeUserWithDrawEndPoint() -> EndPoint<Response<NicknameDTO>>
func makeUserInformationEndPoint(with id: Int?) -> EndPoint<Response<MemberDTO>>
func makeUserPostsEndPoint(at page: Int, of id: Int?) -> EndPoint<Response<[PostDTO]>>
func makeUserProfileImageDefaultEndPoint() -> EndPoint<Response<Data>>
func makeFetchUserProfilePresignedURL(of fileType: String) -> EndPoint<Response<PresignedURLDTO>>
}

final class DefaultUserEndPointFactory: UserEndPointFactory {
Expand Down Expand Up @@ -75,7 +77,6 @@ final class DefaultUserEndPointFactory: UserEndPointFactory {
}

func makeUserPostsEndPoint(at page: Int, of id: Int? = nil) -> EndPoint<Response<[PostDTO]>> {

var queryParameters = [String: String]()
queryParameters.updateValue(String(page), forKey: "page")

Expand All @@ -89,4 +90,22 @@ final class DefaultUserEndPointFactory: UserEndPointFactory {
queryParameters: queryParameters
)
}

func makeUserProfileImageDefaultEndPoint() -> EndPoint<Response<Data>> {
return EndPoint(
path: "/member/profile-image/default",
method: .POST
)
}

func makeFetchUserProfilePresignedURL(of fileType: String) -> EndPoint<Response<PresignedURLDTO>> {
var bodyParameters = [String: String]()
bodyParameters.updateValue(fileType, forKey: "filetype")

return EndPoint(
path: "/member/profile-image/presigned-url",
method: .POST,
bodyParameters: bodyParameters
)
}
}
34 changes: 25 additions & 9 deletions iOS/Layover/Layover/Network/Provider/Provider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ protocol ProviderType {
func request<R: Decodable, E: RequestResponsable>(with endPoint: E, authenticationIfNeeded: Bool, retryCount: Int) async throws -> R where E.Response == R
func request(url: URL) async throws -> Data
func request(url: String) async throws -> Data
func upload(data: Data, to url: String, method: HTTPMethod) async throws -> Data
func upload(data: Data, to presignedURL: String, method: HTTPMethod) async throws -> Data
func upload(fromFile: URL,
to url: String,
method: HTTPMethod,
sessionTaskDelegate: URLSessionTaskDelegate?,
delegateQueue: OperationQueue?) async throws -> Data
to url: String,
method: HTTPMethod,
sessionTaskDelegate: URLSessionTaskDelegate?,
delegateQueue: OperationQueue?) async throws -> Data
}

extension ProviderType {
Expand All @@ -29,12 +29,16 @@ extension ProviderType {
retryCount: retryCount)
}

func upload(data: Data, to url: String, method: HTTPMethod = .PUT) async throws -> Data {
func upload(data: Data, to presignedURL: String, method: HTTPMethod = .PUT) async throws -> Data {
return try await upload(data: data,
to: url,
to: presignedURL,
method: method)
}

func upload(from fileURL: URL, to url: String, method: HTTPMethod = .PUT) async throws -> Data {
return try await upload(from: fileURL, to: url, method: method)
}

func upload(fromFile: URL,
to url: String,
method: HTTPMethod = .PUT,
Expand Down Expand Up @@ -126,16 +130,28 @@ class Provider: ProviderType {
}

// 이미지 업로드용
func upload(data: Data, to url: String, method: HTTPMethod = .PUT) async throws -> Data {
guard let url = URL(string: url) else { throw NetworkError.components }
func upload(data: Data, to presignedURL: String, method: HTTPMethod = .PUT) async throws -> Data {
guard let contentType = URLComponents(string: presignedURL)?.queryItems?.first(where: { $0.name == "Content-Type"} )?.value,
let url = URL(string: presignedURL) else { throw NetworkError.components }
var request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData)
request.httpMethod = method.rawValue
request.setValue(contentType, forHTTPHeaderField: "Content-Type")

let (data, response) = try await session.upload(for: request, from: data)
try self.checkStatusCode(of: response)
return data
}

func upload(from fileURL: URL, to url: String, method: HTTPMethod = .PUT) async throws -> Data {
guard let url = URL(string: url) else { throw NetworkError.components }
var request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData)
request.httpMethod = method.rawValue

let (data, response) = try await session.upload(for: request, fromFile: fileURL)
try self.checkStatusCode(of: response)
return data
}

// 동영상 업로드용
func upload(fromFile: URL,
to url: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class EditProfileConfigurator: Configurator {
let viewController = viewController
let interactor = EditProfileInteractor()
let presenter = EditProfilePresenter()
let worker = MockUserWorker()
let worker = UserWorker()
let router = EditProfileRouter()

router.viewController = viewController
Expand Down
Loading

0 comments on commit ff95957

Please sign in to comment.