feat(admin): complete integration of auth, delivery, and system infrastructure modules

This commit is contained in:
comlibmb
2026-02-18 23:30:39 +08:00
parent 7b27694690
commit 5d00e3d74e
37 changed files with 2830 additions and 1075 deletions

View File

@@ -0,0 +1,144 @@
import { rpcOrNull, rpcOrValue, rpcOrEmptyArray } from '@/services/analytics/rpc.uts'
/**
* 管理员模型
*/
export type AdminUser = {
id: string
username: string
real_name: string | null
role: string
is_active: boolean
last_login_at: string | null
last_login_ip: string | null
roles: string[] | null
}
/**
* 角色模型
*/
export type AdminRole = {
id: string
name: string
code: string
description: string | null
is_active: boolean
created_at: string
updated_at: string
}
/**
* 权限/菜单模型
*/
export type AdminPermission = {
id: string
parent_id: string | null
name: string
code: string
type: string
path: string | null
icon: string | null
sort_order: number
is_visible: boolean
created_at: string
updated_at: string
}
/**
* 获取管理员列表
*/
export async function fetchAdminPage(
page: number,
pageSize: number,
search: string | null = null,
status: number | null = null
): Promise<{ total: number, items: Array<AdminUser> }> {
const res = await rpcOrNull('rpc_admin_get_admin_list', {
p_page: page,
p_page_size: pageSize,
p_search: search,
p_status: status
} as UTSJSONObject)
if (res == null) return { total: 0, items: [] as Array<AdminUser> }
return {
total: (res as any).total as number,
items: (res as any).items as Array<AdminUser>
}
}
/**
* 获取角色列表
*/
export async function fetchRolePage(
page: number,
pageSize: number,
search: string | null = null
): Promise<{ total: number, items: Array<AdminRole> }> {
const res = await rpcOrNull('rpc_admin_get_role_list', {
p_page: page,
p_page_size: pageSize,
p_search: search
} as UTSJSONObject)
if (res == null) return { total: 0, items: [] as Array<AdminRole> }
return {
total: (res as any).total as number,
items: (res as any).items as Array<AdminRole>
}
}
/**
* 保存角色
*/
export async function saveRole(role: any): Promise<string | null> {
const res = await rpcOrValue('rpc_admin_save_role', {
p_id: role.id,
p_name: role.name,
p_code: role.code,
p_description: role.description,
p_is_active: role.is_active
} as any)
return res != null ? String(res) : null
}
/**
* 删除角色
*/
export async function deleteRole(id: string): Promise<boolean> {
const ok = await rpcOrValue('rpc_admin_delete_role', { p_id: id } as any)
return ok === true
}
/**
* 获取权限菜单树列表
*/
export async function fetchPermissionList(): Promise<Array<AdminPermission>> {
return await rpcOrEmptyArray('rpc_admin_get_permission_list', {} as any) as Array<AdminPermission>
}
/**
* 保存权限菜单
*/
export async function savePermission(permission: any): Promise<string | null> {
const res = await rpcOrValue('rpc_admin_save_permission', {
p_id: permission.id,
p_parent_id: permission.parent_id,
p_name: permission.name,
p_code: permission.code,
p_type: permission.type,
p_path: permission.path,
p_icon: permission.icon,
p_sort_order: permission.sort_order,
p_is_visible: permission.is_visible
} as any)
return res != null ? String(res) : null
}
/**
* 删除权限菜单
*/
export async function deletePermission(id: string): Promise<boolean> {
const ok = await rpcOrValue('rpc_admin_delete_permission', { p_id: id } as any)
return ok === true
}

View File

