This commit is contained in:
2025-03-29 18:00:27 +08:00
parent a20c082b91
commit 12aa9022c4
4 changed files with 218 additions and 146 deletions

View File

@@ -116,10 +116,11 @@ app
path: 'mark',
key: 'update',
middleware: ['auth'],
isDebug: true,
})
.define(async (ctx) => {
const tokenUser = ctx.state.tokenUser;
const { id, ...data } = ctx.query.data || {};
const { id, createdAt, updatedAt, uid: _, puid: _2, uname: _3, ...data } = ctx.query.data || {};
let markModel: MarkModel;
if (id) {
markModel = await MarkModel.findByPk(id);
@@ -130,7 +131,15 @@ app
ctx.throw(403, 'no permission');
}
const version = Number(markModel.version) + 1;
await markModel.update({ ...markModel.data, ...data, version });
await markModel.update({
...markModel.data,
...data,
data: {
...markModel.data,
...data,
},
version,
});
} else {
markModel = await MarkModel.create({
...data,

View File

@@ -317,3 +317,5 @@ export const syncMarkModel = async (sync?: Opts) => {
const sequelize = await useContextKey('sequelize');
await MarkMInit({ sequelize, tableName: 'micro_mark' }, sync);
};
syncMarkModel({ sync: true, alter: true, logging: true });