diff --git a/api/app/lib/models/resource.js b/api/app/lib/models/resource.js new file mode 100644 index 0000000..54bc245 --- /dev/null +++ b/api/app/lib/models/resource.js @@ -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; +}; \ No newline at end of file diff --git a/api/app/lib/models/role.js b/api/app/lib/models/role.js new file mode 100644 index 0000000..12304ea --- /dev/null +++ b/api/app/lib/models/role.js @@ -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; +}; \ No newline at end of file diff --git a/api/app/lib/models/role_resource.js b/api/app/lib/models/role_resource.js new file mode 100644 index 0000000..a4c74c8 --- /dev/null +++ b/api/app/lib/models/role_resource.js @@ -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; +}; \ No newline at end of file diff --git a/api/app/lib/models/user_role.js b/api/app/lib/models/user_role.js new file mode 100644 index 0000000..68aae04 --- /dev/null +++ b/api/app/lib/models/user_role.js @@ -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; +}; \ No newline at end of file