q q q
This commit is contained in:
49
src/lib/services/service.ts
Normal file
49
src/lib/services/service.ts
Normal 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
12
src/lib/services/user.ts
Normal 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
45
src/lib/types/service.ts
Normal 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
44
src/lib/types/user.ts
Normal 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[]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user