/** @format */

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

/**
 * 初始化ali oss
 * @param data 用户id
 * @param Id id
 */
export const initAliOSS = (data: any, Id: any) => {
	return web.request({
		url: "/oss/oss/ali/init",
		method: "get",
		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/ali/listDir",
		method: "get",
		params: {
			userId: userId,
			dirName: dirName,
			bucket: bucket,
		},
	});
};
/**
 * 查询Ali OSS所有桶
 * @param userId
 */
export const getAllAliOSsBucket = (userId: any) => {
	return web.request({
		url: `/oss/oss/ali/seleteBucket`,
		method: "post",
		params: {
			userId: userId,
		},
	});
};

/**
 * 获取所有阿里云oss配置
 * @param userId
 */
export const getAllAliOSSConfig = (userId: any) => {
	return web.request({
		url: `/oss/oss/ali/return_online`,
		method: "get",
		params: {
			userId: userId,
		},
	});
};
/**
 * 新增阿里云oss配置
 * @param data
 */
export const addAliOSSConfig = (data: API.AliOSSConfigRequest) => {
	return web.request({
		url: `/oss/oss/ali/add`,
		method: "post",
		headers: {
			"Content-Type": "application/json;charset=UTF-8",
		},
		data: data,
	});
};
/**
 * 注销阿里云oss配置
 * @param userId
 * @param Id
 */
export const setAliShutdown = (userId: any, Id: any) => {
	return web.request({
		url: `/oss/oss/ali/shutdown`,
		method: "post",
		params: {
			userId: userId,
			Id: Id,
		},
	});
};
/**
 * 删除阿里云oss配置
 * @param data
 */
export const deleteAliConfig = (data: any) => {
	return web.request({
		url: `/oss/oss/ali/delete`,
		method: "post",
		headers: {
			"Content-Type": "application/json;charset=UTF-8",
		},
		data: data,
	});
};

/**
 * 修改阿里云oss配置
 * @param data
 */
export const updateAliConfig = (data: any) => {
	return web.request({
		url: `/oss/oss/ali/update`,
		method: "post",
		headers: {
			"Content-Type": "application/json;charset=UTF-8",
		},
		data: data,
	});
};
/**
 * 获取阿里云oss配置详情
 * @param id
 */
export const getAliConfigDetailById = (id: any) => {
	return web.request({
		url: `/oss/oss/ali/one`,
		method: "get",
		params: {
			id: id,
		},
	});
};
