feat: update wallet punch point and report success
This commit is contained in:
@ -13,7 +13,7 @@ protocol WildPhotographerReportServing {
|
||||
/// 拉取举报首页须知与规则文案。
|
||||
func reportCopy() async throws -> WildReportCopyResponse
|
||||
/// 提交摄影师举报。
|
||||
func submitReport(_ request: WildReportSubmitRequest) async throws
|
||||
func submitReport(_ request: WildReportSubmitRequest) async throws -> WildReportSubmitResponse
|
||||
/// 为已有举报补充证据。
|
||||
func supplementReport(_ request: WildReportSupplementRequest) async throws
|
||||
/// 拉取附近风险地图点位。
|
||||
@ -51,8 +51,8 @@ final class WildPhotographerReportAPI: WildPhotographerReportServing {
|
||||
}
|
||||
|
||||
/// 提交摄影师举报。
|
||||
func submitReport(_ request: WildReportSubmitRequest) async throws {
|
||||
let _: EmptyPayload = try await client.send(
|
||||
func submitReport(_ request: WildReportSubmitRequest) async throws -> WildReportSubmitResponse {
|
||||
try await client.send(
|
||||
APIRequest(
|
||||
method: .post,
|
||||
path: "/api/yf-handset-app/photog/report/submit",
|
||||
@ -209,6 +209,28 @@ struct WildReportSubmitRequest: Encodable, Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
/// 提交举报接口响应体,包含后端生成的举报 ID 和举报编号。
|
||||
struct WildReportSubmitResponse: Decodable, Equatable {
|
||||
let id: Int
|
||||
let complaintNo: String
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id
|
||||
case complaintNo = "complaint_no"
|
||||
}
|
||||
|
||||
init(id: Int = 0, complaintNo: String = "") {
|
||||
self.id = id
|
||||
self.complaintNo = complaintNo
|
||||
}
|
||||
|
||||
init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
id = try container.decodeIfPresent(Int.self, forKey: .id) ?? 0
|
||||
complaintNo = try container.decodeIfPresent(String.self, forKey: .complaintNo) ?? ""
|
||||
}
|
||||
}
|
||||
|
||||
/// 提交举报接口中的附件项。
|
||||
struct WildReportEvidenceRequest: Encodable, Equatable {
|
||||
let fileURL: String
|
||||
|
||||
@ -317,14 +317,14 @@ final class WildPhotographerReportSubmitViewModel {
|
||||
submitProgressText = "正在提交举报"
|
||||
notifyStateChange()
|
||||
|
||||
try await api.submitReport(buildSubmitRequest(
|
||||
let submitResponse = try await api.submitReport(buildSubmitRequest(
|
||||
scenicId: scenicId,
|
||||
scenicName: scenicName,
|
||||
evidences: evidenceRequests,
|
||||
paymentScreenshots: paymentRequests
|
||||
))
|
||||
|
||||
let record = buildSubmittedRecord()
|
||||
let record = buildSubmittedRecord(response: submitResponse)
|
||||
let result = WildReportSubmitResult(
|
||||
record: record,
|
||||
imageCount: images.count,
|
||||
@ -503,11 +503,11 @@ final class WildPhotographerReportSubmitViewModel {
|
||||
)
|
||||
}
|
||||
|
||||
private func buildSubmittedRecord() -> WildReportRecord {
|
||||
private func buildSubmittedRecord(response: WildReportSubmitResponse) -> WildReportRecord {
|
||||
let parsedContact = WildReportContactParser.parse(contact)
|
||||
return WildReportRecord(
|
||||
serverID: nil,
|
||||
id: "",
|
||||
serverID: response.id > 0 ? response.id : nil,
|
||||
id: response.complaintNo,
|
||||
title: "摄影师举报",
|
||||
reportType: selectedReportType ?? WildReportType(value: 0, label: ""),
|
||||
status: .pending,
|
||||
|
||||
Reference in New Issue
Block a user