This commit is contained in:
rgrgogu
2026-05-06 14:15:04 +08:00
parent a8f10a25d7
commit d5fcc574a4
12 changed files with 389 additions and 219 deletions
+11 -11
View File
@@ -15,19 +15,19 @@ const { DataTypes } = require('sequelize');
const sequelize = require('../../config/db.config');
const mdl_Users = sequelize.define('User', {
user_id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true, label: "User ID" },
email: { type: DataTypes.STRING(255), allowNull: false, unique: true, label: "Email Address", validate: { isEmail: true } },
user_id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true, label: "User ID", order: 1, hidden: true },
email: { type: DataTypes.STRING(255), allowNull: false, unique: true, label: "Email Address", validate: { isEmail: true }, order: 3 },
password: { type: DataTypes.TEXT, label: "Password" },
is_active: { type: DataTypes.BOOLEAN, defaultValue: true, label: "Active" },
is_verified: { type: DataTypes.BOOLEAN, defaultValue: false, label: "Verified" },
reg_type: { type: DataTypes.ENUM('system', 'google'), defaultValue: 'system', label: "Registration Type" },
is_active: { type: DataTypes.BOOLEAN, defaultValue: true, label: "Active", order: 6 },
is_verified: { type: DataTypes.BOOLEAN, defaultValue: false, label: "Verified", order: 7 },
reg_type: { type: DataTypes.ENUM('google', 'system'), defaultValue: 'system', label: "Registration Type", order: 8 },
/**
* acc_type drives RBAC:
* - "user" → Client endpoints only
* - "staff" → Client + Staff endpoints
* - "admin" → All endpoints
*/
acc_type: { type: DataTypes.ENUM('user', 'staff', 'admin'), defaultValue: 'user', label: "Account Type" },
acc_type: { type: DataTypes.ENUM('admin', 'staff', 'user'), defaultValue: 'user', label: "Account Type", order: 9 },
/**
* personal_info JSONB structure:
* {
@@ -40,20 +40,20 @@ const mdl_Users = sequelize.define('User', {
* album: [{ uuid, file_url, original_name, uploaded_at, order_index }]
* }
*/
personal_info: { type: DataTypes.JSONB, defaultValue: null, label: "Personal Info" },
personal_info: { type: DataTypes.JSONB, defaultValue: null, label: "Personal Info", order: 2 },
// OTP fields (stored temporarily during verification flow)
otp_code: { type: DataTypes.STRING(6), allowNull: true, label: "OTP Code" },
otp_expires_at: { type: DataTypes.DATE, allowNull: true, label: "OTP Expires At" },
// ── Audit trails ────────────────────────────────────────────────────────────
createdBy: { type: DataTypes.BIGINT, allowNull: true, label: "Created By" },
updatedBy: { type: DataTypes.BIGINT, allowNull: true, label: "Modified By" },
deletedBy: { type: DataTypes.BIGINT, allowNull: true, label: "Deleted By" },
createdBy: { type: DataTypes.BIGINT, allowNull: true, label: "Created By" },
updatedBy: { type: DataTypes.BIGINT, allowNull: true, label: "Modified By" },
deletedBy: { type: DataTypes.BIGINT, allowNull: true, label: "Deleted By" },
}, {
tableName: 'users',
timestamps: true,
paranoid: true, // enables soft delete — sets deleted_at instead of DELETE
paranoid: true, // enables soft delete — sets deleted_at instead of DELETE
});
module.exports = mdl_Users;