/** @format */

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

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

export const getAllQiniuConfigs = (userId: any) => {
	return web.request({
		url: `/oss/oss/qiniu/return_online`,
		method: "get",
		params: {
			userId: userId,
		},
	});
};

/**
 * 新增七牛oss配置
 * @param data
 */
export const addQiniuOSSConfig = (data: API.QiniuOSSConfigRequest) => {
	return web.request({
		url: `/oss/oss/qiniu/add`,
		method: "post",
		headers: {
			"Content-Type": "application/json;charset=UTF-8",
		},
		data: data,
	});
};

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

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

/**
 * 更新Qiniu oss配置
 * @param data
 */
export const updateQiniuConfig = (data: any) => {
	return web.request({
		url: `/oss/oss/qiniu/update`,
		method: "post",
		headers: {
			"Content-Type": "application/json;charset=UTF-8",
		},
		data: data,
	});
};
/**
 * 获取Qiniu oss配置
 * @param id
 */
export const getQiniuConfigDetailById = (id: any) => {
	return web.request({
		url: `/oss/oss/qiniu/one`,
		method: "get",
		params: {
			Id: id,
		},
	});
};
