feat: 更新素材管理和举报风险地图

This commit is contained in:
2026-07-09 12:20:02 +08:00
parent 9b92d81902
commit 42aca73588
42 changed files with 6164 additions and 1369 deletions

View File

@ -0,0 +1,140 @@
//
// MaterialManagementAPI.swift
// suixinkan
//
import Foundation
///
@MainActor
protocol MaterialManagementServing {
///
func list(status: Int, keyword: String?, page: Int, pageSize: Int) async throws -> MaterialListResponse
///
func detail(id: Int) async throws -> MaterialDetail
///
func setListingStatus(id: Int, listingStatus: Int) async throws
///
func delete(id: Int) async throws
///
func addTag(name: String) async throws -> Int
///
func upload(_ request: MaterialUploadRequest) async throws
///
func edit(_ request: MaterialUploadRequest) async throws
///
func scenicSpotListAll(scenicId: String) async throws -> ScenicSpotListResponse
}
/// API Android `NetworkApi` `media-album type=1`
@MainActor
final class MaterialManagementAPI: MaterialManagementServing {
private let client: APIClient
/// API
init(client: APIClient) {
self.client = client
}
/// `type=1`
func list(status: Int, keyword: String?, page: Int = 1, pageSize: Int = 10) async throws -> MaterialListResponse {
var items = [
URLQueryItem(name: "status", value: String(status)),
URLQueryItem(name: "type", value: "1"),
URLQueryItem(name: "page", value: String(max(page, 1))),
URLQueryItem(name: "page_size", value: String(max(pageSize, 1))),
]
if let keyword = keyword?.trimmingCharacters(in: .whitespacesAndNewlines), !keyword.isEmpty {
items.append(URLQueryItem(name: "keyword", value: keyword))
}
return try await client.send(
APIRequest(method: .get, path: "/api/app/media-album/list", queryItems: items)
)
}
/// `type=1`
func detail(id: Int) async throws -> MaterialDetail {
try await client.send(
APIRequest(
method: .get,
path: "/api/app/media-album/detail",
queryItems: [
URLQueryItem(name: "id", value: String(id)),
URLQueryItem(name: "type", value: "1"),
]
)
)
}
/// `type=1`
func setListingStatus(id: Int, listingStatus: Int) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(
method: .post,
path: "/api/app/media-album/operation",
queryItems: [
URLQueryItem(name: "id", value: String(id)),
URLQueryItem(name: "listing_status", value: String(listingStatus)),
URLQueryItem(name: "type", value: "1"),
]
)
)
}
/// `type=1`
func delete(id: Int) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(
method: .post,
path: "/api/app/media-album/delete",
queryItems: [
URLQueryItem(name: "id", value: String(id)),
URLQueryItem(name: "type", value: "1"),
]
)
)
}
///
func addTag(name: String) async throws -> Int {
try await client.send(
APIRequest(
method: .post,
path: "/api/app/media-album/add-tag",
queryItems: [URLQueryItem(name: "name", value: name)]
)
)
}
///
func upload(_ request: MaterialUploadRequest) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(method: .post, path: "/api/app/media-album/upload", body: request)
)
}
///
func edit(_ request: MaterialUploadRequest) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(method: .post, path: "/api/app/media-album/edit", body: request)
)
}
///
func scenicSpotListAll(scenicId: String) async throws -> ScenicSpotListResponse {
try await client.send(
APIRequest(
method: .get,
path: "/api/yf-handset-app/photog/scenic-spot/list-all",
queryItems: [URLQueryItem(name: "scenic_id", value: scenicId)]
)
)
}
}