@@ -0,0 +1,129 @@
import { rpcOrNull, rpcOrValue } from '@/services/analytics/rpc.uts'
/**
* 配送员模型
*/
export type DeliveryStaff = {
id: string
uid: string | null
nickname: string
avatar: string | null
phone: string
status: number
is_active: boolean
created_at: string
updated_at: string
}
/**
* 提货点模型
*/
export type DeliveryStation = {
id: string
name: string
phone: string
address: string
image: string | null
lng: number | null
lat: number | null
status: number
sort_order: number
business_hours: UTSJSONObject | null
created_at: string
updated_at: string
}
/**
* 获取配送员列表
*/
export async function fetchDeliveryStaffPage(
page: number,
pageSize: number,
search: string | null = null,
status: number | null = null
): Promise<{ total: number, items: Array<DeliveryStaff> }> {
const res = await rpcOrNull('rpc_admin_get_delivery_staff_list', {
p_page: page,
p_page_size: pageSize,
p_search: search,
p_status: status
} as UTSJSONObject)
if (res == null) return { total: 0, items: [] as Array<DeliveryStaff> }
return {
total: (res as any).total as number,
items: (res as any).items as Array<DeliveryStaff>
}
}
/**
* 保存配送员
*/
export async function saveDeliveryStaff(staff: any): Promise<string | null> {
const res = await rpcOrValue('rpc_admin_save_delivery_staff', {
p_id: staff.id,
p_nickname: staff.nickname,
p_avatar: staff.avatar,
p_phone: staff.phone,
p_status: staff.status
} as any)
return res != null ? String(res) : null
}
/**
* 删除配送员
*/
export async function deleteDeliveryStaff(id: string): Promise<boolean> {
const ok = await rpcOrValue('rpc_admin_delete_delivery_staff', { p_id: id } as any)
return ok === true
}
/**
* 获取提货点列表
*/
export async function fetchDeliveryStationPage(
page: number,
pageSize: number,
search: string | null = null,
status: number | null = null
): Promise<{ total: number, items: Array<DeliveryStation> }> {
const res = await rpcOrNull('rpc_admin_get_delivery_station_list', {
p_page: page,
p_page_size: pageSize,
p_search: search,
p_status: status
} as UTSJSONObject)
if (res == null) return { total: 0, items: [] as Array<DeliveryStation> }
return {
total: (res as any).total as number,
items: (res as any).items as Array<DeliveryStation>
}
}
/**
* 保存提货点
*/
export async function saveDeliveryStation(station: any): Promise<string | null> {
const res = await rpcOrValue('rpc_admin_save_delivery_station', {
p_id: station.id,
p_name: station.name,
p_phone: station.phone,
p_address: station.address,
p_image: station.image,
p_lng: station.lng,
p_lat: station.lat,
p_status: station.status,
p_sort_order: station.sort_order,
p_business_hours: station.business_hours
} as any)
return res != null ? String(res) : null
}
/**
* 删除提货点
*/
export async function deleteDeliveryStation(id: string): Promise<boolean> {
const ok = await rpcOrValue('rpc_admin_delete_delivery_station', { p_id: id } as any)
return ok === true
}

View File

@@ -0,0 +1,22 @@
import { rpcOrNull } from '@/services/analytics/rpc.uts'
/**
* 系统信息模型
*/
export type SystemInfo = {
server_os : string
web_server : string
db_engine : string
db_version : string
uts_runtime : string
auth_id : string
}
/**
* 获取服务器及系统环境信息
*/
export async function fetchSystemInfo() : Promise<SystemInfo | null> {
const res = await rpcOrNull('rpc_admin_get_system_info', {} as UTSJSONObject)
if (res == null) return null
return res as SystemInfo
}

View File

@@ -0,0 +1,41 @@
import { rpcOrNull, rpcOrValue } from '@/services/analytics/rpc.uts'
/**
* 系统配置项模型
*/
export type SystemConfig = {
config_key : string
config_value : UTSJSONObject
description ?: string
updated_at ?: string
}
/**
* 获取指定键的系统配置
*/
export async function getSystemConfig(key : string) : Promise<UTSJSONObject | null> {
const res = await rpcOrNull('rpc_admin_system_config_get', {
p_key: key
} as UTSJSONObject)
if (res == null) return null
return res as UTSJSONObject
}
/**
* 保存/更新系统配置
*/
export async function saveSystemConfig(key : string, value : UTSJSONObject, description : string | null = null) : Promise<boolean> {
const ok = await rpcOrValue('rpc_admin_system_config_save', {
p_key: key,
p_value: value,
p_description: description
} as any)
return ok === true
}
/**
* 批量获取配置 (可选扩展)
* 逻辑:如果后续有需求,可以补齐 rpc_admin_system_config_batch_get
*/