import request from '@/utils/request'

/**
 * 上传接口
 * @param file
 * @param title
 * @param alt
 * @param url
 * @param filename
 * @param size
 * @param ext
 * @param pic
 * @param resolution
 * @param mine_type
 * @param etag
 * @returns {*}
 */
export function upload(file,title,alt,url,filename,size,ext,pic,resolution,mine_type,etag) {
  return request({
    url: '/api/attachment/upload',
    method: 'post',
    data: {
      file,
      title,
      alt,
      url,
      filename,
      size,
      ext,
      pic,
      resolution,
      mine_type,
      etag
    },
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

/**
 * 获取邮件设置
 * @returns {*}
 */
export function getMailSettings() {
  return request({
    url: '/api/user/mail-setting',
    method: 'get'
  })
}

/**
 * 设置邮件设置
 * @param id
 * @param from_name
 * @param from_email
 * @param smtp_port
 * @param smtp_server
 * @param auth_code
 * @param is_ssl
 * @returns {*}
 */
export function saveMailSetting(id,from_name,from_email,smtp_port,smtp_server,auth_code,is_ssl) {
  return request({
    url: '/api/user/mail-setting',
    method: 'post',
    data: {
      id,
      from_name,
      from_email,
      smtp_port,
      smtp_server,
      auth_code,
      is_ssl
    }
  })
}
