import axios from 'bc-common-ui-vue3/src/bc-components/bc-libs/api.request'

const prefix = 'cas/api/v1/base/sysLog'

/**
 * 分页查询方法
 * @param parmas
 * @returns {*|void|ClientRequest|ClientHttp2Stream|never|AxiosPromise<any>}
 */
export const getSysLogPage = (parmas) => {
  return axios.request({
    url: prefix + '/page',
    params: parmas,
    method: 'get',
  })
}

/**
 * 根据参数查询列表
 * @param parmas
 * @returns {*|void|ClientRequest|ClientHttp2Stream|never|AxiosPromise<any>}
 */
export const getSysLogList = (parmas) => {
  return axios.request({
    url: prefix + '/list',
    params: parmas,
    method: 'get',
  })
}

/**
 * 新增
 * @param params
 * @returns {Promise<any>}
 */
export const addSysLog = (params) => {
  return new Promise((resolve, reject) => {
    axios
      .request({
        url: prefix + '/add',
        method: 'POST',
        data: params,
      })
      .then((response) => {
        resolve(response.data)
      })
      .catch((err) => {
        reject(err)
      })
  })
}

/**
 * 修改
 * @param params
 * @returns {Promise<any>}
 */
export const editSysLog = (params) => {
  return new Promise((resolve, reject) => {
    axios
      .request({
        url: prefix + '/merge',
        method: 'POST',
        data: params,
      })
      .then((response) => {
        resolve(response.data)
      })
      .catch((err) => {
        reject(err)
      })
  })
}

/**
 * 删除
 * @param id
 * @returns {Promise<any>}
 */
export const deleteSysLog = (id) => {
  return new Promise((resolve, reject) => {
    axios
      .request({
        url: prefix + '/delete/' + id,
        method: 'POST',
      })
      .then((response) => {
        resolve(response.data)
      })
      .catch((err) => {
        reject(err)
      })
  })
}
