import { http } from '@/utils/http/axios';

export interface SceneModule {
  code: string;
  // createdAt: string,
  id: number;
  // isDeleted: number,
  name: string;
  remark: string;
  status: number;
  // updatedAt: string,
}

export interface SceneLabel {
  code: string;
  // createdAt: string,
  id: number;
  // isDeleted: number,
  name: string;
  remark: string;
  status: number;
  // updatedAt: string,
}

export interface WorkshopModule {
  code: string;
  // createdAt: string,
  id: number;
  // isDeleted: number,
  name: string;
  remark: string;
  status: number;
  // updatedAt: string,
}

export interface Records {
  code: string;
  createdAt: string;
  id: number;
  isDeleted: number;
  name: string;
  remark: string;
  status: number;
  updatedAt: string;
}

export interface Response<Records> {
  pageNumber: number;
  pageSize: number;
  records: Records[];
  totalPage: number;
  totalRow: number;
}

// 查询所有场景模板
export function getSceneModuleList(pageNumber: number, pageSize: number) {
  return http.request<Response<Records>>({
    url: '/template/findSceneModule',
    method: 'get',
    params: { pageNumber: pageNumber, pageSize: pageSize },
  });
}

// 根据场景名称查询场景模板
export function findSceneModuleByName(
  sceneModuleName: string,
  pageNumber: number,
  pageSize: number,
) {
  return http.request<Response<Records>>({
    url: '/template/findSceneModule',
    method: 'get',
    params: { pageNumber: pageNumber, pageSize: pageSize, sceneModuleName: sceneModuleName },
  });
}

// 查询所有场景标签模板
export function getSceneLabelList(pageNumber: number, pageSize: number) {
  return http.request<Response<Records>>({
    url: '/template/findSceneLabel',
    method: 'get',
    params: { pageNumber: pageNumber, pageSize: pageSize },
  });
}

// 根据场景标签名称查询场景标签模板
export function findSceneLabelByName(sceneLabelName: string, pageNumber: number, pageSize: number) {
  return http.request<Response<Records>>({
    url: '/template/findSceneLabel',
    method: 'get',
    params: { sceneLabelName: sceneLabelName, pageNumber: pageNumber, pageSize: pageSize },
  });
}

// 查询所有车间模板
export function getWorkshopModuleList(pageNumber: number, pageSize: number) {
  return http.request<Response<Records>>({
    url: '/template/findWorkshopModule',
    method: 'get',
    params: { pageNumber: pageNumber, pageSize: pageSize },
  });
}

// 根据车间名称查询车间模板
export function findWorkshopModuleByName(
  workshopModuleName: string,
  pageNumber: number,
  pageSize: number,
) {
  return http.request<Response<Records>>({
    url: '/template/findWorkshopModule',
    method: 'get',
    params: { workshopModuleName: workshopModuleName, pageNumber: pageNumber, pageSize: pageSize },
  });
}

// 添加场景模板
export function saveSceneModule(sceneModule: SceneModule) {
  return http.request({
    url: '/template/saveSceneModule',
    method: 'post',
    params: sceneModule,
  });
}

// 添加场景标签模板
export function saveSceneLabel(sceneLabel: SceneLabel) {
  return http.request({
    url: '/template/saveSceneLabel',
    method: 'post',
    params: sceneLabel,
  });
}

// 添加车间模板
export function saveWorkshopModule(workshopModule: WorkshopModule) {
  return http.request({
    url: '/template/saveWorkshopModule',
    method: 'post',
    params: workshopModule,
  });
}

// 删除场景模板
export function deleteSceneModule(sceneModuleId: number) {
  return http.request({
    url: `/template/deleteSceneModule?sceneModuleId=${sceneModuleId}`,
    method: 'delete',
  });
}

// 删除场景标签
export function deleteSceneLabel(sceneLabelId: number) {
  return http.request({
    url: `/template/deleteSceneLabel?sceneLabelId=${sceneLabelId}`,
    method: 'delete',
  });
}

// 删除车间模板
export function deleteWorkshopModule(workshopModuleId: number) {
  return http.request({
    url: `/template/deleteWorkshopModule?workshopModuleId=${workshopModuleId}`,
    method: 'delete',
  });
}

// 编辑场景模板
export function updateSceneModule(sceneModule: SceneModule) {
  return http.request({
    url: '/template/updateSceneModule',
    method: 'put',
    params: sceneModule,
  });
}

// 编辑场景标签
export function updateSceneLabel(sceneLabel: SceneLabel) {
  return http.request({
    url: '/template/updateSceneLabel',
    method: 'put',
    params: sceneLabel,
  });
}

// 编辑车间模板
export function updateWorkshopModule(workshopModule: WorkshopModule) {
  return http.request({
    url: '/template/updateWorkshopModule',
    method: 'put',
    params: workshopModule,
  });
}
