import {
  AccountParams,
  DeptListItem,
  MenuParams,
  RoleParams,
  RolePageParams,
  MenuListGetResultModel,
  PositionByOrgParams,
  DeptListGetResultModel,
  AccountListGetResultModel,
  RolePageListGetResultModel,
  RoleListGetResultModel,
  addDept,
  ReportParams,
  ReportListGetResultModel,
  NoticeListGetResultModel,
  UserListParams,
  UserListGetResultModel,
  StatisticalListGetResultModel,
} from './model/systemModel';
import { defHttp } from '@/utils/http/axios';

enum Api {
  DeptList = '/api/Orgs/OrgsTree',
  AccountList = '/api/users/load',
  AddAccount = '/api/Users/AddOrUpdate',
  DeleteAccount = '/api/Users/Delete',
  AddDept = '/api/Orgs/Add',
  UpdateDept = '/api/Orgs/Update',
  DeleteDept = '/api/Orgs/Delete',
  OrgList = '/api/Orgs/LoadPage',
  RolePageList = '/api/Roles/LoadPage',
  AddRole = '/api/Roles/Add',
  UpdateRole = '/api/Roles/Update',
  DeleteRole = '/api/Roles/Delete',
  MenuList = '/api/Modules/ModulesTree',
  ButtonList = '/api/Modules/ElementsByModule',
  AddMenu = '/api/Modules/Add',
  AddButton = '/api/Modules/AddMenu',
  EditMenu = '/api/Modules/Update',
  EditButton = '/api/Modules/UpdateMenu',
  DeleteMenu = '/api/Modules/Delete',
  DeleteButton = '/api/Modules/DeleteMenu',
  MenuDetail = '/api/Modules/ModuleById',
  PositionList = '/api/SysPosition/Load',
  AddPosition = '/api/SysPosition/Add',
  PosGroupList = '/api/SysPosGroup/Load',
  AddPosGroup = '/api/SysPosGroup/Add',
  PositionsTree = '/api/SysPosition/PositionsTree',
  OrgPosGroup = '/api/Orgs/OrgPosGroup',
  UserRoles = '/api/Users/UserRoles',
  OrgPositonTree = '/api/Orgs/OrgPositonTree',
  UserOrgs = '/api/Users/UserOrgs',
  AssignModule = '/api/Roles/AssignModule',
  LoadForRole = '/api/Modules/LoadForRole',
  LoadByRole = '/api/Users/LoadByRole',
  IsAccountExist = '/system/accountExist',
  setRoleStatus = '/system/setRoleStatus',
  GetAllRoleList = '/system/getAllRoleList',
  LoadPositionByOrg = '/api/SysPosition/LoadPositionByOrg',
  LoadDataBaseLinkTree = '/api/SysDatabaseLink/LoadDataBaseLinkTree',
  GetPosInfo = '/api/SysPosition/Get',
  UpdatePosition = '/api/SysPosition/Update',
  ReportList = '/api/DroneCaseinfo/LoadCaseInfoList',
  NoticeList = '/api/DroneCaseinfo/LoadMessageList',
  AddNotice = '/api/DroneCaseinfo/AddMessage',
  UpdateNotice = '/api/DroneCaseinfo/UpdateMessage',
  DeleteNotice = '/api/DroneCaseinfo/UpdateDelMessage',
  UserList = '/api/users/load',
  // StatisticalList='/api/DroneCaseinfo/CaseSynthesisCensus',
  StatisticalList = '/api/DroneCaseinfo/CaseSynthesisCensusSingle',
  StatisticalListExport = '/api/DroneCaseinfo/ExportCaseSynthesisCensusStreet',
  LoadNoticeDetail = '/api/DroneCaseinfo/LoadMessage',
  getChildrenTree = '/api/Orgs/LoadChildren',
  GetUserRoles = '/api/Roles/UserRoles',
  GetUserOrgs = '/api/Orgs/UserOrgs',
  GetSpecialData = '/api/Specialcolumn/GetDataColName',
}

