import axios from '../../../bc-libs/api.request'
import config from '@/config'

const systemPrefix = config.deploymentStandAlone?'':'cas/'

const prefix = systemPrefix+'api/v1/base/noticeUser'

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

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

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

/**
 * 新增
 * @param params
 * @returns {Promise<any>}
 */
export const addNoticeUser = (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 editNoticeUser = (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 deleteNoticeUser = (id) => {
  return new Promise((resolve, reject) => {
    axios.request({
      url: prefix+'/delete/'+id,
      method: 'POST',
    }).then(response => {
      resolve(response.data);
    }).catch(err => {
      reject(err)
    })
  })
}

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




