feat: migrate backend storage to postgres
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
import db from '~/utils/sqlite';
|
||||
import { query } from '~/utils/db';
|
||||
import { useResponseError, useResponseSuccess } from '~/utils/response';
|
||||
|
||||
export default defineEventHandler((event) => {
|
||||
const id = event.context.params?.id;
|
||||
if (!id) {
|
||||
export default defineEventHandler(async (event) => {
|
||||
const idParam = event.context.params?.id;
|
||||
const id = Number(idParam);
|
||||
if (!idParam || Number.isNaN(id)) {
|
||||
return useResponseError('缺少ID参数', -1);
|
||||
}
|
||||
|
||||
const result = db
|
||||
.prepare('DELETE FROM telegram_notification_configs WHERE id = ?')
|
||||
.run(id);
|
||||
const result = await query(
|
||||
'DELETE FROM telegram_notification_configs WHERE id = $1',
|
||||
[id],
|
||||
);
|
||||
|
||||
if (result.changes === 0) {
|
||||
if (result.rowCount === 0) {
|
||||
return useResponseError('配置不存在或删除失败', -1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user