u
This commit is contained in:
66
src/api/agentprinter.js
Normal file
66
src/api/agentprinter.js
Normal file
@@ -0,0 +1,66 @@
|
||||
import { http } from './http.js';
|
||||
|
||||
export const agentprinter = {
|
||||
/**
|
||||
* GET /api/agentprinter
|
||||
* Query: ?printeragentId=<id>
|
||||
* → { agentprinters: Agentprinter[] }
|
||||
*/
|
||||
list(printeragentId) {
|
||||
const url =
|
||||
printeragentId != null
|
||||
? `/api/agentprinter?printeragentId=${encodeURIComponent(printeragentId)}`
|
||||
: '/api/agentprinter';
|
||||
return http(url);
|
||||
},
|
||||
|
||||
/**
|
||||
* GET /api/agentprinter/:id
|
||||
* → { agentprinter: Agentprinter }
|
||||
*/
|
||||
get(id) {
|
||||
return http(`/api/agentprinter/${id}`);
|
||||
},
|
||||
|
||||
/**
|
||||
* PATCH /api/agentprinter/:id
|
||||
* Body: { enabled?: boolean, sort?: number }
|
||||
* → { agentprinter: Agentprinter }
|
||||
*/
|
||||
update(id, patch = {}) {
|
||||
const body = {};
|
||||
if (patch.enabled !== undefined) body.enabled = Boolean(patch.enabled);
|
||||
if (patch.sort !== undefined && patch.sort !== null && patch.sort !== '') {
|
||||
body.sort = Number(patch.sort);
|
||||
}
|
||||
return http(`/api/agentprinter/${id}`, {
|
||||
method: 'PATCH',
|
||||
body,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* PUT /api/agentprinter/order
|
||||
* Body: { printeragentId: number, agentprinterIds: number[] }
|
||||
* → { agentprinterIds: number[] }
|
||||
*/
|
||||
order({ printeragentId, agentprinterIds }) {
|
||||
return http('/api/agentprinter/order', {
|
||||
method: 'PUT',
|
||||
body: {
|
||||
printeragentId: Number(printeragentId),
|
||||
agentprinterIds: Array.isArray(agentprinterIds) ? agentprinterIds.map(Number) : [],
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* DELETE /api/agentprinter/:id → 204
|
||||
*/
|
||||
delete(id) {
|
||||
return http(`/api/agentprinter/${id}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user