1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- /* indent size: 2 */
- module.exports = app => {
- const DataTypes = app.Sequelize;
- const Model = app.model.define('AdminUser', {
- admin_id: {
- type: DataTypes.INTEGER(10).UNSIGNED,
- primaryKey: true,
- autoIncrement: true
- },
- username: {
- type: DataTypes.STRING(20)
- },
- password: {
- type: DataTypes.STRING(255)
- },
- role_id: {
- type: DataTypes.INTEGER(10).UNSIGNED
- },
- admin_status: {
- type: DataTypes.INTEGER(1).UNSIGNED
- },
- login_ip: {
- type: DataTypes.STRING(15)
- },
- login_time: {
- type: DataTypes.DATE,
- get() {
- let logintime = this.getDataValue('login_time');
- if('0000-00-00 00:00:00' == logintime) return '';
- return logintime;
- }
- },
- login_count:{
- type:DataTypes.INTEGER(1).UNSIGNED
- },
- admin_token: {
- type: DataTypes.STRING(255)
- },
- admin_code: {
- type: DataTypes.CHAR(6)
- },
- other_auth: {
- type: DataTypes.STRING(255)
- },
- action_user: {
- type: DataTypes.INTEGER(1).UNSIGNED
- },
- update_time: {
- type: DataTypes.TIME
- },
- create_time: {
- type: DataTypes.DATE
- }
- },
- {
- tableName: 'szj_admin_user'
- });
- Model.associate = function() {
- //关联角色表
- Model.belongsTo(app.model.Roles,{foreignKey:'role_id',targetKey:'role_id',as:'role'});
- }
- //同步:没有就新建,有就不变
- Model.sync();
- return Model;
- };
|