/** @format */

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

/**
 * 初始化minio
 * @param data 用户id
 * @param id
 */
export const initMinioOSS = (data: any, id: any) => {
	return web.request({
		url: "/oss/oss/minio/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/minio/listMinioDir",
		method: "get",
		params: {
			userId: userId,
			dirName: dirName,
			bucket: bucket,
		},
	});
};
/**
 * 查询MinIO所有桶
 * @param userId
 */
export const getAllMinioBucket = (userId: any) => {
	return web.request({
		url: `/oss/oss/minio/seleteBucket`,
		method: "post",
		params: {
			userId: userId,
		},
	});
};
/**
 * 获取MinIO配置信息
 * @param userId
 */
export const getAllMinioConfig = (userId: any) => {
	return web.request({
		url: `/oss/oss/minio/return_online`,
		method: "get",
		params: {
			userId: userId,
		},
	});
};
/**
 * 新增阿里云oss配置
 * @param data
 */
export const addMinioOSSConfig = (data: API.MinioOSSConfigRequest) => {
	return web.request({
		url: `/oss/oss/minio/add`,
		method: "post",
		headers: {
			"Content-Type": "application/json;charset=UTF-8",
		},
		data: data,
	});
};
/**
 * 注销MinIo oss配置
 * @param userId
 * @param Id
 */
export const setMinioShutdown = (userId: any, Id: any) => {
	return web.request({
		url: `/oss/oss/minio/shutdown`,
		method: "post",
		params: {
			userId: userId,
			Id: Id,
		},
	});
};

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

/**
 * 删除Minio oss配置
 * @param data
 */
export const updateMinioConfig = (data: any) => {
	return web.request({
		url: `/oss/oss/minio/update`,
		method: "post",
		headers: {
			"Content-Type": "application/json;charset=UTF-8",
		},
		data: data,
	});
};
/**
 * 获取Minio oss配置详情
 * @param id
 */
export const getMinioConfigDetailById = (id: any) => {
	return web.request({
		url: `/oss/oss/minio/one`,
		method: "get",
		params: {
			Id: id,
		},
	});
};
