// @ts-ignore
/* eslint-disable */
import { request } from 'umi';

/** 获取当前的用户 GET  */
export async function currentUser(params: {
  person_id: number;
  identity_id: number;
  u_type: number;
  random_num?: number;
}) {
  return request('/dsideal_yy/ypt/userinfo/getUserInfo', {
    method: 'GET',
    params,
  });
}

/** 获取用户头像 GET  */
export async function queryPersonTxByYw(params: {
  person_id: number;
  identity_id: number;
  u_type?: number;
  random_num?: number;
}) {
  return request('/dsideal_yy/person/getPersonTxByYw', {
    method: 'GET',
    params,
  });
}

/** 退出登录接口 POST /api/login/outLogin */
export async function outLogin(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/dsideal_yy/login/doLogout?login_type=1', {
    method: 'POST',
    ...(options || {}),
  });
}

/** 登录校验接口 POST */
export async function checkLogin(body: API.LoginParams, options?: { [key: string]: any }) {  
  return request<API.LoginResult>('/dsideal_yy/checkLoginStatus', {
    method: 'POST', 
    requestType: 'form',
    data: body,
    ...(options || {}),
  });
}

/** 登录接口 POST */
export async function login(body: API.LoginParams, options?: { [key: string]: any }) {  
  return request<API.LoginResult>('/dsideal_yy/login/doLogin?login_type=1', {
    method: 'POST', 
    requestType: 'form',
    data: body,
    ...(options || {}),
  });
}

/** 此处后端没有提供注释 GET /api/notices */
export async function getNotices(options?: { [key: string]: any }) {
  return request<API.NoticeIconList>('/api/notices', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 获取规则列表 GET /api/rule */
export async function rule(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.RuleList>('/api/rule', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 新建规则 PUT /api/rule */
export async function updateRule(options?: { [key: string]: any }) {
  return request<API.RuleListItem>('/api/rule', {
    method: 'PUT',
    ...(options || {}),
  });
}

/** 新建规则 POST /api/rule */
export async function addRule(options?: { [key: string]: any }) {
  return request<API.RuleListItem>('/api/rule', {
    method: 'POST',
    ...(options || {}),
  });
}

/** 删除规则 DELETE /api/rule */
export async function removeRule(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/rule', {
    method: 'DELETE',
    ...(options || {}),
  });
}
