Implement permission-driven home tab aligned with Android.
Load role-permission on first visit to drive menus, role-based layout, store card, and location reporting with account-scoped persistence and unit tests. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
66
suixinkan/Features/Home/API/HomeAPI.swift
Normal file
66
suixinkan/Features/Home/API/HomeAPI.swift
Normal file
@ -0,0 +1,66 @@
|
||||
//
|
||||
// HomeAPI.swift
|
||||
// suixinkan
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@MainActor
|
||||
/// 首页 API,封装权限、门店与位置上报相关接口。
|
||||
final class HomeAPI {
|
||||
private let client: APIClient
|
||||
|
||||
init(client: APIClient) {
|
||||
self.client = client
|
||||
}
|
||||
|
||||
/// 拉取当前账号全部角色权限配置。
|
||||
func rolePermissions() async throws -> [RolePermissionResponse] {
|
||||
try await client.send(
|
||||
APIRequest(method: .get, path: "/api/yf-handset-app/role-permission")
|
||||
)
|
||||
}
|
||||
|
||||
/// 拉取全部门店列表。
|
||||
func storeList() async throws -> StoreListResponse {
|
||||
try await client.send(
|
||||
APIRequest(method: .get, path: "/api/app/store/all")
|
||||
)
|
||||
}
|
||||
|
||||
/// 拉取摄影师位置上报详情。
|
||||
func locationDetail(staffId: String) async throws -> LocationDetailResponse {
|
||||
try await client.send(
|
||||
APIRequest(
|
||||
method: .get,
|
||||
path: "/api/yf-handset-app/photog/loacation/detail",
|
||||
queryItems: [URLQueryItem(name: "staff_id", value: staffId)]
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/// 上报摄影师位置。
|
||||
func reportLocation(
|
||||
staffId: String,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
address: String,
|
||||
type: Int,
|
||||
scenicId: String
|
||||
) async throws -> LocationReportResponse {
|
||||
try await client.send(
|
||||
APIRequest(
|
||||
method: .post,
|
||||
path: "/api/yf-handset-app/photog/loacation/report",
|
||||
queryItems: [
|
||||
URLQueryItem(name: "staff_id", value: staffId),
|
||||
URLQueryItem(name: "latitude", value: String(latitude)),
|
||||
URLQueryItem(name: "longitude", value: String(longitude)),
|
||||
URLQueryItem(name: "address", value: address),
|
||||
URLQueryItem(name: "type", value: String(type)),
|
||||
URLQueryItem(name: "scenic_id", value: scenicId),
|
||||
]
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user