/** @format */

import web from "@/utils/axios/web.ts";

/**
 * 初始化Tencent oss
 * @param data 用户id
 * @param id
 */
export const initTencentOSS = (data: any, id: any) => {
	return web.request({
		url: "/oss/oss/tencent/init",
		method: "post",
		params: {
			userId: data,
			Id: id,
		},
	});
};
/**
 * 获取文件目录信息
 * @param userId 用户id
 * @param dirName 目录名称
 * @param bucket  桶名称
 */
export const getDirAndFileList = (userId: any, dirName: any, bucket: any) => {
	return web.request({
		url: "/oss/oss/tencent/listDir",
		method: "get",
		params: {
			userId: userId,
			dirName: dirName,
			bucket: bucket,
		},
	});
};
/**
 * 查询Tencent OSS所有桶
 * @param userId
 */
export const getAllTencentOSsBucket = (userId: any) => {
	return web.request({
		url: `/oss/oss/tencent/seleteBucket`,
		method: "post",
		params: {
			userId: userId,
		},
	});
};
/**
 * 查询Tencent OSS所有配置
 * @param userId
 */
export const getAllTencentOSsConfig = (userId: any) => {
	return web.request({
		url: `/oss/oss/tencent/return_online`,
		method: "get",
		params: {
			userId: userId,
		},
	});
};
/**
 * 新增腾讯云oss
 * @param data
 */
export const addTencentOSSConfig = (data: API.TencentOSSConfigRequest) => {
	return web.request({
		url: `/oss/oss/tencent/add`,
		method: "post",
		headers: {
			"Content-Type": "application/json;charset=UTF-8",
		},
		data: data,
	});
};

/**
 * 注销 Tencent oss配置
 * @param userId
 * @param Id
 */
export const setTencentShutdown = (userId: any, Id: any) => {
	return web.request({
		url: `/oss/oss/tencent/shutdown`,
		method: "post",
		params: {
			userId: userId,
			Id: Id,
		},
	});
};

/**
 * 删除Tencent oss配置
 * @param data
 */
export const deleteTencentConfig = (data: any) => {
	return web.request({
		url: `/oss/oss/tencent/delete`,
		method: "post",
		headers: {
			"Content-Type": "application/json;charset=UTF-8",
		},
		data: data,
	});
};

/**
 * 更新Tencent oss配置
 * @param data
 */
export const updateTencentConfig = (data: any) => {
	return web.request({
		url: `/oss/oss/tencent/update`,
		method: "post",
		headers: {
			"Content-Type": "application/json;charset=UTF-8",
		},
		data: data,
	});
};
/**
 * 获取腾讯云oss配置详情
 * @param id
 */
export const getTencentConfigDetailById = (id: any) => {
	return web.request({
		url: `/oss/oss/tencent/one`,
		method: "get",
		params: {
			Id: id,
		},
	});
};
