Skip to content

Commit

Permalink
Merge pull request #27 from TaleLin/dev
Browse files Browse the repository at this point in the history
Fix known bugs
  • Loading branch information
vanoneang committed Oct 10, 2019
2 parents c0176f3 + ea35da0 commit b79f02b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
8 changes: 4 additions & 4 deletions lib/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export class Manager {
export class User extends Model {
public id!: number;
public username!: string;
public nickname!: string;
public admin!: number;
public active!: number;
public email!: string;
Expand Down Expand Up @@ -303,6 +304,7 @@ export class User extends Model {
const origin = {
id: this.id,
username: this.username,
nickname: this.nickname,
admin: this.admin,
active: this.active,
email: this.email,
Expand All @@ -313,10 +315,8 @@ export class User extends Model {
// @ts-ignore
update_time: this.updateTime
};
if (has(this, 'auths')) {
return { ...origin, auths: get(this, 'auths', []) };
} else if (has(this, 'groupName')) {
return { ...origin, group_name: get(this, 'groupName', '') };
if (has(this, 'auths') || has(this, 'groupName')) {
return { ...origin, auths: get(this, 'auths', []), group_name: get(this, 'groupName', '') };
} else {
return origin;
}
Expand Down
19 changes: 6 additions & 13 deletions lib/interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import Sequelize from 'sequelize';
import { merge } from 'lodash';
import { UserAdmin, UserActive } from './enums';
import dayjs from 'dayjs';
import { generate } from './password-hash';
import { config } from './config';

Expand All @@ -17,12 +15,10 @@ export let InfoCrudMixin = {
paranoid: true,
getterMethods: {
createTime() {
// @ts-ignore
return dayjs(this.getDataValue('create_time')).unix() * 1000;
return new Date().getTime();
},
updateTime() {
// @ts-ignore
return dayjs(this.getDataValue('update_time')).unix() * 1000;
return new Date().getTime();
}
}
}
Expand Down Expand Up @@ -54,7 +50,7 @@ export let UserInterface = {
comment: '头像url',
get() {
// @ts-ignore
return this.getDataValue('avatar') ? config.getItem('siteDomain') + 'assets/' + this.getDataValue('avatar') : null;
return this.getDataValue('avatar') ? config.getItem('siteDomain').replace(/\/+$/, '') + '/assets/' + this.getDataValue('avatar') : null;
}

},
Expand Down Expand Up @@ -105,12 +101,10 @@ export let UserInterface = {
return this.getDataValue('active') === UserActive.ACTIVE;
},
createTime() {
// @ts-ignore
return dayjs(this.getDataValue('create_time')).unix() * 1000;
return new Date().getTime();
},
updateTime() {
// @ts-ignore
return dayjs(this.getDataValue('update_time')).unix() * 1000;
return new Date().getTime();
}
}
}
Expand Down Expand Up @@ -208,8 +202,7 @@ export let LogInterface = {
updatedAt: false,
getterMethods: {
time() {
// @ts-ignore
return dayjs(this.getDataValue('time')).unix() * 1000;
return new Date().getTime();
}
}
}
Expand Down

0 comments on commit b79f02b

Please sign in to comment.