import request from '@/utils/request';
import { baseURL } from '@/config';

// 登录日志
export function loginLogData(data) {
  return request({
    url:
      '/loginLog/list?page=' +
      data.page +
      '&size=' +
      data.size +
      '&userName=' +
      data.userName +
      '&start=' +
      data.start +
      '&end=' +
      data.end,
    method: 'get',
    data,
  });
}

// 删除登录日志
export function removeLoginData(data) {
  return request({
    url: '/loginLog/remove',
    method: 'post',
    data,
  });
}

// 登录日志导出
export function exportLoginLog(data) {
  let param = '?start=' + data.start + '&end=' + data.end;
  if (data.userName != '') {
    param += '&userName=' + data.userName;
  }
  return baseURL + '/loginLog/export' + param;
}

// 查询操作类型
export function getBusinessType(data) {
  return request({
    url: '/operLog/businessType',
    method: 'get',
    data,
  });
}

// 操作日志
export function actionLogData(data) {
  let param = '?page=' + data.page + '&size=' + data.size;
  if (data.businessType != '') {
    param += '&businessType=' + data.businessType;
  }
  if ((data.status != '' && data.status != 2) || data.status == 0) {
    param += '&status=' + data.status;
  }
  if (data.operName != '') {
    param += '&operName=' + data.operName;
  }
  return request({
    url: '/operLog/list' + param,
    method: 'get',
    data,
  });
}
// 删除操作日志
export function removeActionLog(data) {
  return request({
    url: '/operLog/remove',
    method: 'post',
    data,
  });
}
// 导出操作日志
export function exportActionLog(data) {
  let param = '?start=' + data.start + '&end=' + data.end;
  if (data.businessType != '') {
    param += '&businessType=' + data.businessType;
  }
  if (data.operName != '') {
    param += '&operName=' + data.operName;
  }
  if ((data.status != '' && data.status != 2) || data.status == 0) {
    param += '&status=' + data.status;
  }
  return baseURL + '/operLog/export' + param;
}
