Initial commit: suixinkan_ios UIKit rewrite project.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-26 14:33:31 +08:00
commit 9edf993432
297 changed files with 47151 additions and 0 deletions

View File

@ -0,0 +1,176 @@
//
// ProjectAPI.swift
// suixinkan
//
// Created by Codex on 2026/6/24.
//
import Foundation
/// 便 ViewModel
@MainActor
protocol ProjectServing {
///
func projectList(scenicId: Int, name: String?, page: Int, pageSize: Int) async throws -> ListPayload<PhotographerProjectItem>
///
func projectDetail(id: Int) async throws -> PhotographerProjectDetailResponse
///
func createProject(_ request: ProjectCreateRequest) async throws
///
func editProject(_ request: ProjectCreateRequest) async throws
///
func deleteProject(id: Int) async throws
///
func storeManagerScenicList(userId: String) async throws -> ListPayload<StoreManagerScenicItem>
///
func storeManagerProjectList(userId: String?, page: Int, pageSize: Int) async throws -> ListPayload<PhotographerProjectItem>
///
func storeManagerProjectDetail(id: Int) async throws -> PhotographerProjectDetailResponse
///
func storeManagerCreate(_ request: StoreManagerCreateRequest) async throws
///
func storeManagerOfflineCreate(_ request: StoreManagerOfflineCreateRequest) async throws
///
func storeManagerUpdate(_ request: StoreManagerUpdateRequest) async throws
///
func storeManagerOfflineUpdate(_ request: StoreManagerOfflineUpdateRequest) async throws
///
func storeManagerDeleteProject(id: Int) async throws
///
func storeAll() async throws -> ListPayload<StoreItem>
}
/// API
@MainActor
final class ProjectAPI: ProjectServing {
private let client: APIClient
/// API
init(client: APIClient) {
self.client = client
}
///
func projectList(scenicId: Int, name: String? = nil, page: Int = 1, pageSize: Int = 10) async throws -> ListPayload<PhotographerProjectItem> {
var query = [
URLQueryItem(name: "scenic_id", value: "\(scenicId)"),
URLQueryItem(name: "page", value: "\(max(page, 1))"),
URLQueryItem(name: "page_size", value: "\(max(pageSize, 1))")
]
if let name = name?.trimmingCharacters(in: .whitespacesAndNewlines), !name.isEmpty {
query.append(URLQueryItem(name: "name", value: name))
}
return try await client.send(
APIRequest(method: .get, path: "/api/yf-handset-app/photog/project/list", queryItems: query)
)
}
///
func projectDetail(id: Int) async throws -> PhotographerProjectDetailResponse {
try await client.send(
APIRequest(
method: .get,
path: "/api/yf-handset-app/photog/project/info-view",
queryItems: [URLQueryItem(name: "id", value: "\(id)")]
)
)
}
///
func createProject(_ request: ProjectCreateRequest) async throws {
_ = try await client.send(
APIRequest(method: .post, path: "/api/yf-handset-app/photog/project/create", body: request)
) as EmptyPayload
}
///
func editProject(_ request: ProjectCreateRequest) async throws {
_ = try await client.send(
APIRequest(method: .post, path: "/api/yf-handset-app/photog/project/edit", body: request)
) as EmptyPayload
}
///
func deleteProject(id: Int) async throws {
_ = try await client.send(
APIRequest(method: .post, path: "/api/yf-handset-app/photog/project/delete", body: ProjectDeleteRequest(id: id))
) as EmptyPayload
}
///
func storeManagerScenicList(userId: String) async throws -> ListPayload<StoreManagerScenicItem> {
try await client.send(
APIRequest(
method: .get,
path: "/api/app/store-manager/scenic-list",
queryItems: [URLQueryItem(name: "user_id", value: userId)]
)
)
}
///
func storeManagerProjectList(userId: String?, page: Int = 1, pageSize: Int = 20) async throws -> ListPayload<PhotographerProjectItem> {
var query = [
URLQueryItem(name: "page", value: "\(max(page, 1))"),
URLQueryItem(name: "page_size", value: "\(max(pageSize, 1))")
]
if let userId = userId?.trimmingCharacters(in: .whitespacesAndNewlines), !userId.isEmpty {
query.append(URLQueryItem(name: "user_id", value: userId))
}
return try await client.send(
APIRequest(method: .get, path: "/api/app/store-manager/list", queryItems: query)
)
}
///
func storeManagerProjectDetail(id: Int) async throws -> PhotographerProjectDetailResponse {
try await client.send(
APIRequest(method: .get, path: "/api/app/store-manager/detail", queryItems: [URLQueryItem(name: "id", value: "\(id)")])
)
}
///
func storeManagerCreate(_ request: StoreManagerCreateRequest) async throws {
_ = try await client.send(APIRequest(method: .post, path: "/api/app/store-manager/create", body: request)) as EmptyPayload
}
///
func storeManagerOfflineCreate(_ request: StoreManagerOfflineCreateRequest) async throws {
_ = try await client.send(APIRequest(method: .post, path: "/api/app/store-manager/offline-create", body: request)) as EmptyPayload
}
///
func storeManagerUpdate(_ request: StoreManagerUpdateRequest) async throws {
_ = try await client.send(APIRequest(method: .post, path: "/api/app/store-manager/update", body: request)) as EmptyPayload
}
///
func storeManagerOfflineUpdate(_ request: StoreManagerOfflineUpdateRequest) async throws {
_ = try await client.send(APIRequest(method: .post, path: "/api/app/store-manager/offline-update", body: request)) as EmptyPayload
}
///
func storeManagerDeleteProject(id: Int) async throws {
_ = try await client.send(
APIRequest(method: .post, path: "/api/app/store-manager/delete", body: ProjectDeleteRequest(id: id))
) as EmptyPayload
}
///
func storeAll() async throws -> ListPayload<StoreItem> {
try await client.send(APIRequest(method: .get, path: "/api/app/store/all"))
}
}