first commit
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* active Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require("bcryptjs");
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require("lodash");
|
||||
const coreModel = require("./../core/models");
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Active = sequelize.define(
|
||||
"active",
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
name: DataTypes.STRING,
|
||||
handle: DataTypes.TEXT,
|
||||
description: DataTypes.TEXT,
|
||||
variables_scores: DataTypes.TEXT,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "active",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Active);
|
||||
|
||||
Active._preCreateProcessing = function (data) {
|
||||
return data;
|
||||
};
|
||||
Active._postCreateProcessing = function (data) {
|
||||
return data;
|
||||
};
|
||||
Active._customCountingConditions = function (data) {
|
||||
return data;
|
||||
};
|
||||
|
||||
Active._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Active.allowFields();
|
||||
allowedFields.push(Active._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Active.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Active.associate = function (models) {};
|
||||
|
||||
Active.allowFields = function () {
|
||||
return ["id", "name", "handle", "variables_scores", "description"];
|
||||
};
|
||||
|
||||
Active.labels = function () {
|
||||
return ["ID", "Name", "Handle", "Variables scores", "Description"];
|
||||
};
|
||||
|
||||
Active.validationRules = function () {
|
||||
return [
|
||||
["id", "ID", ""],
|
||||
["name", "Name", "required"],
|
||||
["variables_scores", "Variables scores", ""],
|
||||
["description", "Description", ""],
|
||||
];
|
||||
};
|
||||
|
||||
Active.validationEditRules = function () {
|
||||
return [
|
||||
["id", "ID", ""],
|
||||
["name", "Name", "required"],
|
||||
["variables_scores", "Variables scores", ""],
|
||||
["description", "Description", ""],
|
||||
];
|
||||
};
|
||||
|
||||
// ex
|
||||
Active.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(["id", "name", "handle", "variables_scores", "description", "created_at", "updated_at"], Object.keys(fields));
|
||||
} else return [];
|
||||
};
|
||||
|
||||
return Active;
|
||||
};
|
||||
@@ -0,0 +1,133 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* activity_log Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require('lodash');
|
||||
const coreModel = require('./../core/models');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Activity_log = sequelize.define(
|
||||
"activity_log",
|
||||
{
|
||||
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
name: DataTypes.STRING,
|
||||
action: DataTypes.STRING,
|
||||
data: DataTypes.TEXT,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "activity_log",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Activity_log);
|
||||
|
||||
Activity_log._preCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Activity_log._postCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Activity_log._customCountingConditions = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
Activity_log._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Activity_log.allowFields();
|
||||
allowedFields.push(Activity_log._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Activity_log.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Activity_log.associate = function(models) { };
|
||||
|
||||
|
||||
|
||||
Activity_log.allowFields = function () {
|
||||
return ['id','name','action','data',];
|
||||
};
|
||||
|
||||
Activity_log.labels = function () {
|
||||
return ['ID','Name','Action','Data',];
|
||||
};
|
||||
|
||||
Activity_log.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['name', 'Name', ''],
|
||||
['action', 'Action', 'required'],
|
||||
['data', 'Data', 'required'],
|
||||
];
|
||||
};
|
||||
|
||||
Activity_log.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['name', 'Name', ''],
|
||||
['action', 'Action', 'required'],
|
||||
['data', 'Data', 'required'],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ex
|
||||
Activity_log.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id','name','action','data','created_at','updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Activity_log;
|
||||
};
|
||||
@@ -0,0 +1,156 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* admin_operation Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require('lodash');
|
||||
const coreModel = require('./../core/models');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Admin_operation = sequelize.define(
|
||||
"admin_operation",
|
||||
{
|
||||
user_id: DataTypes.INTEGER,
|
||||
action: DataTypes.STRING,
|
||||
detail: DataTypes.TEXT,
|
||||
last_ip: DataTypes.STRING,
|
||||
user_agent: DataTypes.STRING,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "admin_operation",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Admin_operation);
|
||||
|
||||
Admin_operation._preCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Admin_operation._postCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Admin_operation._customCountingConditions = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
Admin_operation._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Admin_operation.allowFields();
|
||||
allowedFields.push(Admin_operation._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Admin_operation.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Admin_operation.associate = function(models) {
|
||||
Admin_operation.belongsTo(models.user, {
|
||||
foreignKey: "user_id",
|
||||
as: "user",
|
||||
constraints: false,
|
||||
}) };
|
||||
|
||||
|
||||
|
||||
Admin_operation.allowFields = function () {
|
||||
return ['user_id','action','detail','last_ip','user_agent',];
|
||||
};
|
||||
|
||||
Admin_operation.labels = function () {
|
||||
return ['User','Action','Detail','Last IP','User Agent',];
|
||||
};
|
||||
|
||||
Admin_operation.validationRules = function () {
|
||||
return [
|
||||
['user_id', 'User', 'required|integer'],
|
||||
['action', 'Action', 'required|max[50]'],
|
||||
['detail', 'Detail', 'required'],
|
||||
['last_ip', 'Last IP', 'required'],
|
||||
['user_agent', 'User Agent', 'required'],
|
||||
];
|
||||
};
|
||||
|
||||
Admin_operation.validationEditRules = function () {
|
||||
return [
|
||||
['user_id', 'User', ''],
|
||||
['action', 'Action', ''],
|
||||
['detail', 'Detail', ''],
|
||||
['last_ip', 'Last IP', ''],
|
||||
['user_agent', 'User Agent', ''],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
Admin_operation.get_user_paginated = function(db, where = {}, ...rest) {
|
||||
return Admin_operation.getPaginated(...rest, [{
|
||||
model: db.user,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "user",
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
Admin_operation.get_admin_operation_user = (id, db) => {
|
||||
return Admin_operation.findByPk(id,
|
||||
{
|
||||
include: [
|
||||
{
|
||||
model: db.user,
|
||||
required: false,
|
||||
as: "user",
|
||||
}
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
// ex
|
||||
Admin_operation.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'user_id','action','detail','last_ip','user_agent','created_at','updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Admin_operation;
|
||||
};
|
||||
@@ -0,0 +1,214 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* answer Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require("bcryptjs");
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require("lodash");
|
||||
const coreModel = require("./../core/models");
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Answer = sequelize.define(
|
||||
"answer",
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
question_id: DataTypes.INTEGER,
|
||||
order: DataTypes.INTEGER,
|
||||
answer: DataTypes.TEXT,
|
||||
answer_value: DataTypes.FLOAT,
|
||||
hide_answer: DataTypes.BOOLEAN,
|
||||
explaination: DataTypes.TEXT,
|
||||
image_id: DataTypes.TEXT,
|
||||
response_header: DataTypes.TEXT,
|
||||
response_body: DataTypes.TEXT,
|
||||
response_arguments: DataTypes.TEXT,
|
||||
black_list_actives: DataTypes.TEXT,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "answer",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Answer);
|
||||
|
||||
Answer._preCreateProcessing = function (data) {
|
||||
return data;
|
||||
};
|
||||
Answer._postCreateProcessing = function (data) {
|
||||
return data;
|
||||
};
|
||||
Answer._customCountingConditions = function (data) {
|
||||
return data;
|
||||
};
|
||||
|
||||
Answer._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Answer.allowFields();
|
||||
allowedFields.push(Answer._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Answer.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Answer.associate = function (models) {
|
||||
Answer.belongsTo(models.question, {
|
||||
foreignKey: "question_id",
|
||||
as: "question",
|
||||
constraints: false,
|
||||
});
|
||||
Answer.belongsTo(models.image, {
|
||||
foreignKey: "image_id",
|
||||
as: "image",
|
||||
constraints: false,
|
||||
});
|
||||
};
|
||||
|
||||
Answer.allowFields = function () {
|
||||
return ["id", "question_id", "order", "answer", "answer_value", "hide_answer", "explaination", "image_id", "response_header", "response_body", "response_arguments", "black_list_actives"];
|
||||
};
|
||||
|
||||
Answer.labels = function () {
|
||||
return ["ID", "Question ID", "Order", "Answer", "Answer value", "Hide answer", "Explaination", "Image ID", "Response header", "Response body", "Response arguments", "Black listed actives"];
|
||||
};
|
||||
|
||||
Answer.validationRules = function () {
|
||||
return [
|
||||
["id", "ID", ""],
|
||||
["question_id", "Question ID", "required"],
|
||||
["order", "Order", "required"],
|
||||
["answer", "Answer", "required"],
|
||||
["answer_value", "Answer value", ""],
|
||||
["hide_answer", "Hide answer", ""],
|
||||
["explaination", "Explaination", ""],
|
||||
["image_id", "Image ID", ""],
|
||||
["response_header", "Response header", ""],
|
||||
["response_body", "Response body", ""],
|
||||
["response_arguments", "Response arguments", ""],
|
||||
["black_list_actives", "Black listed actives", ""],
|
||||
];
|
||||
};
|
||||
|
||||
Answer.validationEditRules = function () {
|
||||
return [
|
||||
["id", "ID", ""],
|
||||
["question_id", "Question ID", "required"],
|
||||
["order", "Order", "required"],
|
||||
["answer", "Answer", "required"],
|
||||
["answer_value", "Answer value", ""],
|
||||
["hide_answer", "Hide answer", ""],
|
||||
["explaination", "Explaination", ""],
|
||||
["image_id", "Image ID", ""],
|
||||
["response_header", "Response header", ""],
|
||||
["response_body", "Response body", ""],
|
||||
["response_arguments", "Response arguments", ""],
|
||||
["black_list_actives", "Black listed actives", ""],
|
||||
];
|
||||
};
|
||||
|
||||
Answer.get_question_paginated = function (db, where = {}, ...rest) {
|
||||
return Answer.getPaginated(...rest, [
|
||||
{
|
||||
model: db.question,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "question",
|
||||
},
|
||||
]);
|
||||
};
|
||||
|
||||
Answer.get_image_paginated = function (db, where = {}, ...rest) {
|
||||
return Answer.getPaginated(...rest, [
|
||||
{
|
||||
model: db.image,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "image",
|
||||
},
|
||||
]);
|
||||
};
|
||||
|
||||
Answer.get_answer_question = (id, db) => {
|
||||
return Answer.findByPk(id, {
|
||||
include: [
|
||||
{
|
||||
model: db.question,
|
||||
required: false,
|
||||
as: "question",
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
Answer.get_answer_image = (id, db) => {
|
||||
return Answer.findByPk(id, {
|
||||
include: [
|
||||
{
|
||||
model: db.image,
|
||||
required: false,
|
||||
as: "image",
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
// ex
|
||||
Answer.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
"id",
|
||||
"question_id",
|
||||
"order",
|
||||
"answer",
|
||||
"answer_value",
|
||||
"hide_answer",
|
||||
"explaination",
|
||||
"image_id",
|
||||
"response_header",
|
||||
"response_body",
|
||||
"response_arguments",
|
||||
"black_list_actives",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
],
|
||||
Object.keys(fields)
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
return Answer;
|
||||
};
|
||||
@@ -0,0 +1,116 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* configuration Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require("bcryptjs");
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require("lodash");
|
||||
const coreModel = require("./../core/models");
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Configuration = sequelize.define(
|
||||
"configuration",
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
image_id: DataTypes.INTEGER,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "configuration",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Configuration);
|
||||
|
||||
Configuration._preCreateProcessing = function (data) {
|
||||
return data;
|
||||
};
|
||||
Configuration._postCreateProcessing = function (data) {
|
||||
return data;
|
||||
};
|
||||
Configuration._customCountingConditions = function (data) {
|
||||
return data;
|
||||
};
|
||||
|
||||
Configuration._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Configuration.allowFields();
|
||||
allowedFields.push(Configuration._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Configuration.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Configuration.associate = function (models) {
|
||||
Configuration.belongsTo(models.image, {
|
||||
foreignKey: "image_id",
|
||||
as: "image",
|
||||
constraints: false,
|
||||
});
|
||||
};
|
||||
|
||||
Configuration.allowFields = function () {
|
||||
return ["id", "image_id"];
|
||||
};
|
||||
|
||||
Configuration.labels = function () {
|
||||
return ["ID", "Image"];
|
||||
};
|
||||
|
||||
Configuration.validationRules = function () {
|
||||
return [
|
||||
["id", "ID", ""],
|
||||
["image_id", "Image", "required"],
|
||||
];
|
||||
};
|
||||
|
||||
Configuration.validationEditRules = function () {
|
||||
return [
|
||||
["id", "ID", ""],
|
||||
["image_id", "Image", "required"],
|
||||
];
|
||||
};
|
||||
|
||||
// ex
|
||||
Configuration.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(["id", "image_id", "created_at", "updated_at"], Object.keys(fields));
|
||||
} else return [];
|
||||
};
|
||||
|
||||
return Configuration;
|
||||
};
|
||||
@@ -0,0 +1,208 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* credential Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require('lodash');
|
||||
const coreModel = require('./../core/models');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Credential = sequelize.define(
|
||||
"credential",
|
||||
{
|
||||
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
oauth: DataTypes.STRING,
|
||||
email: DataTypes.STRING,
|
||||
password: DataTypes.STRING,
|
||||
user_id: DataTypes.INTEGER,
|
||||
type: DataTypes.INTEGER,
|
||||
verify: DataTypes.INTEGER,
|
||||
status: DataTypes.INTEGER,
|
||||
two_factor_authentication: DataTypes.INTEGER,
|
||||
force_password_change: DataTypes.BOOLEAN,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "credential",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Credential);
|
||||
|
||||
Credential._preCreateProcessing = function (data) {
|
||||
if(!data.status) data.status = 1;
|
||||
if(!data.two_factor_authentication) data.two_factor_authentication = 0;
|
||||
return data;
|
||||
};
|
||||
Credential._postCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Credential._customCountingConditions = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
Credential._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Credential.allowFields();
|
||||
allowedFields.push(Credential._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Credential.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Credential.associate = function(models) {
|
||||
Credential.belongsTo(models.user, {
|
||||
foreignKey: "user_id",
|
||||
as: "user",
|
||||
constraints: false,
|
||||
}) };
|
||||
|
||||
|
||||
Credential.verify_mapping = function (verify) {
|
||||
const mapping = {"0":"Not verified","1":"Verified"}
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[verify];
|
||||
};
|
||||
|
||||
|
||||
Credential.status_mapping = function (status) {
|
||||
const mapping = {"0":"Inactive","1":"Active","2":"Suspend"}
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[status];
|
||||
};
|
||||
|
||||
|
||||
Credential.type_mapping = function (type) {
|
||||
const mapping = {"0":"normal","1":"facebook","2":"google","3":"twitter"}
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[type];
|
||||
};
|
||||
|
||||
|
||||
Credential.two_factor_authentication_mapping = function (two_factor_authentication) {
|
||||
const mapping = {"0":"No","1":"Yes"}
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[two_factor_authentication];
|
||||
};
|
||||
|
||||
|
||||
Credential.allowFields = function () {
|
||||
return ['id','oauth','email','password','user_id','type','verify','status','two_factor_authentication','force_password_change',];
|
||||
};
|
||||
|
||||
Credential.labels = function () {
|
||||
return ['ID','ID','Email','Password','User','Type','Verified','Status','Two factor authentication','',];
|
||||
};
|
||||
|
||||
Credential.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['oauth', 'ID', ''],
|
||||
['email', 'Email', 'required|valid_email'],
|
||||
['password', 'Password', 'required'],
|
||||
['user_id', 'User', ''],
|
||||
['type', 'Type', 'required'],
|
||||
['verify', 'Verified', 'required'],
|
||||
['status', 'Status', 'required'],
|
||||
['two_factor_authentication', 'Two factor authentication', ''],
|
||||
['force_password_change', '', ''],
|
||||
];
|
||||
};
|
||||
|
||||
Credential.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['oauth', 'ID', ''],
|
||||
['email', 'Email', 'required|valid_email'],
|
||||
['password', 'Password', ''],
|
||||
['user_id', 'User', ''],
|
||||
['type', 'Type', 'required'],
|
||||
['verify', 'Verified', 'required'],
|
||||
['status', 'Status', 'required'],
|
||||
['two_factor_authentication', 'Two factor authentication', ''],
|
||||
['force_password_change', '', ''],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
Credential.get_user_paginated = function(db, where = {}, ...rest) {
|
||||
return Credential.getPaginated(...rest, [{
|
||||
model: db.user,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "user",
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
Credential.get_credential_user = (id, db) => {
|
||||
return Credential.findByPk(id,
|
||||
{
|
||||
include: [
|
||||
{
|
||||
model: db.user,
|
||||
required: false,
|
||||
as: "user",
|
||||
}
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
// ex
|
||||
Credential.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id','oauth','email','password','user_id','type','verify','status','two_factor_authentication','force_password_change','created_at','updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Credential;
|
||||
};
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* email Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require('lodash');
|
||||
const coreModel = require('./../core/models');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Email = sequelize.define(
|
||||
"email",
|
||||
{
|
||||
slug: DataTypes.STRING,
|
||||
subject: DataTypes.TEXT,
|
||||
tag: DataTypes.TEXT,
|
||||
html: DataTypes.TEXT,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "email",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Email);
|
||||
|
||||
Email._preCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Email._postCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Email._customCountingConditions = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
Email._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Email.allowFields();
|
||||
allowedFields.push(Email._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Email.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Email.associate = function(models) { };
|
||||
|
||||
|
||||
Email.type_mapping = function (type) {
|
||||
const mapping = {"0":"Forgot_token","1":"Access token","2":"Refresh_token","3":"Other","4":"Api Key","5":"Api Secret","6":"Verify"}
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[type];
|
||||
};
|
||||
|
||||
|
||||
Email.allowFields = function () {
|
||||
return ['slug','subject','tag','html',];
|
||||
};
|
||||
|
||||
Email.labels = function () {
|
||||
return ['Email Type','Subject','Replacement Tags','Email Body',];
|
||||
};
|
||||
|
||||
Email.validationRules = function () {
|
||||
return [
|
||||
['slug', 'Email Type', 'required|is_unique[email.slug]'],
|
||||
['subject', 'Subject', 'required'],
|
||||
['tag', 'Replacement Tags', 'required'],
|
||||
['html', 'Email Body', 'required'],
|
||||
];
|
||||
};
|
||||
|
||||
Email.validationEditRules = function () {
|
||||
return [
|
||||
['slug', 'Email Type', ''],
|
||||
['subject', 'Subject', 'required'],
|
||||
['tag', 'Replacement Tags', ''],
|
||||
['html', 'Email Body', 'required'],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ex
|
||||
Email.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'slug','subject','tag','html','created_at','updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Email;
|
||||
};
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* image Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require("bcryptjs");
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require("lodash");
|
||||
const coreModel = require("./../core/models");
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Image = sequelize.define(
|
||||
"image",
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
url: DataTypes.TEXT,
|
||||
caption: DataTypes.TEXT,
|
||||
user_id: DataTypes.INTEGER,
|
||||
width: DataTypes.INTEGER,
|
||||
height: DataTypes.INTEGER,
|
||||
mobile_width: DataTypes.INTEGER,
|
||||
mobile_height: DataTypes.INTEGER,
|
||||
upload_type: DataTypes.INTEGER,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "image",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Image);
|
||||
|
||||
Image._preCreateProcessing = function (data) {
|
||||
return data;
|
||||
};
|
||||
Image._postCreateProcessing = function (data) {
|
||||
return data;
|
||||
};
|
||||
Image._customCountingConditions = function (data) {
|
||||
return data;
|
||||
};
|
||||
|
||||
Image._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Image.allowFields();
|
||||
allowedFields.push(Image._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Image.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Image.associate = function (models) {
|
||||
Image.belongsTo(models.user, {
|
||||
foreignKey: "user_id",
|
||||
as: "user",
|
||||
constraints: false,
|
||||
});
|
||||
Image.hasOne(models.configuration, {
|
||||
foreignKey: "image_id",
|
||||
as: "configuration",
|
||||
constraints: false,
|
||||
});
|
||||
Image.hasMany(models.answer, {
|
||||
foreignKey: "image_id",
|
||||
as: "answers",
|
||||
constraints: false,
|
||||
});
|
||||
};
|
||||
|
||||
Image.upload_type_mapping = function (upload_type) {
|
||||
const mapping = { 0: "Server Hosted", 1: "External Link", 2: "S3", 3: "Cloudinary", 4: "File", 5: "External File", 6: "Local Hosted" };
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[upload_type];
|
||||
};
|
||||
|
||||
Image.allowFields = function () {
|
||||
return ["image_id", "id", "url", "caption", "user_id", "width", "height", "mobile_width", "mobile_height", "upload_type"];
|
||||
};
|
||||
|
||||
Image.labels = function () {
|
||||
return ["ID", "URL", "Caption", "User", "Width", "Height", "Mobile width", "Mobile height", "Upload Type"];
|
||||
};
|
||||
|
||||
Image.validationRules = function () {
|
||||
return [
|
||||
["id", "ID", ""],
|
||||
["url", "URL", "required"],
|
||||
["caption", "Caption", ""],
|
||||
["user_id", "User", ""],
|
||||
["width", "Width", ""],
|
||||
["height", "Height", ""],
|
||||
["mobile_width", "Mobile width", ""],
|
||||
["mobile_height", "Mobile height", ""],
|
||||
["upload_type", "Upload Type", ""],
|
||||
];
|
||||
};
|
||||
|
||||
Image.validationEditRules = function () {
|
||||
return [
|
||||
["id", "ID", ""],
|
||||
["url", "URL", "required"],
|
||||
["caption", "Caption", ""],
|
||||
["user_id", "User", ""],
|
||||
["width", "Width", ""],
|
||||
["height", "Height", ""],
|
||||
["mobile_width", "Mobile width", ""],
|
||||
["mobile_height", "Mobile height", ""],
|
||||
["upload_type", "Upload Type", ""],
|
||||
];
|
||||
};
|
||||
|
||||
Image.get_user_paginated = function (db, where = {}, ...rest) {
|
||||
return Image.getPaginated(...rest, [
|
||||
{
|
||||
model: db.user,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "user",
|
||||
},
|
||||
]);
|
||||
};
|
||||
|
||||
Image.get_answer_paginated = function (db, where = {}, ...rest) {
|
||||
return Image.getPaginated(...rest, [
|
||||
{
|
||||
model: db.answer,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "answers",
|
||||
},
|
||||
]);
|
||||
};
|
||||
|
||||
Image.get_image_user = (id, db) => {
|
||||
return Image.findByPk(id, {
|
||||
include: [
|
||||
{
|
||||
model: db.user,
|
||||
required: false,
|
||||
as: "user",
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
Image.get_image_answer = (id, db) => {
|
||||
return Image.findByPk(id, {
|
||||
include: [
|
||||
{
|
||||
model: db.answer,
|
||||
required: false,
|
||||
as: "answers",
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
// ex
|
||||
Image.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(["id", "url", "caption", "user_id", "width", "height", "mobile_width", "mobile_height", "upload_type", "created_at", "updated_at"], Object.keys(fields));
|
||||
} else return [];
|
||||
};
|
||||
|
||||
return Image;
|
||||
};
|
||||
@@ -0,0 +1,61 @@
|
||||
'use strict';
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2020*/
|
||||
/**
|
||||
* Sequelize File
|
||||
* @copyright 2020 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
let Sequelize = require('sequelize');
|
||||
const basename = path.basename(__filename);
|
||||
const dotenv = require('dotenv');
|
||||
dotenv.config();
|
||||
|
||||
let db = {};
|
||||
|
||||
let sequelize = new Sequelize(process.env.DB_DATABASE, process.env.DB_USERNAME, process.env.DB_PASSWORD, {
|
||||
dialect: process.env.DB_ADAPTER,
|
||||
username: process.env.DB_USERNAME,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME,
|
||||
host: process.env.DB_HOSTNAME,
|
||||
port: process.env.DB_PORT,
|
||||
logging: console.log,
|
||||
timezone: '-04:00',
|
||||
pool: {
|
||||
maxConnections: 1,
|
||||
minConnections: 0,
|
||||
maxIdleTime: 100,
|
||||
},
|
||||
define: {
|
||||
timestamps: false,
|
||||
underscoredAll: true,
|
||||
underscored: true,
|
||||
},
|
||||
});
|
||||
|
||||
// sequelize.sync({ force: true });
|
||||
|
||||
fs.readdirSync(__dirname)
|
||||
.filter((file) => {
|
||||
return file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js';
|
||||
})
|
||||
.forEach((file) => {
|
||||
var model = sequelize['import'](path.join(__dirname, file));
|
||||
db[model.name] = model;
|
||||
});
|
||||
|
||||
Object.keys(db).forEach((modelName) => {
|
||||
if (db[modelName].associate) {
|
||||
db[modelName].associate(db);
|
||||
}
|
||||
});
|
||||
|
||||
db.sequelize = sequelize;
|
||||
db.Sequelize = Sequelize;
|
||||
|
||||
module.exports = db;
|
||||
@@ -0,0 +1,163 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* member_operation Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require('lodash');
|
||||
const coreModel = require('./../core/models');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Member_operation = sequelize.define(
|
||||
"member_operation",
|
||||
{
|
||||
action: DataTypes.STRING,
|
||||
detail: DataTypes.TEXT,
|
||||
last_ip: DataTypes.STRING,
|
||||
user_agent: DataTypes.STRING,
|
||||
status: DataTypes.INTEGER,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "member_operation",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Member_operation);
|
||||
|
||||
Member_operation._preCreateProcessing = function (data) {
|
||||
if(!data.status) data.status = 1;
|
||||
return data;
|
||||
};
|
||||
Member_operation._postCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Member_operation._customCountingConditions = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
Member_operation._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Member_operation.allowFields();
|
||||
allowedFields.push(Member_operation._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Member_operation.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Member_operation.associate = function(models) {
|
||||
Member_operation.belongsTo(models.user, {
|
||||
foreignKey: "user_id",
|
||||
as: "user",
|
||||
constraints: false,
|
||||
}) };
|
||||
|
||||
|
||||
Member_operation.status_mapping = function (status) {
|
||||
const mapping = {"0":"Inactive","1":"Active"}
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[status];
|
||||
};
|
||||
|
||||
|
||||
Member_operation.allowFields = function () {
|
||||
return ["user_id",'action','detail','last_ip','user_agent','status',];
|
||||
};
|
||||
|
||||
Member_operation.labels = function () {
|
||||
return ['Action','Detail','Last IP','User Agent','Status',];
|
||||
};
|
||||
|
||||
Member_operation.validationRules = function () {
|
||||
return [
|
||||
['action', 'Action', 'required|max[50]'],
|
||||
['detail', 'Detail', 'required'],
|
||||
['last_ip', 'Last IP', 'required'],
|
||||
['user_agent', 'User Agent', 'required'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
Member_operation.validationEditRules = function () {
|
||||
return [
|
||||
['action', 'Action', ''],
|
||||
['detail', 'Detail', ''],
|
||||
['last_ip', 'Last IP', ''],
|
||||
['user_agent', 'User Agent', ''],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
Member_operation.get_user_paginated = function(db, where = {}, ...rest) {
|
||||
return Member_operation.getPaginated(...rest, [{
|
||||
model: db.user,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "user",
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
Member_operation.get_member_operation_user = (id, db) => {
|
||||
return Member_operation.findByPk(id,
|
||||
{
|
||||
include: [
|
||||
{
|
||||
model: db.user,
|
||||
required: false,
|
||||
as: "user",
|
||||
}
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
// ex
|
||||
Member_operation.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'action','detail','last_ip','user_agent','status','created_at','updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Member_operation;
|
||||
};
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* order Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require("bcryptjs");
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require("lodash");
|
||||
const coreModel = require("./../core/models");
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Order = sequelize.define(
|
||||
"order",
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
webhook_id: {
|
||||
type: DataTypes.STRING,
|
||||
unique: true,
|
||||
},
|
||||
shopify_id: {
|
||||
type: DataTypes.STRING,
|
||||
unique: true,
|
||||
},
|
||||
event: DataTypes.TEXT,
|
||||
customer_shopify_id: DataTypes.STRING,
|
||||
customer: DataTypes.TEXT,
|
||||
answers: DataTypes.TEXT,
|
||||
profile: DataTypes.TEXT,
|
||||
actives: DataTypes.TEXT,
|
||||
items: DataTypes.TEXT,
|
||||
financial_status: DataTypes.STRING,
|
||||
fulfillment_status: DataTypes.STRING,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "order",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Order);
|
||||
|
||||
Order._preCreateProcessing = function (data) {
|
||||
return data;
|
||||
};
|
||||
Order._postCreateProcessing = function (data) {
|
||||
return data;
|
||||
};
|
||||
Order._customCountingConditions = function (data) {
|
||||
return data;
|
||||
};
|
||||
|
||||
Order._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Order.allowFields();
|
||||
allowedFields.push(Order._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Order.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Order.associate = function (models) {};
|
||||
|
||||
Order.allowFields = function () {
|
||||
return ["id", "webhook_id", "shopify_id", "event", "profile", "actives", "customer_shopify_id", "customer", "answers", "items", "financial_status", "fulfillment_status"];
|
||||
};
|
||||
|
||||
Order.labels = function () {
|
||||
return ["ID", "Webhook Id", "Order shopify id", "Event", "Profile", "Actives", "Customer", "Customer", "Answers", "Items", "Financial status", "Fulfillment status"];
|
||||
};
|
||||
|
||||
Order.validationRules = function () {
|
||||
return [
|
||||
["id", "ID", ""],
|
||||
["shopify_id", "Order shopify id", ""],
|
||||
["event", "Event", ""],
|
||||
["customer_shopify_id", "Customer", ""],
|
||||
["customer", "Customer", ""],
|
||||
["answers", "Answers", ""],
|
||||
["items", "Items", ""],
|
||||
["financial_status", "Financial status", ""],
|
||||
["fulfillment_status", "Fulfillment status", ""],
|
||||
];
|
||||
};
|
||||
|
||||
Order.validationEditRules = function () {
|
||||
return [
|
||||
["id", "ID", ""],
|
||||
["shopify_id", "Order shopify id", ""],
|
||||
["event", "Event", ""],
|
||||
["customer_shopify_id", "Customer", ""],
|
||||
["customer", "Customer", ""],
|
||||
["answers", "Answers", ""],
|
||||
["items", "Items", ""],
|
||||
["financial_status", "Financial status", ""],
|
||||
["fulfillment_status", "Fulfillment status", ""],
|
||||
];
|
||||
};
|
||||
|
||||
// ex
|
||||
Order.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
["id", "webhook_id", "shopify_id", "event", "customer_shopify_id", "profile", "actives", "customer", "answers", "items", "financial_status", "fulfillment_status", "created_at", "updated_at"],
|
||||
Object.keys(fields)
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
return Order;
|
||||
};
|
||||
@@ -0,0 +1,119 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* output_variable Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require("bcryptjs");
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require("lodash");
|
||||
const coreModel = require("./../core/models");
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Output_variable = sequelize.define(
|
||||
"output_variable",
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
name: DataTypes.STRING,
|
||||
priority: DataTypes.FLOAT,
|
||||
active_list: DataTypes.TEXT,
|
||||
ranges_response: DataTypes.TEXT,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "output_variable",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Output_variable);
|
||||
|
||||
Output_variable._preCreateProcessing = function (data) {
|
||||
return data;
|
||||
};
|
||||
Output_variable._postCreateProcessing = function (data) {
|
||||
return data;
|
||||
};
|
||||
Output_variable._customCountingConditions = function (data) {
|
||||
return data;
|
||||
};
|
||||
|
||||
Output_variable._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Output_variable.allowFields();
|
||||
allowedFields.push(Output_variable._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Output_variable.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Output_variable.associate = function (models) {};
|
||||
|
||||
Output_variable.allowFields = function () {
|
||||
return ["id", "name", "priority", "active_list", "ranges_response"];
|
||||
};
|
||||
|
||||
Output_variable.labels = function () {
|
||||
return ["ID", "Name", "Priority", "Actives list", "Ranges responses"];
|
||||
};
|
||||
|
||||
Output_variable.validationRules = function () {
|
||||
return [
|
||||
["id", "ID", ""],
|
||||
["name", "Name", "required"],
|
||||
["priority", "Priority", "required"],
|
||||
["active_list", "Actives list", "required"],
|
||||
["ranges_response", "Ranges responses", "required"],
|
||||
];
|
||||
};
|
||||
|
||||
Output_variable.validationEditRules = function () {
|
||||
return [
|
||||
["id", "ID", ""],
|
||||
["name", "Name", "required"],
|
||||
["priority", "Priority", "required"],
|
||||
["active_list", "Actives list", "required"],
|
||||
["ranges_response", "Ranges responses", "required"],
|
||||
];
|
||||
};
|
||||
|
||||
// ex
|
||||
Output_variable.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(["id", "name", "priority", "active_list", "ranges_response", "created_at", "updated_at"], Object.keys(fields));
|
||||
} else return [];
|
||||
};
|
||||
|
||||
return Output_variable;
|
||||
};
|
||||
@@ -0,0 +1,304 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* question Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require("bcryptjs");
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require("lodash");
|
||||
const coreModel = require("./../core/models");
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Question = sequelize.define(
|
||||
"question",
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
quiz_id: DataTypes.INTEGER,
|
||||
question: DataTypes.TEXT,
|
||||
question_arguments: DataTypes.TEXT,
|
||||
order: DataTypes.INTEGER,
|
||||
image_width: DataTypes.FLOAT,
|
||||
image_height: DataTypes.FLOAT,
|
||||
placeholder: DataTypes.STRING,
|
||||
note: DataTypes.TEXT,
|
||||
note_type: DataTypes.INTEGER,
|
||||
target: DataTypes.INTEGER,
|
||||
response: DataTypes.TEXT,
|
||||
save_response_into: DataTypes.STRING,
|
||||
depends_on: DataTypes.STRING,
|
||||
slider_range: DataTypes.STRING,
|
||||
output_variable_name: DataTypes.STRING,
|
||||
weight: DataTypes.FLOAT,
|
||||
extra_output_variable: DataTypes.TEXT,
|
||||
type: DataTypes.INTEGER,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "question",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Question);
|
||||
|
||||
Question._preCreateProcessing = function (data) {
|
||||
return data;
|
||||
};
|
||||
Question._postCreateProcessing = function (data) {
|
||||
return data;
|
||||
};
|
||||
Question._customCountingConditions = function (data) {
|
||||
return data;
|
||||
};
|
||||
|
||||
Question._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Question.allowFields();
|
||||
allowedFields.push(Question._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Question.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Question.associate = function (models) {
|
||||
Question.belongsTo(models.quiz, {
|
||||
foreignKey: "quiz_id",
|
||||
as: "quiz",
|
||||
constraints: false,
|
||||
});
|
||||
Question.hasMany(models.answer, {
|
||||
foreignKey: "question_id",
|
||||
as: "answers",
|
||||
constraints: false,
|
||||
});
|
||||
};
|
||||
|
||||
Question.type_mapping = function (type) {
|
||||
const mapping = { 1: "text", 2: "number", 3: "date", 4: "mcq", 5: "mcqi", 6: "slide", 7: "selection", 8: "geolocation" };
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[type];
|
||||
};
|
||||
|
||||
Question.target_mapping = function (target) {
|
||||
const mapping = { 1: "female", 2: "male", 3: "non-binary", 4: "all" };
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[target];
|
||||
};
|
||||
|
||||
Question.note_type_mapping = function (note_type) {
|
||||
const mapping = { 1: "Note", 2: "Scientific note" };
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[note_type];
|
||||
};
|
||||
|
||||
Question.allowFields = function () {
|
||||
return [
|
||||
"question_id",
|
||||
"id",
|
||||
"quiz_id",
|
||||
"question",
|
||||
"question_arguments",
|
||||
"order",
|
||||
"image_width",
|
||||
"image_height",
|
||||
"placeholder",
|
||||
"note",
|
||||
"note_type",
|
||||
"target",
|
||||
"response",
|
||||
"save_response_into",
|
||||
"depends_on",
|
||||
"slider_range",
|
||||
"output_variable_name",
|
||||
"weight",
|
||||
"extra_output_variable",
|
||||
"type",
|
||||
];
|
||||
};
|
||||
|
||||
Question.labels = function () {
|
||||
return [
|
||||
"ID",
|
||||
"Quiz ID",
|
||||
"Question",
|
||||
"Question arguments",
|
||||
"Order",
|
||||
"Image width",
|
||||
"Image height",
|
||||
"Placeholder",
|
||||
"Note",
|
||||
"Note type",
|
||||
"Target",
|
||||
"Response",
|
||||
"Save response",
|
||||
"Depends on question",
|
||||
"Slider range",
|
||||
"Output variable",
|
||||
"weight",
|
||||
"Extra output variables",
|
||||
"Type",
|
||||
];
|
||||
};
|
||||
|
||||
Question.validationRules = function () {
|
||||
return [
|
||||
["id", "ID", ""],
|
||||
["quiz_id", "Quiz ID", "required"],
|
||||
["question", "Question", "required"],
|
||||
["question_arguments", "Question arguments", ""],
|
||||
["order", "Order", "required"],
|
||||
["image_width", "Image width", "required"],
|
||||
["image_height", "Image height", "required"],
|
||||
["placeholder", "Placeholder", ""],
|
||||
["note", "Note", ""],
|
||||
["note_type", "Note type", ""],
|
||||
["target", "Target", ""],
|
||||
["response", "Response", ""],
|
||||
["save_response_into", "Save response", ""],
|
||||
["depends_on", "Depends on question", ""],
|
||||
["slider_range", "Slider range", ""],
|
||||
["output_variable_name", "Output variable", "required"],
|
||||
["weight", "weight", "required"],
|
||||
["extra_output_variable", "Extra output variables", ""],
|
||||
["type", "Type", "required"],
|
||||
];
|
||||
};
|
||||
|
||||
Question.validationEditRules = function () {
|
||||
return [
|
||||
["id", "ID", ""],
|
||||
["quiz_id", "Quiz ID", "required"],
|
||||
["question", "Question", "required"],
|
||||
["question_arguments", "Question arguments", ""],
|
||||
["order", "Order", "required"],
|
||||
["image_width", "Image width", "required"],
|
||||
["image_height", "Image height", "required"],
|
||||
["placeholder", "Placeholder", ""],
|
||||
["note", "Note", ""],
|
||||
["note_type", "Note type", ""],
|
||||
["target", "Target", ""],
|
||||
["response", "Response", ""],
|
||||
["save_response_into", "Save response", ""],
|
||||
["depends_on", "Depends on question", ""],
|
||||
["slider_range", "Slider range", ""],
|
||||
["output_variable_name", "Output variable", "required"],
|
||||
["weight", "weight", "required"],
|
||||
["extra_output_variable", "Extra output variables", ""],
|
||||
["type", "Type", "required"],
|
||||
];
|
||||
};
|
||||
|
||||
Question.get_quiz_paginated = function (db, where = {}, ...rest) {
|
||||
return Question.getPaginated(...rest, [
|
||||
{
|
||||
model: db.quiz,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "quiz",
|
||||
},
|
||||
]);
|
||||
};
|
||||
|
||||
Question.get_answer_paginated = function (db, where = {}, ...rest) {
|
||||
return Question.getPaginated(...rest, [
|
||||
{
|
||||
model: db.answer,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "answers",
|
||||
},
|
||||
]);
|
||||
};
|
||||
|
||||
Question.get_question_quiz = (id, db) => {
|
||||
return Question.findByPk(id, {
|
||||
include: [
|
||||
{
|
||||
model: db.quiz,
|
||||
required: false,
|
||||
as: "quiz",
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
Question.get_question_answer = (id, db) => {
|
||||
return Question.findByPk(id, {
|
||||
include: [
|
||||
{
|
||||
model: db.answer,
|
||||
required: false,
|
||||
as: "answers",
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
// ex
|
||||
Question.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
"id",
|
||||
"quiz_id",
|
||||
"question",
|
||||
"question_arguments",
|
||||
"order",
|
||||
"image_width",
|
||||
"image_height",
|
||||
"placeholder",
|
||||
"note",
|
||||
"note_type",
|
||||
"target",
|
||||
"response",
|
||||
"save_response_into",
|
||||
"depends_on",
|
||||
"slider_range",
|
||||
"output_variable_name",
|
||||
"weight",
|
||||
"extra_output_variable",
|
||||
"type",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
],
|
||||
Object.keys(fields)
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
return Question;
|
||||
};
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* quiz Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require('lodash');
|
||||
const coreModel = require('./../core/models');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Quiz = sequelize.define(
|
||||
"quiz",
|
||||
{
|
||||
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
name: DataTypes.STRING,
|
||||
description: DataTypes.TEXT,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "quiz",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Quiz);
|
||||
|
||||
Quiz._preCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Quiz._postCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Quiz._customCountingConditions = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
Quiz._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Quiz.allowFields();
|
||||
allowedFields.push(Quiz._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Quiz.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Quiz.associate = function(models) {
|
||||
Quiz.hasMany(models.question, {
|
||||
foreignKey: "quiz_id",
|
||||
as: "questions",
|
||||
constraints: false,
|
||||
}) };
|
||||
|
||||
|
||||
|
||||
Quiz.allowFields = function () {
|
||||
return ["quiz_id",'id','name','description',];
|
||||
};
|
||||
|
||||
Quiz.labels = function () {
|
||||
return ['ID','Name','Description',];
|
||||
};
|
||||
|
||||
Quiz.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['name', 'Name', 'required'],
|
||||
['description', 'Description', ''],
|
||||
];
|
||||
};
|
||||
|
||||
Quiz.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['name', 'Name', 'required'],
|
||||
['description', 'Description', ''],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
Quiz.get_question_paginated = function(db, where = {}, ...rest) {
|
||||
return Quiz.getPaginated(...rest, [{
|
||||
model: db.question,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "questions",
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
Quiz.get_quiz_question = (id, db) => {
|
||||
return Quiz.findByPk(id,
|
||||
{
|
||||
include: [
|
||||
{
|
||||
model: db.question,
|
||||
required: false,
|
||||
as: "questions",
|
||||
}
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
// ex
|
||||
Quiz.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id','name','description','created_at','updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Quiz;
|
||||
};
|
||||
@@ -0,0 +1,165 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* refer_log Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require('lodash');
|
||||
const coreModel = require('./../core/models');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Refer_log = sequelize.define(
|
||||
"refer_log",
|
||||
{
|
||||
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
user_id: DataTypes.INTEGER,
|
||||
referrer_user_id: DataTypes.INTEGER,
|
||||
type: DataTypes.INTEGER,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "refer_log",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Refer_log);
|
||||
|
||||
Refer_log._preCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Refer_log._postCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Refer_log._customCountingConditions = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
Refer_log._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Refer_log.allowFields();
|
||||
allowedFields.push(Refer_log._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Refer_log.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Refer_log.associate = function(models) {
|
||||
Refer_log.belongsTo(models.user, {
|
||||
foreignKey: "user_id",
|
||||
as: "user",
|
||||
constraints: false,
|
||||
}) };
|
||||
|
||||
|
||||
Refer_log.type_mapping = function (type) {
|
||||
const mapping = {"0":"user"}
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[type];
|
||||
};
|
||||
|
||||
|
||||
Refer_log.allowFields = function () {
|
||||
return ['id','user_id','referrer_user_id','type',];
|
||||
};
|
||||
|
||||
Refer_log.labels = function () {
|
||||
return ['ID','Referree User','Referrer User','Type',];
|
||||
};
|
||||
|
||||
Refer_log.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['user_id', 'Referree User', 'required|integer'],
|
||||
['referrer_user_id', 'Referrer User', 'required|integer'],
|
||||
['type', 'Type', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
Refer_log.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['user_id', 'Referree User', ''],
|
||||
['referrer_user_id', 'Referrer User', ''],
|
||||
['type', 'Type', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
Refer_log.get_user_paginated = function(db, where = {}, ...rest) {
|
||||
return Refer_log.getPaginated(...rest, [{
|
||||
model: db.user,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "user",
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
Refer_log.get_refer_log_user = (id, db) => {
|
||||
return Refer_log.findByPk(id,
|
||||
{
|
||||
include: [
|
||||
{
|
||||
model: db.user,
|
||||
required: false,
|
||||
as: "user",
|
||||
}
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
// ex
|
||||
Refer_log.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id','user_id','referrer_user_id','type','created_at','updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Refer_log;
|
||||
};
|
||||
@@ -0,0 +1,113 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* result_profile Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require("bcryptjs");
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require("lodash");
|
||||
const coreModel = require("./../core/models");
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Result_profile = sequelize.define(
|
||||
"result_profile",
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
section_title: DataTypes.STRING,
|
||||
output_variable_list: DataTypes.TEXT,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "result_profile",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Result_profile);
|
||||
|
||||
Result_profile._preCreateProcessing = function (data) {
|
||||
return data;
|
||||
};
|
||||
Result_profile._postCreateProcessing = function (data) {
|
||||
return data;
|
||||
};
|
||||
Result_profile._customCountingConditions = function (data) {
|
||||
return data;
|
||||
};
|
||||
|
||||
Result_profile._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Result_profile.allowFields();
|
||||
allowedFields.push(Result_profile._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Result_profile.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Result_profile.associate = function (models) {};
|
||||
|
||||
Result_profile.allowFields = function () {
|
||||
return ["id", "section_title", "output_variable_list"];
|
||||
};
|
||||
|
||||
Result_profile.labels = function () {
|
||||
return ["ID", "Section title", "Variables List"];
|
||||
};
|
||||
|
||||
Result_profile.validationRules = function () {
|
||||
return [
|
||||
["id", "ID", ""],
|
||||
["section_title", "Section title", ""],
|
||||
["output_variable_list", "Variables List", ""],
|
||||
];
|
||||
};
|
||||
|
||||
Result_profile.validationEditRules = function () {
|
||||
return [
|
||||
["id", "ID", ""],
|
||||
["section_title", "Section title", ""],
|
||||
["output_variable_list", "Variables List", ""],
|
||||
];
|
||||
};
|
||||
|
||||
// ex
|
||||
Result_profile.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(["id", "section_title", "output_variable_list", "created_at", "updated_at"], Object.keys(fields));
|
||||
} else return [];
|
||||
};
|
||||
|
||||
return Result_profile;
|
||||
};
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* role Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require('lodash');
|
||||
const coreModel = require('./../core/models');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Role = sequelize.define(
|
||||
"role",
|
||||
{
|
||||
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
name: DataTypes.STRING,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "role",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Role);
|
||||
|
||||
Role._preCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Role._postCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Role._customCountingConditions = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
Role._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Role.allowFields();
|
||||
allowedFields.push(Role._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Role.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Role.associate = function(models) {
|
||||
Role.hasMany(models.user, {
|
||||
foreignKey: "user_id",
|
||||
as: "users",
|
||||
constraints: false,
|
||||
}) };
|
||||
|
||||
|
||||
|
||||
Role.allowFields = function () {
|
||||
return ["user_id",'id','name',];
|
||||
};
|
||||
|
||||
Role.labels = function () {
|
||||
return ['ID','Role Name',];
|
||||
};
|
||||
|
||||
Role.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['name', 'Role Name', 'required'],
|
||||
];
|
||||
};
|
||||
|
||||
Role.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['name', 'Role Name', 'required'],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
Role.get_user_paginated = function(db, where = {}, ...rest) {
|
||||
return Role.getPaginated(...rest, [{
|
||||
model: db.user,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "users",
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
Role.get_role_user = (id, db) => {
|
||||
return Role.findByPk(id,
|
||||
{
|
||||
include: [
|
||||
{
|
||||
model: db.user,
|
||||
required: false,
|
||||
as: "users",
|
||||
}
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
// ex
|
||||
Role.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id','name','created_at','updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Role;
|
||||
};
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* rule Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require("bcryptjs");
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require("lodash");
|
||||
const coreModel = require("./../core/models");
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Rule = sequelize.define(
|
||||
"rule",
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
output_variable_name: DataTypes.STRING,
|
||||
actives: DataTypes.TEXT,
|
||||
operator: DataTypes.INTEGER,
|
||||
compare_value: DataTypes.FLOAT,
|
||||
min: DataTypes.FLOAT,
|
||||
max: DataTypes.FLOAT,
|
||||
action: DataTypes.INTEGER,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "rule",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Rule);
|
||||
|
||||
Rule._preCreateProcessing = function (data) {
|
||||
return data;
|
||||
};
|
||||
Rule._postCreateProcessing = function (data) {
|
||||
return data;
|
||||
};
|
||||
Rule._customCountingConditions = function (data) {
|
||||
return data;
|
||||
};
|
||||
|
||||
Rule._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Rule.allowFields();
|
||||
allowedFields.push(Rule._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Rule.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Rule.associate = function (models) {};
|
||||
|
||||
Rule.operator_mapping = function (operator) {
|
||||
const mapping = { 0: "=:equal", 1: "<:less than", 2: "<=:less than or equal", 3: ">:greater than", 4: ">=:greater than or equal", 5: "!=:not equal", 6: "in:between" };
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[operator];
|
||||
};
|
||||
|
||||
Rule.action_mapping = function (action) {
|
||||
const mapping = { 1: "add", 2: "remove" };
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[action];
|
||||
};
|
||||
|
||||
Rule.allowFields = function () {
|
||||
return ["id", "output_variable_name", "actives", "operator", "compare_value", "min", "max", "action"];
|
||||
};
|
||||
|
||||
Rule.labels = function () {
|
||||
return ["ID", "Output variable", "actives", "Condition operator", "Compare value", "Between Min", "Between Max", "Action"];
|
||||
};
|
||||
|
||||
Rule.validationRules = function () {
|
||||
return [
|
||||
["id", "ID", ""],
|
||||
["output_variable_name", "Output variable", "required"],
|
||||
["actives", "actives", "required"],
|
||||
["operator", "Condition operator", "required"],
|
||||
["compare_value", "Compare value", "required"],
|
||||
["min", "Between Min", ""],
|
||||
["max", "Between Max", ""],
|
||||
["action", "Action", "required"],
|
||||
];
|
||||
};
|
||||
|
||||
Rule.validationEditRules = function () {
|
||||
return [
|
||||
["id", "ID", ""],
|
||||
["output_variable_name", "Output variable", "required"],
|
||||
["actives", "actives", "required"],
|
||||
["operator", "Condition operator", "required"],
|
||||
["compare_value", "Compare value", "required"],
|
||||
["min", "Between Min", ""],
|
||||
["max", "Between Max", ""],
|
||||
["action", "Action", "required"],
|
||||
];
|
||||
};
|
||||
|
||||
// ex
|
||||
Rule.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(["id", "output_variable_name", "actives", "operator", "compare_value", "min", "max", "action", "created_at", "updated_at"], Object.keys(fields));
|
||||
} else return [];
|
||||
};
|
||||
|
||||
return Rule;
|
||||
};
|
||||
@@ -0,0 +1,151 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* setting Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require('lodash');
|
||||
const coreModel = require('./../core/models');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Setting = sequelize.define(
|
||||
"setting",
|
||||
{
|
||||
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
key: DataTypes.STRING,
|
||||
type: DataTypes.INTEGER,
|
||||
value: DataTypes.TEXT,
|
||||
maintenance: DataTypes.INTEGER,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "setting",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Setting);
|
||||
|
||||
Setting._preCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Setting._postCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Setting._customCountingConditions = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
Setting._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Setting.allowFields();
|
||||
allowedFields.push(Setting._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Setting.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Setting.associate = function(models) { };
|
||||
|
||||
|
||||
Setting.type_mapping = function (type) {
|
||||
const mapping = {"0":"text","1":"select","2":"number","3":"image","4":"read_only"}
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[type];
|
||||
};
|
||||
|
||||
|
||||
Setting.maintenance_mapping = function (maintenance) {
|
||||
const mapping = {"0":"No","1":"Yes"}
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[maintenance];
|
||||
};
|
||||
|
||||
|
||||
Setting.allowFields = function () {
|
||||
return ['id','key','type','value','maintenance',];
|
||||
};
|
||||
|
||||
Setting.labels = function () {
|
||||
return ['ID','Setting Field','Setting Type','Setting Value','Setting Type',];
|
||||
};
|
||||
|
||||
Setting.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['key', 'Setting Field', 'required'],
|
||||
['type', 'Setting Type', 'required'],
|
||||
['value', 'Setting Value', 'required'],
|
||||
['maintenance', 'Setting Type', 'required'],
|
||||
];
|
||||
};
|
||||
|
||||
Setting.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['key', 'Setting Field', ''],
|
||||
['type', 'Setting Type', ''],
|
||||
['value', 'Setting Value', 'required'],
|
||||
['maintenance', 'Setting Type', ''],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ex
|
||||
Setting.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id','key','type','value','maintenance','created_at','updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Setting;
|
||||
};
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* sms Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require('lodash');
|
||||
const coreModel = require('./../core/models');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Sms = sequelize.define(
|
||||
"sms",
|
||||
{
|
||||
slug: DataTypes.STRING,
|
||||
tag: DataTypes.TEXT,
|
||||
content: DataTypes.TEXT,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "sms",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Sms);
|
||||
|
||||
Sms._preCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Sms._postCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Sms._customCountingConditions = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
Sms._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Sms.allowFields();
|
||||
allowedFields.push(Sms._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Sms.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Sms.associate = function(models) { };
|
||||
|
||||
|
||||
|
||||
Sms.allowFields = function () {
|
||||
return ['slug','tag','content',];
|
||||
};
|
||||
|
||||
Sms.labels = function () {
|
||||
return ['SMS Slug','Replacement Tags','SMS Body',];
|
||||
};
|
||||
|
||||
Sms.validationRules = function () {
|
||||
return [
|
||||
['slug', 'SMS Slug', 'required|is_unique[sms.slug]'],
|
||||
['tag', 'Replacement Tags', 'required'],
|
||||
['content', 'SMS Body', 'required'],
|
||||
];
|
||||
};
|
||||
|
||||
Sms.validationEditRules = function () {
|
||||
return [
|
||||
['slug', 'SMS Slug', ''],
|
||||
['tag', 'Replacement Tags', ''],
|
||||
['content', 'SMS Body', 'required'],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ex
|
||||
Sms.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'slug','tag','content','created_at','updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Sms;
|
||||
};
|
||||
+187
@@ -0,0 +1,187 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* token Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require('lodash');
|
||||
const coreModel = require('./../core/models');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Token = sequelize.define(
|
||||
"token",
|
||||
{
|
||||
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
token: DataTypes.TEXT,
|
||||
data: DataTypes.TEXT,
|
||||
type: DataTypes.INTEGER,
|
||||
user_id: DataTypes.INTEGER,
|
||||
ttl: DataTypes.INTEGER,
|
||||
issue_at: DataTypes.DATE,
|
||||
expire_at: DataTypes.DATE,
|
||||
status: DataTypes.INTEGER,
|
||||
|
||||
},
|
||||
{
|
||||
timestamps: false,
|
||||
freezeTableName: true,
|
||||
tableName: "token",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Token);
|
||||
|
||||
Token._preCreateProcessing = function (data) {
|
||||
if(!data.status) data.status = 1;
|
||||
return data;
|
||||
};
|
||||
Token._postCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Token._customCountingConditions = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
Token._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Token.allowFields();
|
||||
allowedFields.push(Token._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Token.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Token.associate = function(models) {
|
||||
Token.belongsTo(models.user, {
|
||||
foreignKey: "user_id",
|
||||
as: "user",
|
||||
constraints: false,
|
||||
}) };
|
||||
|
||||
|
||||
Token.status_mapping = function (status) {
|
||||
const mapping = {"0":"Inactive","1":"Active"}
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[status];
|
||||
};
|
||||
|
||||
|
||||
Token.type_mapping = function (type) {
|
||||
const mapping = {"0":"Forgot_token","1":"Access token","2":"Refresh_token","3":"Other","4":"Api Key","5":"Api Secret","6":"Verify"}
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[type];
|
||||
};
|
||||
|
||||
|
||||
Token.allowFields = function () {
|
||||
return ['id','token','data','type','user_id','ttl','issue_at','expire_at','status',];
|
||||
};
|
||||
|
||||
Token.labels = function () {
|
||||
return ['ID','Token','Data','Token Type','User','Time To Live','Issue at','Expire at','Status',];
|
||||
};
|
||||
|
||||
Token.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['token', 'Token', 'required'],
|
||||
['data', 'Data', 'required'],
|
||||
['type', 'Token Type', 'required|integer'],
|
||||
['user_id', 'User', 'required|integer'],
|
||||
['ttl', 'Time To Live', 'required|integer'],
|
||||
['issue_at', 'Issue at', 'required'],
|
||||
['expire_at', 'Expire at', 'required'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
Token.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['token', 'Token', 'required'],
|
||||
['data', 'Data', 'required'],
|
||||
['type', 'Token Type', 'required|integer'],
|
||||
['user_id', 'User', 'required|integer'],
|
||||
['ttl', 'Time To Live', 'required|integer'],
|
||||
['issue_at', 'Issue at', 'required'],
|
||||
['expire_at', 'Expire at', 'required'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
Token.get_user_paginated = function(db, where = {}, ...rest) {
|
||||
return Token.getPaginated(...rest, [{
|
||||
model: db.user,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "user",
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
Token.get_token_user = (id, db) => {
|
||||
return Token.findByPk(id,
|
||||
{
|
||||
include: [
|
||||
{
|
||||
model: db.user,
|
||||
required: false,
|
||||
as: "user",
|
||||
}
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
// ex
|
||||
Token.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id','token','data','type','user_id','ttl','issue_at','expire_at','status','created_at','updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Token;
|
||||
};
|
||||
+357
@@ -0,0 +1,357 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* user Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require('lodash');
|
||||
const coreModel = require('./../core/models');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const User = sequelize.define(
|
||||
"user",
|
||||
{
|
||||
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
role_id: DataTypes.INTEGER,
|
||||
profile_id: DataTypes.INTEGER,
|
||||
organization_id: DataTypes.INTEGER,
|
||||
first_name: DataTypes.STRING,
|
||||
last_name: DataTypes.STRING,
|
||||
phone: DataTypes.STRING,
|
||||
image: DataTypes.TEXT,
|
||||
refer: DataTypes.STRING,
|
||||
stripe_uid: DataTypes.STRING,
|
||||
paypal_uid: DataTypes.STRING,
|
||||
expire_at: DataTypes.DATEONLY,
|
||||
status: DataTypes.INTEGER,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "user",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, User);
|
||||
|
||||
User._preCreateProcessing = function (data) {
|
||||
if(!data.image) data.image = "/image/profile.png";
|
||||
if(!data.refer) data.refer = Math.round(Math.random() * 1000000000000,0);
|
||||
if(!data.status) data.status = 1;
|
||||
if(!data.verify) data.verify = 0;
|
||||
if(!data.type)
|
||||
{
|
||||
data.type = 'n';
|
||||
}
|
||||
return data;
|
||||
};
|
||||
User._postCreateProcessing = function (data) {
|
||||
if(data.password && data.password.length < 1)
|
||||
{
|
||||
delete data.password;
|
||||
}
|
||||
if(data.image && data.image.length < 1)
|
||||
{
|
||||
delete data.image;
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
User._customCountingConditions = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
User._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = User.allowFields();
|
||||
allowedFields.push(User._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
User.timeDefaultMapping = function () {
|
||||
let results = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 60; j++) {
|
||||
let hour = i < 10 ? "0".i : i;
|
||||
let min = j < 10 ? "0".j : j;
|
||||
results[i * 60 + j] = `${hour}:${min}`;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
User.associate = function(models) {
|
||||
User.belongsTo(models.role, {
|
||||
foreignKey: "role_id",
|
||||
as: "role",
|
||||
constraints: false,
|
||||
})
|
||||
User.hasOne(models.credential, {
|
||||
foreignKey: "user_id",
|
||||
as: "credential",
|
||||
constraints: false,
|
||||
})
|
||||
User.hasMany(models.refer_log, {
|
||||
foreignKey: "user_id",
|
||||
as: "refer_logs",
|
||||
constraints: false,
|
||||
})
|
||||
User.hasMany(models.member_operation, {
|
||||
foreignKey: "user_id",
|
||||
as: "member_operations",
|
||||
constraints: false,
|
||||
})
|
||||
User.hasMany(models.admin_operation, {
|
||||
foreignKey: "user_id",
|
||||
as: "admin_operations",
|
||||
constraints: false,
|
||||
})
|
||||
User.hasMany(models.token, {
|
||||
foreignKey: "user_id",
|
||||
as: "tokens",
|
||||
constraints: false,
|
||||
})
|
||||
User.hasMany(models.image, {
|
||||
foreignKey: "user_id",
|
||||
as: "images",
|
||||
constraints: false,
|
||||
}) };
|
||||
|
||||
|
||||
User.status_mapping = function (status) {
|
||||
const mapping = {"0":"Inactive","1":"Active","2":"Suspend"}
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[status];
|
||||
};
|
||||
|
||||
|
||||
User.allowFields = function () {
|
||||
return ["user_id","user_id","user_id","user_id","user_id","user_id",'id','role_id','profile_id','organization_id','first_name','last_name','phone','image','refer','stripe_uid','paypal_uid','expire_at','status',];
|
||||
};
|
||||
|
||||
User.labels = function () {
|
||||
return ['ID','Role ID','Profile ID','Organization ID','First Name','Last Name','Phone #','Image','Refer Code','Stripe ID','PayPal ID','Expire At','Status',];
|
||||
};
|
||||
|
||||
User.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['role_id', 'Role ID', ''],
|
||||
['profile_id', 'Profile ID', ''],
|
||||
['organization_id', 'Organization ID', ''],
|
||||
['first_name', 'First Name', 'required'],
|
||||
['last_name', 'Last Name', 'required'],
|
||||
['phone', 'Phone #', ''],
|
||||
['image', 'Image', ''],
|
||||
['refer', 'Refer Code', ''],
|
||||
['stripe_uid', 'Stripe ID', ''],
|
||||
['paypal_uid', 'PayPal ID', ''],
|
||||
['expire_at', 'Expire At', ''],
|
||||
['status', 'Status', 'required'],
|
||||
];
|
||||
};
|
||||
|
||||
User.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['role_id', 'Role ID', ''],
|
||||
['profile_id', 'Profile ID', ''],
|
||||
['organization_id', 'Organization ID', ''],
|
||||
['first_name', 'First Name', ''],
|
||||
['last_name', 'Last Name', ''],
|
||||
['phone', 'Phone #', ''],
|
||||
['image', 'Image', ''],
|
||||
['refer', 'Refer Code', ''],
|
||||
['stripe_uid', 'Stripe ID', ''],
|
||||
['paypal_uid', 'PayPal ID', ''],
|
||||
['expire_at', 'Expire At', ''],
|
||||
['status', 'Status', ''],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
User.get_role_paginated = function(db, where = {}, ...rest) {
|
||||
return User.getPaginated(...rest, [{
|
||||
model: db.role,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "role",
|
||||
}])
|
||||
}
|
||||
|
||||
User.get_credential_paginated = function(db, where = {}, ...rest) {
|
||||
return User.getPaginated(...rest, [{
|
||||
model: db.credential,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "credential",
|
||||
}])
|
||||
}
|
||||
|
||||
User.get_refer_log_paginated = function(db, where = {}, ...rest) {
|
||||
return User.getPaginated(...rest, [{
|
||||
model: db.refer_log,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "refer_logs",
|
||||
}])
|
||||
}
|
||||
|
||||
User.get_member_operation_paginated = function(db, where = {}, ...rest) {
|
||||
return User.getPaginated(...rest, [{
|
||||
model: db.member_operation,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "member_operations",
|
||||
}])
|
||||
}
|
||||
|
||||
User.get_admin_operation_paginated = function(db, where = {}, ...rest) {
|
||||
return User.getPaginated(...rest, [{
|
||||
model: db.admin_operation,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "admin_operations",
|
||||
}])
|
||||
}
|
||||
|
||||
User.get_token_paginated = function(db, where = {}, ...rest) {
|
||||
return User.getPaginated(...rest, [{
|
||||
model: db.token,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "tokens",
|
||||
}])
|
||||
}
|
||||
|
||||
User.get_image_paginated = function(db, where = {}, ...rest) {
|
||||
return User.getPaginated(...rest, [{
|
||||
model: db.image,
|
||||
where: where,
|
||||
required: Object.keys(where).length > 0 ? true : false,
|
||||
as: "images",
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
User.get_user_role = (id, db) => {
|
||||
return User.findByPk(id,
|
||||
{
|
||||
include: [
|
||||
{
|
||||
model: db.role,
|
||||
required: false,
|
||||
as: "role",
|
||||
}
|
||||
]
|
||||
});
|
||||
};User.get_user_credential = (id, db) => {
|
||||
return User.findByPk(id,
|
||||
{
|
||||
include: [
|
||||
{
|
||||
model: db.credential,
|
||||
required: false,
|
||||
as: "credential",
|
||||
}
|
||||
]
|
||||
});
|
||||
};User.get_user_refer_log = (id, db) => {
|
||||
return User.findByPk(id,
|
||||
{
|
||||
include: [
|
||||
{
|
||||
model: db.refer_log,
|
||||
required: false,
|
||||
as: "refer_logs",
|
||||
}
|
||||
]
|
||||
});
|
||||
};User.get_user_member_operation = (id, db) => {
|
||||
return User.findByPk(id,
|
||||
{
|
||||
include: [
|
||||
{
|
||||
model: db.member_operation,
|
||||
required: false,
|
||||
as: "member_operations",
|
||||
}
|
||||
]
|
||||
});
|
||||
};User.get_user_admin_operation = (id, db) => {
|
||||
return User.findByPk(id,
|
||||
{
|
||||
include: [
|
||||
{
|
||||
model: db.admin_operation,
|
||||
required: false,
|
||||
as: "admin_operations",
|
||||
}
|
||||
]
|
||||
});
|
||||
};User.get_user_token = (id, db) => {
|
||||
return User.findByPk(id,
|
||||
{
|
||||
include: [
|
||||
{
|
||||
model: db.token,
|
||||
required: false,
|
||||
as: "tokens",
|
||||
}
|
||||
]
|
||||
});
|
||||
};User.get_user_image = (id, db) => {
|
||||
return User.findByPk(id,
|
||||
{
|
||||
include: [
|
||||
{
|
||||
model: db.image,
|
||||
required: false,
|
||||
as: "images",
|
||||
}
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
// ex
|
||||
User.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id','role_id','profile_id','organization_id','first_name','last_name','phone','image','refer','stripe_uid','paypal_uid','expire_at','status','created_at','updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return User;
|
||||
};
|
||||
Reference in New Issue
Block a user