chore: modify service and hanler
This commit is contained in:
No files matched your search
@@ -2,7 +2,7 @@ import { xfetch } from '~/composables/useXfetch'
|
||||
|
||||
const mainUrl = '/api/v1/device'
|
||||
|
||||
export async function getSourceDevices(params: any = null) {
|
||||
export async function getDevices(params: any = null) {
|
||||
try {
|
||||
let url = mainUrl
|
||||
if (params && typeof params === 'object' && Object.keys(params).length > 0) {
|
||||
@@ -21,12 +21,12 @@ export async function getSourceDevices(params: any = null) {
|
||||
result.body = (resp.body as Record<string, any>) || {}
|
||||
return result
|
||||
} catch (error) {
|
||||
console.error('Error fetching source devices:', error)
|
||||
throw new Error('Failed to fetch source devices')
|
||||
console.error('Error fetching devices:', error)
|
||||
throw new Error('Failed to fetch devices')
|
||||
}
|
||||
}
|
||||
|
||||
export async function getSourceDeviceDetail(id: string | number) {
|
||||
export async function getDeviceDetail(id: string | number) {
|
||||
try {
|
||||
const resp = await xfetch(`${mainUrl}/${id}`, 'GET')
|
||||
const result: any = {}
|
||||
@@ -39,7 +39,7 @@ export async function getSourceDeviceDetail(id: string | number) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function postSourceDevice(data: any) {
|
||||
export async function postDevice(data: any) {
|
||||
try {
|
||||
const resp = await xfetch(mainUrl, 'POST', data)
|
||||
const result: any = {}
|
||||
@@ -52,7 +52,7 @@ export async function postSourceDevice(data: any) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function patchSourceDevice(id: string | number, data: any) {
|
||||
export async function patchDevice(id: string | number, data: any) {
|
||||
try {
|
||||
const resp = await xfetch(`${mainUrl}/${id}`, 'PATCH', data)
|
||||
const result: any = {}
|
||||
@@ -65,7 +65,7 @@ export async function patchSourceDevice(id: string | number, data: any) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function removeSourceDevice(id: string | number) {
|
||||
export async function removeDevice(id: string | number) {
|
||||
try {
|
||||
const resp = await xfetch(`${mainUrl}/${id}`, 'DELETE')
|
||||
const result: any = {}
|
||||
|
||||
Reference in New Issue
Block a user