Skip to content

Commit f0d82f2

Browse files
author
pedro
committed
fix: 修复sequelize升级带来的版本问题
1 parent 4f163b2 commit f0d82f2

4 files changed

Lines changed: 16 additions & 9 deletions

File tree

lib/core.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { set, get, has, merge } from "lodash";
1717
import { Loader } from "./loader";
1818
import { LinRouter } from "./lin-router";
1919
import { verify } from "./password-hash";
20+
import dayjs from "dayjs";
2021

2122
// tslint:disable-next-line:variable-name
2223
export const __version__ = "0.0.1";
@@ -238,7 +239,7 @@ User.prototype.toJSON = function() {
238239
// @ts-ignore
239240
group_id: this.groupId,
240241
// @ts-ignore
241-
create_time: this.create_time
242+
create_time: this.createTime
242243
};
243244
if (has(this, "auths")) {
244245
return { ...origin, auths: get(this, "auths", []) };
@@ -402,7 +403,7 @@ Log.prototype.toJSON = function() {
402403
// @ts-ignore
403404
message: this.message,
404405
// @ts-ignore
405-
time: this.time,
406+
time: this.time ? null : dayjs(this.time).unix(),
406407
// @ts-ignore
407408
user_id: this.user_id,
408409
// @ts-ignore

lib/db.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ export const db = new Sequelize(database, username, password, {
1313
host: host,
1414
port: port,
1515
dialect: type,
16-
logging: logging
16+
logging: logging,
17+
timezone: "+08:00"
1718
});

lib/lin-validator.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import isAsyncFunction from "is-async-function";
2-
import { get, isArray, set, unset } from "lodash";
2+
import { get, isArray, set, unset, cloneDeep } from "lodash";
33
import { ParametersException } from "./exception";
44
import { Context } from "koa";
55
import { extendedValidator } from "./extended-validator";
@@ -37,8 +37,9 @@ export class LinValidator {
3737
path: ctx.params,
3838
header: ctx.request.header
3939
};
40+
const tmpData = cloneDeep(this.data);
4041
this.parsed = {
41-
...this.data,
42+
...tmpData,
4243
default: {}
4344
};
4445
if (!(await this.checkRules())) {
@@ -154,7 +155,9 @@ export class LinValidator {
154155
stoppedFlag = true;
155156
}
156157
}
157-
it.parsedValue && (this.parsed[dataKey][key] = it.parsedValue);
158+
if (it.parsedValue !== void 0) {
159+
this.parsed[dataKey][key] = it.parsedValue;
160+
}
158161
}
159162
if (errs.length !== 0) {
160163
this.errors.push({ key, message: errs });
@@ -174,7 +177,9 @@ export class LinValidator {
174177
stoppedFlag = true;
175178
}
176179
}
177-
value.parsedValue && (this.parsed[dataKey][key] = value.parsedValue);
180+
if (value.parsedValue !== void 0) {
181+
this.parsed[dataKey][key] = value.parsedValue;
182+
}
178183
if (errs.length !== 0) {
179184
this.errors.push({ key, message: errs });
180185
}
@@ -226,7 +231,7 @@ export class LinValidator {
226231
}
227232
if (parsed) {
228233
const key = get(this.parsed, path, defaultVal && defaultVal);
229-
if (key) {
234+
if (key !== void 0) {
230235
return key;
231236
} else {
232237
const index = path.lastIndexOf(".");

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lin-mizar",
3-
"version": "0.0.1-alpha.5",
3+
"version": "0.0.1-alpha.9",
44
"description": "The core library of Lin CMS",
55
"main": "lin/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)