export const getPositionsTree = (params?: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({ url: Api.PositionsTree, params });

export const getPositionList = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({ url: Api.PositionList, params });

export const getPosGroupList = (params?: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({ url: Api.PosGroupList, params });

export const getAccountList = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({ url: Api.AccountList, params });

export const getDeptList = (params?: DeptListItem) =>
  defHttp.get<DeptListGetResultModel>({ url: Api.DeptList, params });

export const getOrgList = (params?: DeptListItem) =>
  defHttp.get<DeptListGetResultModel>({ url: Api.OrgList, params });

export const getOrgPositonTree = (params?: DeptListItem) =>
  defHttp.get<DeptListGetResultModel>({ url: Api.OrgPositonTree, params });

export const loadForRole = (params?: DeptListItem) =>
  defHttp.get<DeptListGetResultModel>({ url: Api.LoadForRole, params });

export const loadByRole = (params?: DeptListItem) =>
  defHttp.get<DeptListGetResultModel>({ url: Api.LoadByRole, params });

export const getChildrenTree = (params: { parentId: number }) =>
  defHttp.get({ url: Api.getChildrenTree, params });

export function addAccount(params) {
  return defHttp.post({
    url: Api.AddAccount,
    params,
  });
}
export function deleteAccount(params) {
  return defHttp.post({
    url: Api.DeleteAccount,
    params,
  });
}

export function addPosGroup(params) {
  return defHttp.post({
    url: Api.AddPosGroup,
    params,
  });
}
export function orgPosGroup(params) {
  return defHttp.post({
    url: Api.OrgPosGroup,
    params,
  });
}
export function userRoles(params) {
  return defHttp.post({
    url: Api.UserRoles,
    params,
  });
}

export function userOrgs(params) {
  return defHttp.post({
    url: Api.UserOrgs,
    params,
  });
}

export function addPosition(params) {
  return defHttp.post({
    url: Api.AddPosition,
    params,
  });
}

export function updatePosition(params) {
  return defHttp.post({
    url: Api.UpdatePosition,
    params,
  });
}

export function addDept(params) {
  return defHttp.post({
    url: Api.AddDept,
    params,
  });
}
export function updateDept(params) {
  return defHttp.post({
    url: Api.UpdateDept,
    params,
  });
}
export function deleteDept(params) {
  return defHttp.post({
    url: Api.DeleteDept,
    params,
  });
}
export function addMenu(params) {
  return defHttp.post({
    url: Api.AddMenu,
    params,
  });
}
export function addButton(params) {
  return defHttp.post({
    url: Api.AddButton,
    params,
  });
}
export function editMenu(params) {
  return defHttp.post({
    url: Api.EditMenu,
    params,
  });
}
export function editButton(params) {
  return defHttp.post({
    url: Api.EditButton,
    params,
  });
}
export function deleteMenu(params) {
  return defHttp.post({
    url: Api.DeleteMenu,
    params,
  });
}
export function deleteButton(params) {
  return defHttp.post({
    url: Api.DeleteButton,
    params,
  });
}

export function addRole(params) {
  return defHttp.post({
    url: Api.AddRole,
    params,
  });
}
export function updateRole(params) {
  return defHttp.post({
    url: Api.UpdateRole,
    params,
  });
}
export function deleteRole(params) {
  return defHttp.post({
    url: Api.DeleteRole,
    params,
  });
}
export function assignModule(params) {
  return defHttp.post({
    url: Api.AssignModule,
    params,
  });
}

export const getMenuDetail = (params?: MenuParams) => defHttp.get({ url: Api.MenuDetail, params });

export const getMenuList = (params?: MenuParams) =>
  defHttp.get<MenuListGetResultModel>({ url: Api.MenuList, params });

export const getButtonList = (params?: MenuParams) =>
  defHttp.get<MenuListGetResultModel>({ url: Api.ButtonList, params });

export const getRoleListByPage = (params?: RolePageParams) =>
  defHttp.get<RolePageListGetResultModel>({ url: Api.RolePageList, params });

export const getAllRoleList = (params?: RoleParams) =>
  defHttp.get<RoleListGetResultModel>({ url: Api.GetAllRoleList, params });

export const setRoleStatus = (id: number, status: string) =>
  defHttp.post({ url: Api.setRoleStatus, params: { id, status } });

export const isAccountExist = (account: string) =>
  defHttp.post({ url: Api.IsAccountExist, params: { account } }, { errorMessageMode: 'none' });

export const getLoadPositionByOrg = (params?: PositionByOrgParams) =>
  defHttp.get<RolePageListGetResultModel>({ url: Api.LoadPositionByOrg, params });

export const getLoadDataBaseLinkTree = () => defHttp.get({ url: Api.LoadDataBaseLinkTree });

export const getPosInfo = (params) => defHttp.get({ url: Api.GetPosInfo, params });

export const getUserRoles = (params) => defHttp.get({ url: Api.GetUserRoles, params });

export const getUserOrgs = (params) => defHttp.get({ url: Api.GetUserOrgs, params });

export const getReportList = (params: ReportParams) =>
  defHttp.get<ReportListGetResultModel>({ url: Api.ReportList, params });

export const getStatisticalList = (params: ReportParams) =>
  defHttp.get<StatisticalListGetResultModel>({ url: Api.StatisticalList, params });

export const exportStatisticalList = (params: ReportParams) => {
  return defHttp.post({
    url: Api.StatisticalListExport,
    params,
  });
};

export const getNoticeList = (params?: Object) =>
  defHttp.get<NoticeListGetResultModel>({ url: Api.NoticeList, params });

export function addNotice(params) {
  return defHttp.post({
    url: Api.AddNotice,
    params,
  });
}

export function updateNotice(params) {
  return defHttp.post({
    url: Api.UpdateNotice,
    params,
  });
}

export function deleteNotice(params) {
  return defHttp.post({
    url: Api.DeleteNotice,
    params,
  });
}

export function getNoticeDetail(params) {
  return defHttp.get({
    url: Api.LoadNoticeDetail,
    params,
  });
}

export function getCaseInfoList(params) {
  return defHttp.get({
    url: Api.ReportList,
    params,
  });
}

export const getUserList = (params: UserListParams) =>
  defHttp.get<UserListGetResultModel>({ url: Api.UserList, params });

export const getSpecialData = () => defHttp.get({ url: Api.GetSpecialData });
