feat(material): finishing integration of material
This commit is contained in:
@@ -16,9 +16,7 @@ export async function getSourceDevices(params: any = null) {
|
||||
const resp = await xfetch(url, 'GET')
|
||||
const result: any = {}
|
||||
result.success = resp.success
|
||||
if (resp.success) {
|
||||
result.data = (resp.body as Record<string, any>).data
|
||||
}
|
||||
result.body = (resp.body as Record<string, any>) || {}
|
||||
return result
|
||||
} catch (error) {
|
||||
console.error('Error fetching source devices:', error)
|
||||
@@ -31,9 +29,7 @@ export async function getSourceDeviceDetail(id: string | number) {
|
||||
const resp = await xfetch(`/api/v1/device/${id}`, 'GET')
|
||||
const result: any = {}
|
||||
result.success = resp.success
|
||||
if (resp.success) {
|
||||
result.data = (resp.body as Record<string, any>).data
|
||||
}
|
||||
result.body = (resp.body as Record<string, any>) || {}
|
||||
return result
|
||||
} catch (error) {
|
||||
console.error('Error fetching device detail:', error)
|
||||
@@ -44,17 +40,23 @@ export async function getSourceDeviceDetail(id: string | number) {
|
||||
export async function postSourceDevice(data: any) {
|
||||
try {
|
||||
const resp = await xfetch('/api/v1/device', 'POST', data)
|
||||
return resp
|
||||
const result: any = {}
|
||||
result.success = resp.success
|
||||
result.body = (resp.body as Record<string, any>) || {}
|
||||
return result
|
||||
} catch (error) {
|
||||
console.error('Error creating device:', error)
|
||||
throw new Error('Failed to create device')
|
||||
}
|
||||
}
|
||||
|
||||
export async function putSourceDevice(id: string | number, data: any) {
|
||||
export async function patchSourceDevice(id: string | number, data: any) {
|
||||
try {
|
||||
const resp = await xfetch(`/api/v1/device/${id}`, 'PUT', data)
|
||||
return resp
|
||||
const resp = await xfetch(`/api/v1/device/${id}`, 'PATCH', data)
|
||||
const result: any = {}
|
||||
result.success = resp.success
|
||||
result.body = (resp.body as Record<string, any>) || {}
|
||||
return result
|
||||
} catch (error) {
|
||||
console.error('Error updating device:', error)
|
||||
throw new Error('Failed to update device')
|
||||
@@ -64,7 +66,10 @@ export async function putSourceDevice(id: string | number, data: any) {
|
||||
export async function removeSourceDevice(id: string | number) {
|
||||
try {
|
||||
const resp = await xfetch(`/api/v1/device/${id}`, 'DELETE')
|
||||
return resp
|
||||
const result: any = {}
|
||||
result.success = resp.success
|
||||
result.body = (resp.body as Record<string, any>) || {}
|
||||
return result
|
||||
} catch (error) {
|
||||
console.error('Error deleting device:', error)
|
||||
throw new Error('Failed to delete device')
|
||||
|
||||
@@ -50,9 +50,9 @@ export async function postSourceMaterial(record: any) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function putSourceMaterial(id: number | string, record: any) {
|
||||
export async function patchSourceMaterial(id: number | string, record: any) {
|
||||
try {
|
||||
const resp = await xfetch(`/api/v1/material/${id}`, 'PUT', record)
|
||||
const resp = await xfetch(`/api/v1/material/${id}`, 'PATCH', record)
|
||||
const result: any = {}
|
||||
result.success = resp.success
|
||||
result.body = (resp.body as Record<string, any>) || {}
|
||||
|
||||
Reference in New Issue
Block a user