This commit is contained in:
menxipeng
2025-10-21 23:23:46 +08:00
parent e77d28abf7
commit 0d32f2d187
6 changed files with 561 additions and 183 deletions

View File

@@ -0,0 +1,49 @@
import {
ServiceListParams,
ServiceListResponse,
ServiceCreateParams,
ServiceUpdateParams,
ServiceResponse
} from '@/lib/types/service'
import { apiGet, apiPost, apiPut, apiDelete } from './api'
export async function getServiceList(params: ServiceListParams): Promise<ServiceListResponse> {
try {
const queryParams = new URLSearchParams({
pageSize: params.pageSize.toString(),
pageNum: params.pageNum.toString(),
})
return await apiGet<ServiceListResponse>(`/back/services/list?${queryParams}`)
} catch (error) {
console.error('Failed to fetch services:', error)
throw error
}
}
export async function createService(data: ServiceCreateParams): Promise<ServiceResponse> {
try {
return await apiPost<ServiceResponse>('/back/services/', data)
} catch (error) {
console.error('Failed to create service:', error)
throw error
}
}
export async function updateService(data: ServiceUpdateParams): Promise<ServiceResponse> {
try {
return await apiPut<ServiceResponse>('/back/services/', data)
} catch (error) {
console.error('Failed to update service:', error)
throw error
}
}
export async function deleteService(id: string): Promise<ServiceResponse> {
try {
return await apiDelete<ServiceResponse>(`/back/services/${id}`)
} catch (error) {
console.error('Failed to delete service:', error)
throw error
}
}

12
src/lib/services/user.ts Normal file
View File

@@ -0,0 +1,12 @@
import { UserByRoleResponse } from '@/lib/types/user'
import { apiGet } from './api'
export async function getUserByRoleKey(roleKey: string): Promise<UserByRoleResponse> {
try {
return await apiGet<UserByRoleResponse>(`/back/user/getUserByRoleKey?roleKey=${roleKey}`)
} catch (error) {
console.error(`Failed to fetch users with role ${roleKey}:`, error)
throw error
}
}

45
src/lib/types/service.ts Normal file
View File

@@ -0,0 +1,45 @@
export interface ValueAddedService {
id: string
serviceTitle: string
description: string
status: string
assignedAdmin: string
assignedCommon: string
createTime?: string
updateTime?: string
}
export interface ServiceListParams {
pageSize: number
pageNum: number
}
export interface ServiceListResponse {
code: number
msg: string
rows: ValueAddedService[]
total: number
}
export interface ServiceCreateParams {
serviceTitle: string
description: string
status: string
assignedAdmin: string
assignedCommon: string
}
export interface ServiceUpdateParams {
id: string
serviceTitle: string
description: string
status: string
assignedAdmin: string
assignedCommon: string
}
export interface ServiceResponse {
code: number
msg: string
data?: any
}

44
src/lib/types/user.ts Normal file
View File

@@ -0,0 +1,44 @@
export interface User {
createBy: string
createTime: string
updateBy: string | null
updateTime: string | null
remark: string | null
userId: string
deptId: string | null
userName: string
nickName: string
email: string
phonenumber: string
sex: string
avatar: string
password: string
status: string
delFlag: string
loginIp: string
loginDate: string
pwdUpdateDate: string | null
dept: any
roles: any[]
roleIds: any
postIds: any
roleId: string | null
roleName: string | null
provinceCode: string
parentId: string | null
type: string | null
mallId: string | null
businessLicense: string | null
businessType: string | null
address: string | null
provinceAddress: string | null
shopAddress: string | null
admin: boolean
}
export interface UserByRoleResponse {
msg: string
code: number
data: User[]
}