-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from zerosome-dev/feature/home
✨[Feat] add mypage review list api
- Loading branch information
Showing
27 changed files
with
586 additions
and
235 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
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
42 changes: 42 additions & 0 deletions
42
Projects/App/Sources/Data/Repository/Review/ReviewRepository.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,42 @@ | ||
// | ||
// ReviewRepository.swift | ||
// App | ||
// | ||
// Created by 박서연 on 2024/08/30. | ||
// Copyright © 2024 iOS. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import Combine | ||
|
||
final class ReviewRepository: ReviewRepositoryProtocol { | ||
|
||
private let apiService: ApiService | ||
|
||
init(apiService: ApiService) { | ||
self.apiService = apiService | ||
} | ||
|
||
func getMyReviewList(offset: Int?, limit: Int?) -> Future<[MypageOffsetPageResult], NetworkError> { | ||
let parameters: [String : Int?] = ["offset" : offset ?? 0, "limit" : limit ?? 10] | ||
|
||
return Future { promise in | ||
Task { | ||
let response: Result<[MypageOffsetPageResponseDTO], NetworkError> = await self.apiService.request( | ||
httpMethod: .get, | ||
endPoint: APIEndPoint.url(for: .userReviewList), | ||
queryParameters: parameters, | ||
header: AccountStorage.shared.accessToken) | ||
|
||
switch response { | ||
case .success(let data): | ||
let mappedResult = data.map { ReviewMapper.toMyReviewOffsetResult(response: $0) } | ||
promise(.success(mappedResult)) | ||
case .failure(let failure): | ||
debugPrint("ReviewRepo > Get user review list > failed \(failure.localizedDescription)") | ||
promise(.failure(NetworkError.badRequest)) | ||
} | ||
} | ||
} | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
Projects/App/Sources/Domain/Entity/Review/MyReviewListResult.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,38 @@ | ||
// | ||
// MyReviewListResult.swift | ||
// App | ||
// | ||
// Created by 박서연 on 2024/08/30. | ||
// Copyright © 2024 iOS. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
// MARK: - 유저 작성 리뷰 목록 조회 api | ||
|
||
struct MypageOffsetPageResult { | ||
var content: ReviewByMemberResult | ||
var limit: Int | ||
var offset: Int | ||
} | ||
|
||
struct ReviewByMemberResult: Identifiable { | ||
var memberId: Int | ||
var nickname: String | ||
var reviewCnt: Int | ||
var reviewList: [ReviewDetailByMemberResult] | ||
|
||
var id = UUID().uuidString | ||
} | ||
|
||
struct ReviewDetailByMemberResult: Hashable, Equatable, Identifiable { | ||
var reviewId: Int | ||
var rating: Double | ||
var reviewContents: String | ||
var brand: String | ||
var productName: String | ||
var productImage: String | ||
var regDate: String | ||
|
||
var id = UUID().uuidString | ||
} |
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
13 changes: 13 additions & 0 deletions
13
Projects/App/Sources/Domain/Repository/ReviewRepositoryProtocol.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,13 @@ | ||
// | ||
// ReviewRepositoryProtocol.swift | ||
// App | ||
// | ||
// Created by 박서연 on 2024/08/30. | ||
// Copyright © 2024 iOS. All rights reserved. | ||
// | ||
|
||
import Combine | ||
|
||
protocol ReviewRepositoryProtocol { | ||
func getMyReviewList(offset: Int?, limit: Int?) -> Future<[MypageOffsetPageResult], NetworkError> | ||
} |
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,20 @@ | ||
// | ||
// ReviewUsecase.swift | ||
// App | ||
// | ||
// Created by 박서연 on 2024/08/30. | ||
// Copyright © 2024 iOS. All rights reserved. | ||
// | ||
|
||
import Combine | ||
|
||
struct ReviewUsecase { | ||
|
||
let reviewProtocol: ReviewRepositoryProtocol | ||
|
||
func getMyReviewList(offset: Int?, limit: Int?) -> Future<[MypageOffsetPageResult], NetworkError> { | ||
return reviewProtocol.getMyReviewList(offset: offset, limit: limit) | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.