import { request, paramsSerializer } from '@/utils/request.js';

// customer-manage
export const customerQueryApi = (data) =>
  request({
    url: '/api/sys/custom/query',
    params: data,
  });
export const customerListApi = (data) =>
  request({
    url: '/api/sys/custom/list',
    params: data,
  });
export const customerDetailApi = (id) =>
  request({
    url: '/api/sys/custom/get',
    params: { id },
  });
export const customerEditApi = (data) => {
  if (data.id) {
    return request({
      url: '/api/sys/custom/update',
      data,
    });
  } else {
    return request({
      url: '/api/sys/custom/add',
      data,
    });
  }
};
export const customerDeleteApi = (id) =>
  request({
    url: '/api/sys/custom/delete',
    params: { id },
  });

// supplier-manage
export const supplierQueryApi = (data) =>
  request({
    url: '/api/sys/supplier/query',
    params: data,
  });
export const supplierListApi = (data) =>
  request({
    url: '/api/sys/supplier/list',
    params: data,
    // method: 'get',
  });
export const supplierDetailApi = (id) =>
  request({
    url: '/api/sys/supplier/get',
    params: { id },
    // method: 'get',
  });
export const supplierEditApi = (data) => {
  if (data.id) {
    return request({
      url: '/api/sys/supplier/update',
      data,
    });
  } else {
    return request({
      url: '/api/sys/supplier/add',
      data,
    });
  }
};
export const supplierEnableApi = (id) =>
  request({
    url: '/api/sys/supplier/enable',
    params: { id },
  });

// device-manage
export const deviceQueryApi = (data) =>
  request({
    url: '/api/sys/device/query',
    params: data,
  });
export const deviceListApi = (data) =>
  request({
    url: '/api/sys/device/list',
    params: data,
  });
export const deviceDetailApi = (id) =>
  request({
    url: '/api/sys/device/get',
    params: { id },
  });
export const deviceEditApi = (data) =>
  request({
    url: '/api/sys/device/save',
    data,
  });
export const deviceDestroyApi = (ids) =>
  request({
    url: '/api/sys/device/delete',
    params: { ids },
    paramsSerializer,
  });
export const deviceEnableApi = (ids, enable) =>
  request({
    url: enable ? '/api/sys/device/enable' : '/api/sys/device/disable',
    params: { ids },
    paramsSerializer,
  });
export const deviceBrandListApi = () =>
  request({
    url: '/api/sys/device/brand/list',
    // method: 'get',
  });

// service-level-manage
export const serviceLevelQueryApi = (data) =>
  request({
    url: '/api/sys/level/query',
    params: data,
  });
export const serviceLevelListApi = (data) =>
  request({
    url: '/api/sys/level/list',
    params: data,
    // method: 'get',
  });
export const serviceLevelDetailApi = (id) =>
  request({
    url: '/api/sys/level/get',
    params: { id },
    // method: 'get',
  });
export const serviceLevelEditApi = (data) => {
  if (data.id) {
    return request({
      url: '/api/sys/level/update',
      data,
    });
  } else {
    return request({
      url: '/api/sys/level/add',
      data,
    });
  }
};
export const serviceLevelDeleteApi = (id) =>
  request({
    url: '/api/sys/level/delete',
    params: { id },
  });

// checkin-manage
export const checkinQueryApi = (data) =>
  request({
    url: '/api/sys/ding/group/query',
    params: data,
    paramsSerializer,
  });
export const checkinListApi = (data) =>
  request({
    url: '/api/sys/ding/group/list',
    params: data,
  });
export const checkinEditApi = (data) => {
  if (data.id) {
    return request({
      url: '/api/sys/ding/group/update',
      data,
    });
  } else {
    return request({
      url: '/api/sys/ding/group/add',
      data,
    });
  }
};
export const checkinDeleteApi = (id) =>
  request({
    url: '/api/sys/ding/group/delete',
    params: { id },
  });

// log-manage
export const logListApi = (data) =>
  request({
    url: '/api/sys/log/page',
    params: data,
  });

// notice-manage
export const noticeQueryApi = (data) =>
  request({
    url: '/api/sys/notice/query',
    params: data,
  });
export const noticeEditApi = (data) => {
  return request({
    url: '/api/sys/notice/save',
    data,
  });
};
export const noticePublishApi = (id) =>
  request({
    url: '/api/sys/notice/publishOrUnpublish',
    params: { id },
  });
export const noticeCancelPublishApi = (id) =>
  request({
    url: '/api/sys/notice/publishOrUnpublish',
    params: { id },
  });
export const noticeDestroyApi = (ids) =>
  request({
    url: '/api/sys/notice/disable',
    params: { ids },
    paramsSerializer,
  });
// notice-message
export const noticeMessageQueryApi = (data) =>
  request({
    url: '/api/sys/message/query',
    params: data,
  });
export const noticeMessageCountApi = (noticeId) =>
  request({
    url: '/api/sys/message/count',
    params: { noticeId },
  });
export const noticeMessageExportApi = (data) =>
  request({
    url: '/api/sys/message/export',
    params: data,
  });

// task-manage
export const taskQueryApi = (data) =>
  request({
    url: '/api/admin/task/query',
    params: data,
  });
