This commit is contained in:
rgrgogu
2026-05-07 23:35:22 +08:00
parent 09660d7503
commit 58ccecd28a
10 changed files with 370 additions and 53 deletions
+17 -2
View File
@@ -1,5 +1,5 @@
const excludeAttributes = [
// Add here
"description"
];
const jsonbSchemas = {
@@ -19,4 +19,19 @@ const userExclude = [
"deleted_at",
];
module.exports = { excludeAttributes, adminExclude, userExclude, jsonbSchemas };
const computedAttributes = [
{
key: "memberCount",
label: "Members",
type: "number",
order: 5,
literal: `(
SELECT CAST(COUNT(*) AS INTEGER)
FROM "user_group_members"
WHERE "user_group_members"."group_id" = "UserGroup"."group_id"
AND "user_group_members"."deletedAt" IS NULL
)`,
},
];
module.exports = { excludeAttributes, adminExclude, userExclude, jsonbSchemas, computedAttributes };
+4 -4
View File
@@ -16,10 +16,10 @@ const mdl_Users = require('./users.mdl');
// ─── UserGroups ────────────────────────────────────────────────────────────────
const mdl_UserGroups = sequelize.define('UserGroup', {
group_id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true },
name: { type: DataTypes.STRING(50), allowNull: false },
description: { type: DataTypes.TEXT },
is_active: { type: DataTypes.BOOLEAN, defaultValue: true },
group_id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true, label: "Group ID", order: 1, hidden: true },
name: { type: DataTypes.STRING(50), allowNull: false, label: "Group Name", order: 2 },
description: { type: DataTypes.TEXT, label: "Description", order: 3 },
is_active: { type: DataTypes.BOOLEAN, defaultValue: true, label: "Active", order: 4 },
// ── Audit trails ────────────────────────────────────────────────────────────
createdBy: { type: DataTypes.BIGINT, allowNull: true, label: "Created By" },
+11 -2
View File
@@ -1,5 +1,5 @@
const excludeAttributes = [
"password", "otp_code", "otp_expires_at",
"password", "otp_code", "otp_expires_at", 'must_change_password', 'password_expires_at',
"personal_info.name.given_name",
"personal_info.name.middle_name",
"personal_info.name.last_name",
@@ -46,4 +46,13 @@ const userExclude = [
"deleted_at",
];
module.exports = { excludeAttributes, adminExclude, userExclude, jsonbSchemas };
const computedAttributes = [
// {
// key: "memberCount",
// label: "Members",
// type: "number",
// order: 99, // adjust order as needed
// },
];
module.exports = { excludeAttributes, adminExclude, userExclude, jsonbSchemas, computedAttributes };
+4
View File
@@ -42,6 +42,10 @@ const mdl_Users = sequelize.define('User', {
*/
personal_info: { type: DataTypes.JSONB, defaultValue: null, label: "Personal Info", order: 2 },
// ── Password policy ─────────────────────────────────────────────────────────
must_change_password: { type: DataTypes.BOOLEAN, defaultValue: false, allowNull: false, label: "Must Change Password" },
password_expires_at: { type: DataTypes.DATE, defaultValue: null, allowNull: true, label: "Password Expires At" },
// 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" },