import { defHttp } from '@/utils/http/axios';
import { TaskResultModel, AccountListItem, AccountParams, Task } from './model/index';

enum Api {
  // 管理员任务
  TaskList = "/api/AdminTaskManage/GteTaskListForAdmin",
  AddTask = "/api/AdminTaskManage/AddTask",
  EditTask = "/api/AdminTaskManage/EditTask",
  DeleteTask = "/api/AdminTaskManage/DeleteTask",
  DetailTask = "/api/AdminTaskManage/GteTaskById",
  GetAiShp = "/api/AdminTaskManage/GteAiShp",
  GetTif = "/api/AdminTaskManage/GteTif",
  // 普通用户任务
  PersonTaskList = "/api/PersonTask/Load",
  PersonTaskDetail = "/api/PersonTask/GetTaskDetail",
  SubmitPersonTask = "/api/PersonTask/SubmitTask",
  ReturnPersonTask = "/api/PersonTask/ReturnTask",
  // 组长-任务列表
  PersonTaskLoad = '/api/PersonTask/Load',
  // 组长-任务详情
  PersonTaskGetTaskDetail = '/api/PersonTask/GetTaskDetail',
  // 接收人
  LoadAllUsers = '/api/Users/LoadAll',
  // shape
  UpdateShape = "/api/InAiShp/Update",
  // tif
  UpdateTif = "/api/InsTif/Update",

}

// 管理员任务
export const getTaskList = (params) =>
  defHttp.get<TaskResultModel>({ url: Api.TaskList, params });

export const addTask = (params:Task) =>
  defHttp.post<TaskResultModel>({ url: Api.AddTask, params });

export const updateTask = (params:Task) =>
  defHttp.post<TaskResultModel>({ url: Api.EditTask, params });

export const deleteTask = (params) =>
  defHttp.post<TaskResultModel>({ url: Api.DeleteTask, params });

export const getTaskDetail = (params) =>
  defHttp.get<TaskResultModel>({ url: Api.DetailTask, params });

export const getAiShape = () =>
  defHttp.get<TaskResultModel>({ url: Api.GetAiShp });

export const getTif = () =>
  defHttp.get<TaskResultModel>({ url: Api.GetTif });

// 普通用户任务
export const getPersonTaskList = (params) =>
  defHttp.get<TaskResultModel>({ url: Api.PersonTaskList, params });

export const getPersonTaskDetail = (params) =>
  defHttp.get<TaskResultModel>({ url: Api.PersonTaskDetail, params });

export const submitTask = (params) =>
  defHttp.post<TaskResultModel>({ url: Api.SubmitPersonTask, params });

export const returnTask = (params) =>
  defHttp.post<TaskResultModel>({ url: Api.ReturnPersonTask, params });

// 组长-任务列表
export const PersonTaskLoad = (params) =>
  defHttp.get({ url: Api.PersonTaskLoad, params });
// 组长-任务详情
export const PersonTaskGetTaskDetail = (params) =>
  defHttp.get({ url: Api.PersonTaskGetTaskDetail, params });
// 接收人
export const LoadAllUsers = () =>
  defHttp.get({ url: Api.LoadAllUsers });

  // shape
export const updateShape = (params) =>
  defHttp.post<TaskResultModel>({ url: Api.UpdateShape,params });

  // tif
export const updateTif = (params) =>
  defHttp.post<TaskResultModel>({ url: Api.UpdateTif,params });
