Skip to content

Commit

Permalink
[WEAV-154] 프로필 이미지 리셋 API 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jisu15-kim committed Dec 7, 2024
1 parent 0387d64 commit 7275f51
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public protocol ProfileServiceProtocol {

func requestPutPartnerInfo(userInfo: UserInfo) async throws

func requestResetProfileImage(imageId: String) async throws

func requestUploadImage(image: Data) async throws
}

Expand Down Expand Up @@ -103,6 +105,11 @@ extension ProfileService: ProfileServiceProtocol {
return
}

public func requestResetProfileImage(imageId: String) async throws {
let result = try await client.deleteProfileImage(path: .init(imageId: imageId))
_ = try result.noContent
}

public func requestUploadImage(image: Data) async throws {
// url 받기
let uploadUrlInfo = try await requestPresignedUrl()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public final class ProfileServiceMock: ProfileServiceProtocol {
return
}

public func requestResetProfileImage(imageId: String) async throws {
print("✅ [ProfileServiceMock] requestResetProfileImage 성공!")
return
}

public func requestUploadImage(image: Data) async throws {
print("✅ [ProfileServiceMock] requestUploadImage 성공!")
return
Expand Down
10 changes: 7 additions & 3 deletions Projects/Model/Model/Sources/Auth/Domain/UserInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ public struct UserInfo: Equatable, Identifiable, Hashable {
self.profile = .init(from: dto.profile)
self.dreamPartner = .init(from: dto.desiredPartner)
self.profileWidgets = dto.profileWidgets.map { .init(from: $0) }
if let profileUrl = dto.profileImages?.first?.url {
self.profile.profileImageUrl = URL(string: profileUrl)
if let profileImage = dto.profileImages?.first {
self.profile.profileImageUrl = URL(string: profileImage.url)
self.profile.profileImageId = profileImage.id
}
}

Expand Down Expand Up @@ -91,6 +92,7 @@ public struct UserInfoProfile: Hashable, Identifiable, Equatable {
public var jobOccupationRawValue: String
public var locations: [LocationModel]
public var profileImageUrl: URL?
public var profileImageId: String?

public var companyName: String {
set {
Expand All @@ -113,7 +115,8 @@ public struct UserInfoProfile: Hashable, Identifiable, Equatable {
jobOccupation: String,
jobOccupationRawValue: String,
locations: [LocationModel],
profileImageUrl: URL? = nil
profileImageUrl: URL? = nil,
profileImageId: String? = nil
) {
self.gender = gender
self.birthYear = birthYear
Expand All @@ -123,6 +126,7 @@ public struct UserInfoProfile: Hashable, Identifiable, Equatable {
self.jobOccupationRawValue = jobOccupationRawValue
self.locations = locations
self.profileImageUrl = profileImageUrl
self.profileImageId = profileImageId
}

public init(from dto: Components.Schemas.UserProfileDisplayInfo) {
Expand Down

0 comments on commit 7275f51

Please sign in to comment.