/*
 * Copyright (c) 2024 LangChat. TyCoding All Rights Reserved.
 *
 * Licensed under the GNU Affero General Public License, Version 3 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.gnu.org/licenses/agpl-3.0.html
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import request from '@/config/axios'

/**
 * OSS对象存储服务接口
 */
export class OssApi {
  /**
   * 获取OSS上传策略
   */
  static policy() {
    return request.get({ 
      url: '/oss/policy' 
    })
  }

  /**
   * 获取文件列表
   */
  static list(params: any) {
    return request.get({ 
      url: '/oss/list', 
      params 
    })
  }

  /**
   * 删除文件
   */
  static del(objectName: string) {
    return request.delete({ 
      url: `/oss/${objectName}` 
    })
  }

  /**
   * 上传文件
   */
  static upload(data: FormData) {
    return request.post({
      url: '/aigc/oss/upload',
      headers: {
        'Content-Type': 'multipart/form-data',
      },
      data
    })
  }

  /**
   * 获取文件访问URL
   */
  static getUrl(objectName: string) {
    return request.get({ 
      url: `/oss/url/${objectName}` 
    })
  }
}
