import Axios from 'axios'
import {
  REQUEST_CONFIG, USER_LOGIN_LOG_SPLIT, USER_LOGIN_LOG_COUNT, USER_LOGIN_LOG_DOWNLOAD,
  USER_OPTION_LOG_SPLIT, USER_OPTION_LOG_COUNT, USER_OPTION_LOGDOWNLOAD
} from "../../utils/RequestUrls";

var staticMethods = {
  // 条件分页查询登录日志
  putQueryLoginLogSplitByCondition: function (beginItem, endItem, selectList) {
    return Axios.put(USER_LOGIN_LOG_SPLIT+beginItem+"/"+endItem,selectList,REQUEST_CONFIG);
  },

  //条件分页查询操作日志
  putQueryOptionLogSplitByCondition: function (beginItem, endItem, selectList) {
    return Axios.put(USER_OPTION_LOG_SPLIT+beginItem+"/"+endItem,selectList,REQUEST_CONFIG);
  },

  // 添加查询登录日志总条数
  putQueryLoginLogCountsByCondition: function (selectList) {
    return Axios.put(USER_LOGIN_LOG_COUNT, selectList, REQUEST_CONFIG);
  },

  //添加查询操作日志总条数
  putQueryOLogCountsByCondition: function (selectList) {
    return Axios.put(USER_OPTION_LOG_COUNT, selectList, REQUEST_CONFIG);
  },

  // 导出用户登录日志
  putExportLoginLogToExcel: function (selectList) {
    return Axios.put(USER_LOGIN_LOG_DOWNLOAD, selectList, {
      headers: {
        'Content-Type': 'application/json'
      },
      responseType: 'arraybuffer'
    });
  },

  //导出用户操作日志
  putExportOptionLogToExcel: function (selectList) {
    return Axios.put(USER_OPTION_LOGDOWNLOAD, selectList, {
      headers: {
        'Content-Type': 'application/json'
      },
      responseType: 'arraybuffer'
    });
  }
};

function UserLogAPI (websocketService = null) {

  return Object.freeze(Object.assign(
    {
      // object methods comes here
    },
    staticMethods
  ))
}
// inject static methods
Object.assign(UserLogAPI, staticMethods);
export default UserLogAPI
