提交 abb66e6a authored 作者: vipcxj's avatar vipcxj

新增删除资源和查询资源数的api

上级 5435789c
import post from '../utils/post'; import post from '../utils/post';
import doDelete from '../utils/delete';
import config from '../utils/config'; import config from '../utils/config';
import request from '../utils/request'; import request from '../utils/request';
import { getToken } from '../utils/auth';
import { encrypt } from '../utils/helper';
import { errors } from '../utils/error';
export class Operations { export class Operations {
constructor() { constructor() {
...@@ -162,6 +166,14 @@ export async function editResource(uri, operations) { ...@@ -162,6 +166,14 @@ export async function editResource(uri, operations) {
return post(`${config.apiContextPath}/api/resource/user/${encodeURIComponent(uri)}/meta`, { operations: operations.operations }); return post(`${config.apiContextPath}/api/resource/user/${encodeURIComponent(uri)}/meta`, { operations: operations.operations });
} }
export async function deleteResource(uri) {
return doDelete(await rsLink(uri));
}
export async function countResource(query) {
return post(`${config.apiContextPath}/api/resource/user/count`, query);
}
export async function queryResource(query) { export async function queryResource(query) {
return post(`${config.apiContextPath}/api/resource/user/query`, query); return post(`${config.apiContextPath}/api/resource/user/query`, query);
} }
...@@ -169,3 +181,11 @@ export async function queryResource(query) { ...@@ -169,3 +181,11 @@ export async function queryResource(query) {
export async function getResourceInfo(uri) { export async function getResourceInfo(uri) {
return request(`${config.apiContextPath}/api/resource/user/${encodeURIComponent(uri)}/meta`); return request(`${config.apiContextPath}/api/resource/user/${encodeURIComponent(uri)}/meta`);
} }
export async function rsLink(uri, download = false) {
const token = await getToken();
if (!token) {
throw errors.tokenMissing();
}
return `${config.apiContextPath}/resource/${encrypt(token)}/${encodeURIComponent(uri)}${download ? '?dl=true' : ''}`;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论