order.js 808 B

1234567891011121314151617181920212223242526272829303132
  1. import { stringify } from 'qs';
  2. import request from '../utils/request';
  3. import { order } from '../utils/api';
  4. export async function query(params) {
  5. return request(`${order}?${stringify(params)}`);
  6. }
  7. export async function queryOne({ id }) {
  8. return request(`${order.replace('/:id', `/${id}`)}`);
  9. }
  10. export async function create(params) {
  11. const options = {
  12. method: 'POST',
  13. body: JSON.stringify(params),
  14. };
  15. return request(`${order.replace('/:id', '')}`, options);
  16. }
  17. export async function update(params) {
  18. const options = {
  19. method: 'PUT',
  20. body: JSON.stringify(params),
  21. };
  22. return request(`${order.replace('/:id', '')}`, options);
  23. }
  24. export async function remove({ id }) {
  25. const options = { method: 'DELETE' };
  26. return request(`${order.replace('/:id', `/${id}`)}`, options);
  27. }