import { defHttp } from '/@/utils/http/axios';
import { setParams } from '/@/utils/index';

enum Api {
  storageRecordQueryPage = '/sys/storage/record/query/page',
  storageRecordDetail = '/sys/storage/record/detail',
  storageRecordAdd = '/sys/storage/record/add',
  storageRecordEdit = '/sys/storage/record/edit',
  storageRecordRemove = '/sys/storage/record/removeByIds',
}

/**
 *
 * @author lf
 * @date  2023/05/11 10:43
 * @description: 根据条件查询存储记录列表,权限 - storage:record:query
 * @method: POST
 * @param:
 *       {String}  name  like   文件名称
 * @return:
 *       {String}  name  文件名称
 *       {String}  absolutePath  绝对路径
 *       {String}  storagePath  存储路径
 *       {String}  bizPath  业务路径
 *       {String}  configId  存储配置id
 *       {Integer}  size  文件大小
 *       {String}  suffix  文件后缀
 *       {String}  cateId  所属目录id
 */

export const storageRecordQueryPage = (params?: object) => {
  return defHttp.post({ url: Api.storageRecordQueryPage, params: setParams(params) });
};
/**
 *
 * @author lf
 * @date  2023/05/11 10:43
 * @description: 根据id查询存储记录详细信息,权限 - storage:record:query
 * @method: GET
 * @param:  id 存储记录主键id
 * @return:
 *       {String}  name  文件名称
 *       {String}  absolutePath  绝对路径
 *       {String}  storagePath  存储路径
 *       {String}  bizPath  业务路径
 *       {String}  configId  存储配置id
 *       {Integer}  size  文件大小
 *       {String}  suffix  文件后缀
 *       {String}  cateId  所属目录id
 */
export const storageRecordDetail = (id: string) => {
  return defHttp.get({ url: Api.storageRecordDetail + '/' + id });
};

/**
 *
 * @author lf
 * @date  2023/05/11 10:43
 * @description: 添加存储记录,权限 - storage:record:add
 * @method: POST
 * @param:
 *       {String}  name  文件名称
 *       {String}  absolutePath  绝对路径
 *       {String}  storagePath  存储路径
 *       {String}  bizPath  业务路径
 *       {String}  configId  存储配置id
 *       {Integer}  size  文件大小
 *       {String}  suffix  文件后缀
 *       {String}  cateId  所属目录id
 * @return:
 *       0 添加失败
 *       1 添加成功
 */
export const storageRecordAdd = (params?: object) => {
  return defHttp.post({ url: Api.storageRecordAdd, params: params });
};

/**
 *
 * @author lf
 * @date  2023/05/11 10:43
 * @description: 通过主键id编辑存储记录,权限 - storage:record:edit
 * @method: POST
 * @param:
 *       {String}  name  文件名称
 *       {String}  absolutePath  绝对路径
 *       {String}  storagePath  存储路径
 *       {String}  bizPath  业务路径
 *       {String}  configId  存储配置id
 *       {Integer}  size  文件大小
 *       {String}  suffix  文件后缀
 *       {String}  cateId  所属目录id
 * @return:
 *       0 编辑失败
 *       1 编辑成功
 */
export const storageRecordEdit = (params?: object) => {
  return defHttp.post({ url: Api.storageRecordEdit, params: params });
};

/**
 * @description: 删除,权限 - storage:record:remove
 * @method: POST
 */
export const storageRecordRemove = (params: Array<string | number>) => {
  return defHttp.post({ url: Api.storageRecordRemove, params: params });
};
