Skip to content

Commit

Permalink
用户模型返回groupName字段
Browse files Browse the repository at this point in the history
  • Loading branch information
vanoneang committed Oct 10, 2019
1 parent df39811 commit ea35da0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
6 changes: 2 additions & 4 deletions lib/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,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
17 changes: 5 additions & 12 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 @@ -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 ea35da0

Please sign in to comment.