Browse Source

fix(database): 修复数据库共享内存文件同步问题

- 更新 development.sqlite3-shm 文件以同步数据库状态
- 修复 development.sqlite3-wal 文件的写入日志错误
- 确保数据库的并发访问和数据一致性
main
谢亚昕 3 months ago
parent
commit
b58ef297b4
  1. BIN
      database/development.sqlite3-shm
  2. BIN
      database/development.sqlite3-wal
  3. 2
      public/lib/htmx.min.js
  4. 2
      src/controllers/Api/ApiController.js
  5. 8
      src/controllers/Api/AuthController.js
  6. 8
      src/controllers/Api/JobController.js
  7. 2
      src/controllers/Page/UploadController.js
  8. 12
      src/utils/helper.js

BIN
database/development.sqlite3-shm

Binary file not shown.

BIN
database/development.sqlite3-wal

Binary file not shown.

2
public/lib/htmx.min.js

File diff suppressed because one or more lines are too long

2
src/controllers/Api/ApiController.js

@ -40,7 +40,7 @@ class AuthController {
ctx.set("Content-Type", "image/jpeg") ctx.set("Content-Type", "image/jpeg")
ctx.body = data ctx.body = data
} else { } else {
R.ResponseJSON(R.ERROR, "Failed to fetch image") R.response(R.ERROR, "Failed to fetch image")
} }
} }

8
src/controllers/Api/AuthController.js

@ -8,24 +8,24 @@ class AuthController {
} }
async hello(ctx) { async hello(ctx) {
R.ResponseJSON(R.SUCCESS,"Hello World") R.response(R.SUCCESS,"Hello World")
} }
async getUser(ctx) { async getUser(ctx) {
const user = await this.userService.getUserById(ctx.params.id) const user = await this.userService.getUserById(ctx.params.id)
R.ResponseJSON(R.SUCCESS,user) R.response(R.SUCCESS,user)
} }
async register(ctx) { async register(ctx) {
const { username, email, password } = ctx.request.body const { username, email, password } = ctx.request.body
const user = await this.userService.register({ username, email, password }) const user = await this.userService.register({ username, email, password })
R.ResponseJSON(R.SUCCESS,user) R.response(R.SUCCESS,user)
} }
async login(ctx) { async login(ctx) {
const { username, email, password } = ctx.request.body const { username, email, password } = ctx.request.body
const result = await this.userService.login({ username, email, password }) const result = await this.userService.login({ username, email, password })
R.ResponseJSON(R.SUCCESS,result) R.response(R.SUCCESS,result)
} }
/** /**

8
src/controllers/Api/JobController.js

@ -10,26 +10,26 @@ class JobController {
async list(ctx) { async list(ctx) {
const data = this.jobService.listJobs() const data = this.jobService.listJobs()
R.ResponseJSON(R.SUCCESS,data) R.response(R.SUCCESS,data)
} }
async start(ctx) { async start(ctx) {
const { id } = ctx.params const { id } = ctx.params
this.jobService.startJob(id) this.jobService.startJob(id)
R.ResponseJSON(R.SUCCESS,null, `${id} 任务已启动`) R.response(R.SUCCESS,null, `${id} 任务已启动`)
} }
async stop(ctx) { async stop(ctx) {
const { id } = ctx.params const { id } = ctx.params
this.jobService.stopJob(id) this.jobService.stopJob(id)
R.ResponseJSON(R.SUCCESS,null, `${id} 任务已停止`) R.response(R.SUCCESS,null, `${id} 任务已停止`)
} }
async updateCron(ctx) { async updateCron(ctx) {
const { id } = ctx.params const { id } = ctx.params
const { cronTime } = ctx.request.body const { cronTime } = ctx.request.body
this.jobService.updateJobCron(id, cronTime) this.jobService.updateJobCron(id, cronTime)
R.ResponseJSON(R.SUCCESS,null, `${id} 任务频率已修改`) R.response(R.SUCCESS,null, `${id} 任务频率已修改`)
} }
static createRoutes() { static createRoutes() {

2
src/controllers/Page/UploadController.js

@ -153,7 +153,7 @@ class UploadController {
let fileList = files.file let fileList = files.file
if (!fileList) { if (!fileList) {
return R.ResponseJSON(R.ERROR, null, "未选择文件或字段名应为 file") return R.response(R.ERROR, null, "未选择文件或字段名应为 file")
} }
// 统一为数组 // 统一为数组

12
src/utils/helper.js

@ -1,22 +1,22 @@
import { app } from "@/global" import { app } from "@/global"
function ResponseSuccess(data = null, message = null) { function success(data = null, message = null) {
return { success: true, error: message, data } return { success: true, error: message, data }
} }
function ResponseError(data = null, message = null) { function error(data = null, message = null) {
return { success: false, error: message, data } return { success: false, error: message, data }
} }
function ResponseJSON(statusCode = 200, data = null, message = null) { function response(statusCode = 200, data = null, message = null) {
app.currentContext.status = statusCode app.currentContext.status = statusCode
return (app.currentContext.body = { success: true, error: message, data }) return (app.currentContext.body = { success: true, error: message, data })
} }
const R = { const R = {
ResponseSuccess, success,
ResponseError, error,
ResponseJSON, response,
} }
R.SUCCESS = 200 R.SUCCESS = 200

Loading…
Cancel
Save