import axios from '@/common/services/axios-instance'

class FrequentlyService {
  getCommonwordsList(params) {
    return axios({
      url: 'api/framework/v1/opinion-manager/opinion/list',
      method: 'post',
      data: params,
    })
  }

  // 获取所有参数个性化设置列表
  getPersonalsetesList() {
    return axios({
      url: `api/framework/v1/personalset-manager/personalsetes/list`,
    }).then((res) => {
      return res.data
    })
  }

  // 获取单个参数个性化设置列表
  getPersonalsetes(paramId) {
    return axios({
      url: `api/framework/v1/personalset-manager/personalsetes/${paramId}`,
    })
      .then((res) => {
        return res.data
      })
      .catch(() => ({}))
  }

  // 保存或更新个性化设置
  savePersonalsetes(params) {
    return axios({
      url: 'api/framework/v1/page/handleData',
      method: 'post',
      data: params,
    })
  }

  // 删除常用语
  deletePersonalOpinion(opinionId) {
    return axios({
      url: `api/framework/v1/page/oaPersonalOpinion?ids=${opinionId}`,
      method: 'delete',
    })
  }

  checkPersonalOpinion(params) {
    return axios
      .get('api/framework/v1/opinion-manager/opinion/check-repeat', { params })
      .then((res) => {
        return res.data
      })
  }
}

export default new FrequentlyService()
