Docker 파일
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import { getDb } from '../../../../utils/db'
|
||||
import { execute } from '../../../../utils/db'
|
||||
|
||||
export default defineEventHandler((event) => {
|
||||
const db = getDb()
|
||||
export default defineEventHandler(async (event) => {
|
||||
const id = getRouterParam(event, 'id')
|
||||
|
||||
db.prepare(`DELETE FROM pubnet_targets WHERE id = ?`).run(id)
|
||||
await execute(`DELETE FROM pubnet_targets WHERE id = $1`, [id])
|
||||
|
||||
return { success: true }
|
||||
})
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { getDb } from '../../../../utils/db'
|
||||
import { execute } from '../../../../utils/db'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const db = getDb()
|
||||
const id = getRouterParam(event, 'id')
|
||||
const body = await readBody(event)
|
||||
|
||||
@@ -14,11 +13,11 @@ export default defineEventHandler(async (event) => {
|
||||
})
|
||||
}
|
||||
|
||||
db.prepare(`
|
||||
await execute(`
|
||||
UPDATE pubnet_targets
|
||||
SET name = ?, url = ?, is_active = ?, updated_at = datetime('now', 'localtime')
|
||||
WHERE id = ?
|
||||
`).run(name, url, is_active ? 1 : 0, id)
|
||||
SET name = $1, url = $2, is_active = $3, updated_at = TO_CHAR(NOW(), 'YYYY-MM-DD HH24:MI:SS')
|
||||
WHERE id = $4
|
||||
`, [name, url, is_active ? 1 : 0, id])
|
||||
|
||||
return {
|
||||
id: Number(id),
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { getDb } from '../../../../utils/db'
|
||||
import { query } from '../../../../utils/db'
|
||||
|
||||
export default defineEventHandler(() => {
|
||||
const db = getDb()
|
||||
|
||||
const targets = db.prepare(`
|
||||
export default defineEventHandler(async () => {
|
||||
const targets = await query(`
|
||||
SELECT * FROM pubnet_targets
|
||||
ORDER BY id ASC
|
||||
`).all()
|
||||
`)
|
||||
|
||||
return targets
|
||||
})
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { getDb } from '../../../../utils/db'
|
||||
import { queryOne } from '../../../../utils/db'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const db = getDb()
|
||||
const body = await readBody(event)
|
||||
|
||||
const { name, url, is_active } = body
|
||||
@@ -13,13 +12,14 @@ export default defineEventHandler(async (event) => {
|
||||
})
|
||||
}
|
||||
|
||||
const result = db.prepare(`
|
||||
const result = await queryOne<{ id: number }>(`
|
||||
INSERT INTO pubnet_targets (name, url, is_active)
|
||||
VALUES (?, ?, ?)
|
||||
`).run(name, url, is_active ? 1 : 0)
|
||||
VALUES ($1, $2, $3)
|
||||
RETURNING id
|
||||
`, [name, url, is_active ? 1 : 0])
|
||||
|
||||
return {
|
||||
id: result.lastInsertRowid,
|
||||
id: result?.id,
|
||||
name,
|
||||
url,
|
||||
is_active: is_active ? 1 : 0
|
||||
|
||||
Reference in New Issue
Block a user