added and fix some of things

Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
2026-08-03 12:03:02 +08:00
parent 6765c1faba
commit d246c09cdd
31 changed files with 724 additions and 510 deletions
+6
View File
@@ -0,0 +1,6 @@
'use strict';
const excludeAttributes = ['description'];
const jsonbSchemas = {};
module.exports = { excludeAttributes, jsonbSchemas };
+5 -2
View File
@@ -3,11 +3,14 @@ const { DataTypes } = require('sequelize');
const sequelize = require('../../config/db.config');
const mdl_Category = sequelize.define('Category', {
id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true },
id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true, hidden: true },
name: { type: DataTypes.STRING(100), allowNull: false, unique: true },
slug: { type: DataTypes.STRING(120), allowNull: false, unique: true },
description: { type: DataTypes.TEXT, allowNull: true },
is_active: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: true },
is_active: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: true, label: "Status" },
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: 'categories',
timestamps: true,
@@ -10,6 +10,7 @@
***********************************************************************************************************************************************************************/
const { DataTypes } = require('sequelize');
const sequelize = require('../../config/db.config');
const mdl_Assets = require('../assets/assets.mdl');
const AdminNotification = sequelize.define('AdminNotification', {
notification_id: {
@@ -49,6 +50,14 @@ const AdminNotification = sequelize.define('AdminNotification', {
defaultValue: 'indigo',
},
// Denormalized copy of the source NotificationBroadcast's per-alert
// layout image (see notification_broadcast.mdl.js) — null when the
// alert has none.
image_asset_id: {
type: DataTypes.BIGINT,
allowNull: true,
},
// Denormalized copy of the source NotificationBroadcast's visibility
// window (see notificationVisibility.util.js) — null means unbounded.
start_date: {
@@ -94,4 +103,6 @@ const AdminNotification = sequelize.define('AdminNotification', {
],
});
AdminNotification.belongsTo(mdl_Assets, { as: "image", foreignKey: "image_asset_id" });
module.exports = AdminNotification;
@@ -2,6 +2,7 @@
const { DataTypes } = require("sequelize");
const sequelize = require("../../config/db.config");
const mdl_Users = require("../users/users.mdl");
const mdl_Assets = require("../assets/assets.mdl");
const NotificationBroadcast = sequelize.define("NotificationBroadcast", {
@@ -23,6 +24,11 @@ const NotificationBroadcast = sequelize.define("NotificationBroadcast", {
// sticky banner's panel background/border — same registry rewards/tiers use.
color: { type: DataTypes.STRING(20), allowNull: false, defaultValue: 'indigo', label: "Color", order: 2.4 },
// Optional per-alert image shown in the click-through details dialog when
// opened from the sticky banner (see AnnouncementCarouselDialog on the
// frontend). Replaces the old shared sticky_banner_settings singleton.
image_asset_id: { type: DataTypes.BIGINT, allowNull: true, label: "Layout Image", order: 2.45 },
// Optional visibility window. Null start_date = show immediately once sent;
// null end_date = show indefinitely. Copied onto AdminNotification/
// UserNotification rows at send time so client reads can filter without
@@ -34,7 +40,7 @@ const NotificationBroadcast = sequelize.define("NotificationBroadcast", {
// Determines where a delivered announcement shows up for recipients.
// - show_in_sticky: client sticky banner (fixed top)
// - show_in_notifications: client + admin notifications lists/bells
show_in_sticky: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false, label: "Show in Sticky Announcements", order: 2.5 },
show_in_sticky: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false, label: "Show in Sticky Alerts", order: 2.5 },
show_in_notifications: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: true, label: "Show in Notifications", order: 2.6 },
// ─── Targeting ────────────────────────────────────────────────────────────
@@ -74,5 +80,6 @@ const NotificationBroadcast = sequelize.define("NotificationBroadcast", {
NotificationBroadcast.belongsTo(mdl_Users, { as: "creator", foreignKey: "createdBy" });
NotificationBroadcast.belongsTo(mdl_Users, { as: "updater", foreignKey: "updatedBy" });
NotificationBroadcast.belongsTo(mdl_Assets, { as: "image", foreignKey: "image_asset_id" });
module.exports = NotificationBroadcast;
@@ -1,22 +0,0 @@
// models/notifications/sticky_banner_setting.mdl.js
//
// Singleton (always id=1) — one shared banner image shown alongside every
// currently-active sticky announcement, not one image per announcement. Set
// from the Announcements list page (see admin/notificationBroadcasts.controller.js's
// getStickyBannerSetting/updateStickyBannerSetting).
const { DataTypes } = require("sequelize");
const sequelize = require("../../config/db.config");
const mdl_Assets = require("../assets/assets.mdl");
const StickyBannerSetting = sequelize.define("StickyBannerSetting", {
id: { type: DataTypes.SMALLINT, primaryKey: true, defaultValue: 1 },
image_asset_id: { type: DataTypes.BIGINT, allowNull: true },
updatedBy: { type: DataTypes.BIGINT, allowNull: true },
}, {
tableName: "sticky_banner_settings",
timestamps: true,
});
StickyBannerSetting.belongsTo(mdl_Assets, { as: "image", foreignKey: "image_asset_id" });
module.exports = StickyBannerSetting;
@@ -10,6 +10,7 @@
***********************************************************************************************************************************************************************/
const { DataTypes } = require('sequelize');
const sequelize = require('../../config/db.config');
const mdl_Assets = require('../assets/assets.mdl');
const UserNotification = sequelize.define('UserNotification', {
notification_id: {
@@ -55,6 +56,14 @@ const UserNotification = sequelize.define('UserNotification', {
defaultValue: 'indigo',
},
// Denormalized copy of the source NotificationBroadcast's per-alert
// layout image (see notification_broadcast.mdl.js) — null when the
// alert has none.
image_asset_id: {
type: DataTypes.BIGINT,
allowNull: true,
},
// Denormalized copy of the source NotificationBroadcast's visibility
// window (see notificationVisibility.util.js) — null means unbounded.
start_date: {
@@ -101,4 +110,6 @@ const UserNotification = sequelize.define('UserNotification', {
],
});
UserNotification.belongsTo(mdl_Assets, { as: "image", foreignKey: "image_asset_id" });
module.exports = UserNotification;