open-renamer/openRenamerBackend/api/ApplicationRuleApi.ts
2022-11-29 23:02:06 +08:00

39 lines
851 B
TypeScript

import { Context } from "koa";
import ApplicationRuleService from "../service/ApplicationRuleService";
const router = {};
/**
* 获取目录下的文件列表
*/
router["GET /applicationRule"] = async function (ctx: Context) {
ctx.body = await ApplicationRuleService.getAll();
};
/**
* 获取默认模板
*/
router["GET /applicationRule/default"] = async function (ctx: Context) {
;
ctx.body = await ApplicationRuleService.getDefault();
};
/**
* 更新或者插入
*/
router['POST /applicationRule'] = async function (ctx: Context) {
ctx.body = await ApplicationRuleService.saveOrAdd(ctx.request.body);
}
/**
* 删除
*/
router["DELETE /applicationRule/:id"] = async function (ctx: Context) {
await ApplicationRuleService.deleteById(ctx.params.id);
ctx.body = "";
};
export default router;