72 lines
1.7 KiB
TypeScript
Raw Normal View History

2023-03-07 00:06:59 +08:00
import {Context} from "koa";
2021-06-27 21:00:24 +08:00
import FileService from "../service/FileService";
import config from "../config";
const router = {};
/**
2023-03-07 00:06:59 +08:00
*
2021-06-27 21:00:24 +08:00
*/
router["GET /file/query"] = async function (ctx: Context) {
ctx.body = await FileService.readPath(ctx.query.path as string, ctx.query.showHidden === '1');
};
/**
2023-03-07 00:06:59 +08:00
*
*/
router["POST /file/recursionQuery"] = async function (ctx: Context) {
ctx.body = await FileService.readRecursion(ctx.request.body);
};
/**
*windows
2021-06-27 21:00:24 +08:00
*/
2022-06-12 13:24:47 +08:00
router['GET /file/isWindows'] = async function (ctx: Context) {
ctx.body = config.isWindows;
2021-06-27 21:00:24 +08:00
}
/**
2023-03-07 00:06:59 +08:00
*
2021-06-27 21:00:24 +08:00
*/
router["GET /file/path/exist"] = async function (ctx: Context) {
ctx.body = await FileService.checkExist(ctx.query.path as string);
};
2022-06-12 13:24:47 +08:00
/**
*
*/
router["POST /file/path/save"] = async function (ctx: Context) {
ctx.body = await FileService.savePath(ctx.request.body);
};
/**
*
*/
router["GET /file/path"] = async function (ctx: Context) {
ctx.body = await FileService.getSaveList();
};
/**
*
*/
router["DELETE /file/path/delete"] = async function (ctx: Context) {
ctx.body = await FileService.deleteOne(ctx.query.id);
};
2023-03-07 00:06:59 +08:00
/**
* delete file batch
*/
router["POST /file/deleteBatch"] = async function (ctx: Context) {
ctx.body = await FileService.deleteBatch(ctx.request.body);
};
/**
* rename file
*/
router["POST /file/rename"] = async function (ctx: Context) {
await FileService.rename(ctx.request.body.source, ctx.request.body.target);
ctx.body = "";
};
2021-06-27 21:00:24 +08:00
export default router;