first commit
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Niolla
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is proprietary and confidential.
|
||||
* Unauthorized copying, modification, distribution, or use
|
||||
* of this file, via any medium, is strictly prohibited.
|
||||
*/
|
||||
|
||||
// app/models/permission/permission.model.js
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const permission = sequelize.define(
|
||||
"permission",
|
||||
{
|
||||
permission_id: {
|
||||
type: DataTypes.STRING,
|
||||
primaryKey: true,
|
||||
},
|
||||
permissionName: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
permissionDescription: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: true,
|
||||
},
|
||||
page:{
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
module:{
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
action: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
}
|
||||
},
|
||||
{
|
||||
tableName: "permission",
|
||||
timestamps: true,
|
||||
},
|
||||
);
|
||||
|
||||
permission.associate = (db) => {
|
||||
permission.hasMany(db.userPermission, {
|
||||
foreignKey: "permission_id",
|
||||
as: "userPermissions"
|
||||
});
|
||||
permission.hasMany(db.rolePermission, {
|
||||
foreignKey: "permission_id",
|
||||
as: "rolePermissions"
|
||||
});
|
||||
};
|
||||
|
||||
return permission;
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Niolla
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is proprietary and confidential.
|
||||
* Unauthorized copying, modification, distribution, or use
|
||||
* of this file, via any medium, is strictly prohibited.
|
||||
*/
|
||||
|
||||
// app/models/permission/role.model.js
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const roles = sequelize.define(
|
||||
"roles",
|
||||
{
|
||||
role_id: {
|
||||
type: DataTypes.STRING,
|
||||
primaryKey: true
|
||||
},
|
||||
roleName: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
roleDescription: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: true
|
||||
}
|
||||
},
|
||||
{
|
||||
tableName: "roles",
|
||||
timestamps: true
|
||||
}
|
||||
);
|
||||
|
||||
roles.associate = (db) => {
|
||||
roles.hasMany(db.rolePermission, {
|
||||
foreignKey: "role_id",
|
||||
as: "rolePermissions"
|
||||
});
|
||||
};
|
||||
|
||||
return roles;
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Niolla
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is proprietary and confidential.
|
||||
* Unauthorized copying, modification, distribution, or use
|
||||
* of this file, via any medium, is strictly prohibited.
|
||||
*/
|
||||
|
||||
// app/models/permission/rolePermission.model.js
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const rolePermission = sequelize.define(
|
||||
"rolePermission",
|
||||
{
|
||||
rp_id: {
|
||||
type: DataTypes.STRING,
|
||||
primaryKey: true
|
||||
},
|
||||
role_id: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
permission_id: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
}
|
||||
},
|
||||
{
|
||||
tableName: "rolePermission",
|
||||
timestamps: true
|
||||
}
|
||||
);
|
||||
|
||||
rolePermission.associate = (db) => {
|
||||
rolePermission.belongsTo(db.roles, {
|
||||
foreignKey: "role_id",
|
||||
as: "role"
|
||||
});
|
||||
rolePermission.belongsTo(db.permission, {
|
||||
foreignKey: "permission_id",
|
||||
as: "permission"
|
||||
});
|
||||
};
|
||||
|
||||
return rolePermission;
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Niolla
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is proprietary and confidential.
|
||||
* Unauthorized copying, modification, distribution, or use
|
||||
* of this file, via any medium, is strictly prohibited.
|
||||
*/
|
||||
|
||||
// app/models/permission/userPermission.model.js
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const userPermission = sequelize.define(
|
||||
"userPermission",
|
||||
{
|
||||
up_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true
|
||||
},
|
||||
user_id: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
permission_id: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
}
|
||||
},
|
||||
{
|
||||
tableName: "userPermission",
|
||||
timestamps: true
|
||||
}
|
||||
);
|
||||
|
||||
userPermission.associate = (db) => {
|
||||
userPermission.belongsTo(db.permission, {
|
||||
foreignKey: "permission_id",
|
||||
as: "permission"
|
||||
});
|
||||
userPermission.belongsTo(db.User, {
|
||||
foreignKey: "user_id",
|
||||
as: "user"
|
||||
});
|
||||
};
|
||||
|
||||
return userPermission;
|
||||
};
|
||||
Reference in New Issue
Block a user