后端实现Resources修改接口

This commit is contained in:
2024-09-01 13:46:10 +08:00
parent 241834feb8
commit 55b631cd9c
6 changed files with 124 additions and 4 deletions

View File

@@ -0,0 +1,26 @@
import { API } from "../../Plugs/API/API";
import ServerStdResponse from "../../ServerStdResponse";
import MySQLConnection from '../../Plugs/MySQLConnection'
import Auth from "../../Plugs/Middleware/Auth";
// 删除资源
class DelResource extends API {
constructor() {
super('DELETE', '/console/resource', Auth);
}
public async onRequset(data: any, res: any) {
let { id } = data;
if (!id) {
return res.json(ServerStdResponse.PARAMS_MISSING);
}
let execRes = await MySQLConnection.execute('DELETE FROM resource WHERE `id` = ?', [id]);
if (!execRes || execRes.affectedRows != 1) {
return res.json(ServerStdResponse.SERVER_ERROR);
}
return res.json({ ...ServerStdResponse.OK });
}
}
export default DelResource;