zmh
2 years ago
4 changed files with 212 additions and 0 deletions
@ -0,0 +1,70 @@ |
|||
/* eslint-disable*/ |
|||
|
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const Resource = sequelize.define("resource", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true |
|||
}, |
|||
name: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "权限名称", |
|||
primaryKey: false, |
|||
field: "name", |
|||
autoIncrement: false |
|||
}, |
|||
code: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "权限码", |
|||
primaryKey: false, |
|||
field: "code", |
|||
autoIncrement: false |
|||
}, |
|||
parentId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "父级id", |
|||
primaryKey: false, |
|||
field: "parent_id", |
|||
autoIncrement: false |
|||
}, |
|||
createTime: { |
|||
type: DataTypes.DATE, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "创建时间", |
|||
primaryKey: false, |
|||
field: "create_time", |
|||
autoIncrement: false |
|||
}, |
|||
order: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "order", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "resource", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.Resource = Resource; |
|||
return Resource; |
|||
}; |
@ -0,0 +1,52 @@ |
|||
/* eslint-disable*/ |
|||
|
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const Role = sequelize.define("role", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true |
|||
}, |
|||
name: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "角色名称", |
|||
primaryKey: false, |
|||
field: "name", |
|||
autoIncrement: false |
|||
}, |
|||
delete: { |
|||
type: DataTypes.BOOLEAN, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "收否删除", |
|||
primaryKey: false, |
|||
field: "delete", |
|||
autoIncrement: false |
|||
}, |
|||
dataRange: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "数据范围:1全公司 2本部门", |
|||
primaryKey: false, |
|||
field: "data_range", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "role", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.Role = Role; |
|||
return Role; |
|||
}; |
@ -0,0 +1,43 @@ |
|||
/* eslint-disable*/ |
|||
|
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const RoleResource = sequelize.define("roleResource", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true |
|||
}, |
|||
roleId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "角色id", |
|||
primaryKey: false, |
|||
field: "role_id", |
|||
autoIncrement: false |
|||
}, |
|||
resId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "权限id", |
|||
primaryKey: false, |
|||
field: "res_id", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "role_resource", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.RoleResource = RoleResource; |
|||
return RoleResource; |
|||
}; |
@ -0,0 +1,47 @@ |
|||
/* eslint-disable*/ |
|||
|
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const UserRole = sequelize.define("userRole", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true |
|||
}, |
|||
roleId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "角色id", |
|||
primaryKey: false, |
|||
field: "role_id", |
|||
autoIncrement: false |
|||
}, |
|||
userId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "用户id", |
|||
primaryKey: false, |
|||
field: "user_id", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "user_role", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.UserRole = UserRole; |
|||
|
|||
const Role = dc.models.Role; |
|||
UserRole.belongsTo(Role, { foreignKey: 'roleId', targetKey: 'id' }); |
|||
Role.hasMany(UserRole, { foreignKey: 'roleId', sourceKey: 'id' }); |
|||
return UserRole; |
|||
}; |
Loading…
Reference in new issue