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

interface WorkshopType {
  name: string;
  code: string;
}

export interface RobotType {
  id?: number;
  robotName?: string;
  robotUrl?: string;
  workshopCodes?: WorkshopType[];
  workshopName?: string[];
  isPush?: boolean;
  tenantId?: number;
  isDelete?: boolean;
  createTime?: string;
  remark?: string | null;
}

export interface QueryType {
  pageNumber: number;
  pageSize: number;
}

interface ReturnType {
  records: RobotType[];
  pageNumber: number;
  pageSize: number;
  totalPage: number;
  totalRow: number;
}

/**
 * @description: 查询
 */
export function getRobot(params: QueryType) {
  return http.request<ReturnType>({
    url: 'robotPush/getList',
    method: 'get',
    params,
  });
}

/**
 * @description: 添加
 */
export function addRobot(data: RobotType) {
  return http.request({
    url: '/robotPush/save',
    method: 'post',
    data,
  });
}

/**
 * @description: 编辑
 */
export function editRobot(data: RobotType) {
  return http.request({
    url: '/robotPush/update',
    method: 'put',
    data,
  });
}

/**
 * @description: 删除
 *
 */
export function delRobot(id: number) {
  return http.request({
    url: `/robotPush/delete?id=${id}`,
    method: 'delete',
  });
}
