day 11
This commit is contained in:
Executable
+143
@@ -0,0 +1,143 @@
|
||||
/*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 { 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: { type: DataTypes.STRING, validate: {} },
|
||||
data: DataTypes.STRING,
|
||||
status: DataTypes.INTEGER,
|
||||
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.status_mapping = function (status) {
|
||||
const mapping = { "0": "Inactive", "1": "Active", "2": "Suspend" }
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[status];
|
||||
};
|
||||
|
||||
|
||||
Activity_log.allowFields = function () {
|
||||
return ['id', 'name', 'action', 'data', 'status',];
|
||||
};
|
||||
|
||||
Activity_log.labels = function () {
|
||||
return ['ID', 'Name', 'Action', 'Data', 'Status',];
|
||||
};
|
||||
|
||||
Activity_log.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['name', 'Name', ''],
|
||||
['action', 'Action', 'required'],
|
||||
['data', 'Data', 'required'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
Activity_log.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['name', 'Name', ''],
|
||||
['action', 'Action', 'required'],
|
||||
['data', 'Data', 'required'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ex
|
||||
Activity_log.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id', 'name', 'action', 'data', 'status', 'created_at', 'updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Activity_log;
|
||||
};
|
||||
Executable
+156
@@ -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 { 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: { type: DataTypes.STRING, validate: {} },
|
||||
user_agent: { type: DataTypes.STRING, validate: {} },
|
||||
status: DataTypes.INTEGER,
|
||||
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) {
|
||||
data.status = 1;
|
||||
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.status_mapping = function (status) {
|
||||
const mapping = { "0": "Inactive", "1": "Active" }
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[status];
|
||||
};
|
||||
|
||||
|
||||
Admin_operation.allowFields = function () {
|
||||
return ['user_id', 'action', 'detail', 'last_ip', 'user_agent', 'status',];
|
||||
};
|
||||
|
||||
Admin_operation.labels = function () {
|
||||
return ['User', 'Action', 'Detail', 'Last IP', 'User Agent', 'Status',];
|
||||
};
|
||||
|
||||
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'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
Admin_operation.validationEditRules = function () {
|
||||
return [
|
||||
['user_id', 'User', ''],
|
||||
['action', 'Action', ''],
|
||||
['detail', 'Detail', ''],
|
||||
['last_ip', 'Last IP', ''],
|
||||
['user_agent', 'User Agent', ''],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
Admin_operation.get_user_paginated = function (db, ...rest) {
|
||||
return Admin_operation.getPaginated(...rest, [{
|
||||
model: db.user,
|
||||
as: "user"
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
Admin_operation.get_admin_operation_user = (id, db) => {
|
||||
return Admin_operation.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||
};
|
||||
|
||||
// ex
|
||||
Admin_operation.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'user_id', 'action', 'detail', 'last_ip', 'user_agent', 'status', 'created_at', 'updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Admin_operation;
|
||||
};
|
||||
Executable
+164
@@ -0,0 +1,164 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* calendar Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
;
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require('lodash');
|
||||
const coreModel = require('./../core/models');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Calendar = sequelize.define(
|
||||
"calendar",
|
||||
{
|
||||
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
event_id: {
|
||||
type: DataTypes.STRING,
|
||||
unique: true
|
||||
},
|
||||
title: DataTypes.STRING,
|
||||
start_date: DataTypes.DATE,
|
||||
end_date: DataTypes.DATE,
|
||||
status: DataTypes.INTEGER,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "calendar",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Calendar);
|
||||
|
||||
Calendar._preCreateProcessing = function (data) {
|
||||
data.status = 1;
|
||||
return data;
|
||||
};
|
||||
Calendar._postCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Calendar._customCountingConditions = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
Calendar._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Calendar.allowFields();
|
||||
allowedFields.push(Calendar._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Calendar.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;
|
||||
};
|
||||
|
||||
Calendar.associate = function (models) {
|
||||
Calendar.belongsTo(models.user, {
|
||||
foreignKey: "user_id",
|
||||
as: "user",
|
||||
constraints: false,
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
Calendar.status_mapping = function (status) {
|
||||
const mapping = { "0": "Inactive", "1": "Active" }
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[status];
|
||||
};
|
||||
|
||||
|
||||
Calendar.allowFields = function () {
|
||||
return ["user_id", 'id', 'event_id', 'title', 'start_date', 'end_date', 'status',];
|
||||
};
|
||||
|
||||
Calendar.labels = function () {
|
||||
return ['ID', 'Event Id', 'Title', 'Start Date', 'End Date', 'Status',];
|
||||
};
|
||||
|
||||
Calendar.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['event_id', 'Event Id', ''],
|
||||
['title', 'Title', 'required'],
|
||||
['start_date', 'Start Date', 'required'],
|
||||
['end_date', 'End Date', 'required'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
Calendar.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['event_id', 'Event Id', ''],
|
||||
['title', 'Title', 'required'],
|
||||
['start_date', 'Start Date', 'required'],
|
||||
['end_date', 'End Date', 'required'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
Calendar.get_user_paginated = function (db, ...rest) {
|
||||
return Calendar.getPaginated(...rest, [{
|
||||
model: db.user,
|
||||
as: "user"
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
Calendar.get_calendar_user = (id, db) => {
|
||||
return Calendar.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||
};
|
||||
|
||||
// ex
|
||||
Calendar.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id', 'event_id', 'title', 'start_date', 'end_date', 'status', 'created_at', 'updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Calendar;
|
||||
};
|
||||
Executable
+152
@@ -0,0 +1,152 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* code Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require('moment')
|
||||
|
||||
const { Op } = require('sequelize')
|
||||
const { intersection } = require('lodash')
|
||||
const coreModel = require('./../core/models')
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Code = sequelize.define(
|
||||
'code',
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
code: { type: DataTypes.STRING, unique: true },
|
||||
is_used: DataTypes.INTEGER,
|
||||
status: DataTypes.INTEGER,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: 'code',
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
)
|
||||
|
||||
coreModel.call(this, Code)
|
||||
|
||||
Code._preCreateProcessing = function (data) {
|
||||
return data
|
||||
}
|
||||
Code._postCreateProcessing = function (data) {
|
||||
return data
|
||||
}
|
||||
Code._customCountingConditions = function (data) {
|
||||
return data
|
||||
}
|
||||
|
||||
Code._filterAllowKeys = function (data) {
|
||||
let cleanData = {}
|
||||
let allowedFields = Code.allowFields()
|
||||
allowedFields.push(Code._primaryKey())
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key]
|
||||
}
|
||||
}
|
||||
return cleanData
|
||||
}
|
||||
|
||||
Code.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
|
||||
}
|
||||
|
||||
Code.associate = function (models) {
|
||||
Code.belongsTo(models.user, {
|
||||
foreignKey: 'user_id',
|
||||
as: 'user',
|
||||
constraints: false,
|
||||
})
|
||||
}
|
||||
|
||||
Code.is_used_mapping = function (is_used) {
|
||||
const mapping = { 0: 'No', 1: 'Yes' }
|
||||
|
||||
if (arguments.length === 0) return mapping
|
||||
else return mapping[is_used]
|
||||
}
|
||||
|
||||
Code.status_mapping = function (status) {
|
||||
const mapping = { 0: 'Inactive', 1: 'Active', 2: 'Suspend' }
|
||||
|
||||
if (arguments.length === 0) return mapping
|
||||
else return mapping[status]
|
||||
}
|
||||
|
||||
Code.allowFields = function () {
|
||||
return ['user_id', 'id', 'code', 'is_used', 'status']
|
||||
}
|
||||
|
||||
Code.labels = function () {
|
||||
return ['ID', 'Code', 'Is Used', 'Status']
|
||||
}
|
||||
|
||||
Code.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['code', 'Code', 'required'],
|
||||
['is_used', 'Is Used', ''],
|
||||
['status', 'Status', 'required|integer'],
|
||||
]
|
||||
}
|
||||
|
||||
Code.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['code', 'Code', 'required'],
|
||||
['is_used', 'Is Used', ''],
|
||||
['status', 'Status', 'required|integer'],
|
||||
]
|
||||
}
|
||||
|
||||
Code.get_user_paginated = function (db, ...rest) {
|
||||
return Code.getPaginated(...rest, [
|
||||
{
|
||||
model: db.user,
|
||||
as: 'user',
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
Code.get_code_user = (id, db) => {
|
||||
return Code.findByPk(id, { include: [{ model: db.user, as: 'user' }] })
|
||||
}
|
||||
|
||||
// ex
|
||||
Code.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
['id', 'code', 'is_used', 'status', 'created_at', 'updated_at'],
|
||||
Object.keys(fields)
|
||||
)
|
||||
} else return []
|
||||
}
|
||||
|
||||
return Code
|
||||
}
|
||||
Executable
+198
@@ -0,0 +1,198 @@
|
||||
/*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 { 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,
|
||||
},
|
||||
email: {
|
||||
type: DataTypes.STRING,
|
||||
unique: true
|
||||
},
|
||||
password: DataTypes.STRING,
|
||||
type: DataTypes.STRING,
|
||||
verify: DataTypes.INTEGER,
|
||||
role_id: 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) {
|
||||
data.status = 1;
|
||||
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.role_id_mapping = function (role_id) {
|
||||
const mapping = { "1": "Member", "2": "Admin" }
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[role_id];
|
||||
};
|
||||
|
||||
|
||||
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 ["user_id", 'id', 'email', 'password', 'type', 'verify', 'role_id', 'status', 'two_factor_authentication', 'force_password_change',];
|
||||
};
|
||||
|
||||
Credential.labels = function () {
|
||||
return ['ID', 'Email', 'Password', 'Type', 'Verified', 'Role', 'Status', 'Two factor authentication', '',];
|
||||
};
|
||||
|
||||
Credential.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['email', 'Email', 'required|valid_email'],
|
||||
['password', 'Password', 'required'],
|
||||
['type', 'Type', ''],
|
||||
['verify', 'Verified', ''],
|
||||
['role_id', 'Role', ''],
|
||||
['status', 'Status', ''],
|
||||
['two_factor_authentication', 'Two factor authentication', ''],
|
||||
['force_password_change', '', ''],
|
||||
];
|
||||
};
|
||||
|
||||
Credential.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['email', 'Email', 'required|valid_email'],
|
||||
['password', 'Password', ''],
|
||||
['type', 'Type', ''],
|
||||
['verify', 'Verified', ''],
|
||||
['role_id', 'Role', ''],
|
||||
['status', 'Status', 'required|in_list[0,1,2]'],
|
||||
['two_factor_authentication', 'Two factor authentication', ''],
|
||||
['force_password_change', '', ''],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
Credential.get_user_paginated = function (db, ...rest) {
|
||||
return Credential.getPaginated(...rest, [{
|
||||
model: db.user,
|
||||
as: "user"
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
Credential.get_credential_user = (id, db) => {
|
||||
return Credential.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||
};
|
||||
|
||||
// ex
|
||||
Credential.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id', 'email', 'password', 'type', 'verify', 'role_id', 'status', 'two_factor_authentication', 'force_password_change', 'created_at', 'updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Credential;
|
||||
};
|
||||
Executable
+149
@@ -0,0 +1,149 @@
|
||||
/*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 { Op } = require("sequelize");
|
||||
const { intersection } = require('lodash');
|
||||
const coreModel = require('./../core/models');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Email = sequelize.define(
|
||||
"email",
|
||||
{
|
||||
slug: {
|
||||
type: DataTypes.STRING,
|
||||
unique: true
|
||||
},
|
||||
subject: DataTypes.TEXT,
|
||||
tag: DataTypes.TEXT,
|
||||
html: DataTypes.TEXT,
|
||||
status: DataTypes.INTEGER,
|
||||
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) {
|
||||
data.status = 1;
|
||||
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.status_mapping = function (status) {
|
||||
const mapping = { "0": "Inactive", "1": "Active" }
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[status];
|
||||
};
|
||||
|
||||
|
||||
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', 'status',];
|
||||
};
|
||||
|
||||
Email.labels = function () {
|
||||
return ['Email Type', 'Subject', 'Replacement Tags', 'Email Body', 'Status',];
|
||||
};
|
||||
|
||||
Email.validationRules = function () {
|
||||
return [
|
||||
['slug', 'Email Type', 'required|is_unique[email.slug]'],
|
||||
['subject', 'Subject', 'required'],
|
||||
['tag', 'Replacement Tags', 'required'],
|
||||
['html', 'Email Body', 'required'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
Email.validationEditRules = function () {
|
||||
return [
|
||||
['slug', 'Email Type', ''],
|
||||
['subject', 'Subject', 'required'],
|
||||
['tag', 'Replacement Tags', ''],
|
||||
['html', 'Email Body', 'required'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ex
|
||||
Email.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'slug', 'subject', 'tag', 'html', 'status', 'created_at', 'updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Email;
|
||||
};
|
||||
Executable
+173
@@ -0,0 +1,173 @@
|
||||
/*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 { 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,
|
||||
width: DataTypes.INTEGER,
|
||||
height: DataTypes.INTEGER,
|
||||
type: DataTypes.INTEGER,
|
||||
status: 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) {
|
||||
data.status = 1;
|
||||
data.refer = 1;
|
||||
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.type_mapping = function (type) {
|
||||
const mapping = { "0": "Server Hosted", "1": "External Link", "2": "S3", "3": "Cloudinary", "4": "File", "5": "External File", "6": "Custom" }
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[type];
|
||||
};
|
||||
|
||||
|
||||
Image.status_mapping = function (status) {
|
||||
const mapping = { "0": "Inactive", "1": "Active" }
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[status];
|
||||
};
|
||||
|
||||
|
||||
Image.allowFields = function () {
|
||||
return ["user_id", 'id', 'url', 'caption', 'width', 'height', 'type', 'status',];
|
||||
};
|
||||
|
||||
Image.labels = function () {
|
||||
return ['ID', 'URL', 'Caption', 'Width', 'Height', 'Image Type', 'Status',];
|
||||
};
|
||||
|
||||
Image.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['url', 'URL', 'required'],
|
||||
['caption', 'Caption', ''],
|
||||
['width', 'Width', ''],
|
||||
['height', 'Height', ''],
|
||||
['type', 'Image Type', ''],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
Image.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['url', 'URL', 'required'],
|
||||
['caption', 'Caption', ''],
|
||||
['width', 'Width', ''],
|
||||
['height', 'Height', ''],
|
||||
['type', 'Image Type', ''],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
Image.get_user_paginated = function (db, ...rest) {
|
||||
return Image.getPaginated(...rest, [{
|
||||
model: db.user,
|
||||
as: "user"
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
Image.get_image_user = (id, db) => {
|
||||
return Image.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||
};
|
||||
|
||||
// ex
|
||||
Image.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id', 'url', 'caption', 'width', 'height', 'type', 'status', 'created_at', 'updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Image;
|
||||
};
|
||||
Executable
+69
@@ -0,0 +1,69 @@
|
||||
'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 { DataTypes } = require('sequelize');
|
||||
const basename = path.basename(__filename);
|
||||
const config = {
|
||||
DB_DATABASE: 'mysql',
|
||||
DB_USERNAME: 'root',
|
||||
DB_PASSWORD: 'root',
|
||||
DB_ADAPTER: 'mysql',
|
||||
DB_NAME: 'day_1',
|
||||
DB_HOSTNAME: 'localhost',
|
||||
DB_PORT: 3306,
|
||||
};
|
||||
|
||||
let db = {};
|
||||
|
||||
let sequelize = new Sequelize(config.DB_DATABASE, config.DB_USERNAME, config.DB_PASSWORD, {
|
||||
dialect: config.DB_ADAPTER,
|
||||
username: config.DB_USERNAME,
|
||||
password: config.DB_PASSWORD,
|
||||
database: config.DB_NAME,
|
||||
host: config.DB_HOSTNAME,
|
||||
port: config.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 = require(path.join(__dirname, file))(sequelize, DataTypes);
|
||||
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;
|
||||
Executable
+152
@@ -0,0 +1,152 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* link Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
;
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require('lodash');
|
||||
const coreModel = require('./../core/models');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Link = sequelize.define(
|
||||
"link",
|
||||
{
|
||||
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
link: DataTypes.STRING,
|
||||
status: DataTypes.INTEGER,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "link",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Link);
|
||||
|
||||
Link._preCreateProcessing = function (data) {
|
||||
data.status = 1;
|
||||
return data;
|
||||
};
|
||||
Link._postCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Link._customCountingConditions = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
Link._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Link.allowFields();
|
||||
allowedFields.push(Link._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Link.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;
|
||||
};
|
||||
|
||||
Link.associate = function (models) {
|
||||
Link.belongsTo(models.user, {
|
||||
foreignKey: "user_id",
|
||||
as: "user",
|
||||
constraints: false,
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
Link.status_mapping = function (status) {
|
||||
const mapping = { "0": "Inactive", "1": "Active" }
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[status];
|
||||
};
|
||||
|
||||
|
||||
Link.allowFields = function () {
|
||||
return ["user_id", 'id', 'link', 'status',];
|
||||
};
|
||||
|
||||
Link.labels = function () {
|
||||
return ['ID', 'Link', 'Status',];
|
||||
};
|
||||
|
||||
Link.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['link', 'Link', 'required'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
Link.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['link', 'Link', 'required'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
Link.get_user_paginated = function (db, ...rest) {
|
||||
return Link.getPaginated(...rest, [{
|
||||
model: db.user,
|
||||
as: "user"
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
Link.get_link_user = (id, db) => {
|
||||
return Link.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||
};
|
||||
|
||||
// ex
|
||||
Link.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id', 'link', 'status', 'created_at', 'updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Link;
|
||||
};
|
||||
Executable
+153
@@ -0,0 +1,153 @@
|
||||
/*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 { 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: { type: DataTypes.STRING, validate: {} },
|
||||
user_agent: { type: DataTypes.STRING, validate: {} },
|
||||
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) {
|
||||
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, ...rest) {
|
||||
return Member_operation.getPaginated(...rest, [{
|
||||
model: db.user,
|
||||
as: "user"
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
Member_operation.get_member_operation_user = (id, db) => {
|
||||
return Member_operation.findByPk(id, { include: [{ model: db.user, 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;
|
||||
};
|
||||
Executable
+152
@@ -0,0 +1,152 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* note Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
;
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require('lodash');
|
||||
const coreModel = require('./../core/models');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Note = sequelize.define(
|
||||
"note",
|
||||
{
|
||||
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
message: DataTypes.STRING,
|
||||
status: DataTypes.INTEGER,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "note",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Note);
|
||||
|
||||
Note._preCreateProcessing = function (data) {
|
||||
data.status = 1;
|
||||
return data;
|
||||
};
|
||||
Note._postCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Note._customCountingConditions = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
Note._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Note.allowFields();
|
||||
allowedFields.push(Note._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
Note.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;
|
||||
};
|
||||
|
||||
Note.associate = function (models) {
|
||||
Note.belongsTo(models.user, {
|
||||
foreignKey: "user_id",
|
||||
as: "user",
|
||||
constraints: false,
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
Note.status_mapping = function (status) {
|
||||
const mapping = { "0": "Inactive", "1": "Active" }
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[status];
|
||||
};
|
||||
|
||||
|
||||
Note.allowFields = function () {
|
||||
return ["user_id", 'id', 'message', 'status',];
|
||||
};
|
||||
|
||||
Note.labels = function () {
|
||||
return ['ID', 'Message', 'Status',];
|
||||
};
|
||||
|
||||
Note.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['message', 'Message', 'required'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
Note.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['message', 'Message', 'required'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
Note.get_user_paginated = function (db, ...rest) {
|
||||
return Note.getPaginated(...rest, [{
|
||||
model: db.user,
|
||||
as: "user"
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
Note.get_note_user = (id, db) => {
|
||||
return Note.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||
};
|
||||
|
||||
// ex
|
||||
Note.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id', 'message', 'status', 'created_at', 'updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Note;
|
||||
};
|
||||
Executable
+158
@@ -0,0 +1,158 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* profile Model
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const moment = require("moment");
|
||||
;
|
||||
const { Op } = require("sequelize");
|
||||
const { intersection } = require('lodash');
|
||||
const coreModel = require('./../core/models');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Profile = sequelize.define(
|
||||
"profile",
|
||||
{
|
||||
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
timezone: DataTypes.STRING,
|
||||
dashboard_code: DataTypes.STRING,
|
||||
code: DataTypes.STRING,
|
||||
status: DataTypes.INTEGER,
|
||||
created_at: DataTypes.DATEONLY,
|
||||
updated_at: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
freezeTableName: true,
|
||||
tableName: "profile",
|
||||
},
|
||||
{
|
||||
underscoredAll: false,
|
||||
underscored: false,
|
||||
}
|
||||
);
|
||||
|
||||
coreModel.call(this, Profile);
|
||||
|
||||
Profile._preCreateProcessing = function (data) {
|
||||
data.status = 1;
|
||||
return data;
|
||||
};
|
||||
Profile._postCreateProcessing = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
Profile._customCountingConditions = function (data) {
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
Profile._filterAllowKeys = function (data) {
|
||||
let cleanData = {};
|
||||
let allowedFields = Profile.allowFields();
|
||||
allowedFields.push(Profile._primaryKey());
|
||||
|
||||
for (const key in data) {
|
||||
if (allowedFields.includes(key)) {
|
||||
cleanData[key] = data[key];
|
||||
}
|
||||
}
|
||||
return cleanData;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
Profile.associate = function (models) {
|
||||
Profile.belongsTo(models.user, {
|
||||
foreignKey: "user_id",
|
||||
as: "profile",
|
||||
constraints: false,
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
Profile.status_mapping = function (status) {
|
||||
const mapping = { "0": "Inactive", "1": "Active" }
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[status];
|
||||
};
|
||||
|
||||
|
||||
Profile.allowFields = function () {
|
||||
return ["user_id", 'id', 'timezone', 'dashboard_code', 'code', 'status',];
|
||||
};
|
||||
|
||||
Profile.labels = function () {
|
||||
return ['ID', 'Timezone', 'Dashboard Code', 'Code', 'Status',];
|
||||
};
|
||||
|
||||
Profile.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['timezone', 'Timezone', 'required'],
|
||||
['dashboard_code', 'Dashboard Code', 'required'],
|
||||
['code', 'Code', ''],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
Profile.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['timezone', 'Timezone', 'required'],
|
||||
['dashboard_code', 'Dashboard Code', 'required'],
|
||||
['code', 'Code', ''],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
Profile.get_user_paginated = function (db, ...rest) {
|
||||
return Profile.getPaginated(...rest, [{
|
||||
model: db.user,
|
||||
as: "profile"
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
Profile.get_profile_user = (id, db) => {
|
||||
return Profile.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||
};
|
||||
|
||||
// ex
|
||||
Profile.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id', 'timezone', 'dashboard_code', 'code', 'status', 'created_at', 'updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Profile;
|
||||
};
|
||||
Executable
+163
@@ -0,0 +1,163 @@
|
||||
/*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 { 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,
|
||||
},
|
||||
referrer_user_id: DataTypes.INTEGER,
|
||||
type: DataTypes.INTEGER,
|
||||
status: 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) {
|
||||
data.status = 1;
|
||||
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.status_mapping = function (status) {
|
||||
const mapping = { "0": "Pending", "1": "Confirmed", "2": "Paid" }
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[status];
|
||||
};
|
||||
|
||||
|
||||
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', 'referrer_user_id', 'type', 'status',];
|
||||
};
|
||||
|
||||
Refer_log.labels = function () {
|
||||
return ['ID', 'Referrer User', 'Type', 'Status',];
|
||||
};
|
||||
|
||||
Refer_log.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['referrer_user_id', 'Referrer User', 'required|integer'],
|
||||
['type', 'Type', 'required|integer'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
Refer_log.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['referrer_user_id', 'Referrer User', ''],
|
||||
['type', 'Type', 'required|integer'],
|
||||
['status', 'Status', ''],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
Refer_log.get_user_paginated = function (db, ...rest) {
|
||||
return Refer_log.getPaginated(...rest, [{
|
||||
model: db.user,
|
||||
as: "user"
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
Refer_log.get_refer_log_user = (id, db) => {
|
||||
return Refer_log.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||
};
|
||||
|
||||
// ex
|
||||
Refer_log.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id', 'referrer_user_id', 'type', 'status', 'created_at', 'updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Refer_log;
|
||||
};
|
||||
Executable
+137
@@ -0,0 +1,137 @@
|
||||
/*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 { 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: { type: DataTypes.STRING, validate: {} },
|
||||
status: DataTypes.INTEGER,
|
||||
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) {
|
||||
data.status = 1;
|
||||
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.status_mapping = function (status) {
|
||||
const mapping = { "0": "Pending", "1": "Confirmed", "2": "Paid" }
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[status];
|
||||
};
|
||||
|
||||
|
||||
Role.allowFields = function () {
|
||||
return ['id', 'name', 'status',];
|
||||
};
|
||||
|
||||
Role.labels = function () {
|
||||
return ['ID', 'Role Name', 'Status',];
|
||||
};
|
||||
|
||||
Role.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['name', 'Role Name', 'required'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
Role.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['name', 'Role Name', 'required'],
|
||||
['status', 'Status', ''],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ex
|
||||
Role.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id', 'name', 'status', 'created_at', 'updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Role;
|
||||
};
|
||||
Executable
+165
@@ -0,0 +1,165 @@
|
||||
/*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 { 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: {
|
||||
type: DataTypes.STRING,
|
||||
unique: true
|
||||
},
|
||||
type: DataTypes.INTEGER,
|
||||
value: DataTypes.TEXT,
|
||||
maintenance: DataTypes.INTEGER,
|
||||
status: 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) {
|
||||
data.status = 1;
|
||||
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.status_mapping = function (status) {
|
||||
const mapping = { "0": "Pending", "1": "Confirmed", "2": "Paid" }
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[status];
|
||||
};
|
||||
|
||||
|
||||
Setting.allowFields = function () {
|
||||
return ['id', 'key', 'type', 'value', 'maintenance', 'status',];
|
||||
};
|
||||
|
||||
Setting.labels = function () {
|
||||
return ['ID', 'Setting Field', 'Setting Type', 'Setting Value', 'Setting Type', 'Status',];
|
||||
};
|
||||
|
||||
Setting.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['key', 'Setting Field', 'required'],
|
||||
['type', 'Setting Type', 'required'],
|
||||
['value', 'Setting Value', 'required'],
|
||||
['maintenance', 'Setting Type', 'required'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
Setting.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['key', 'Setting Field', ''],
|
||||
['type', 'Setting Type', ''],
|
||||
['value', 'Setting Value', 'required'],
|
||||
['maintenance', 'Setting Type', ''],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ex
|
||||
Setting.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id', 'key', 'type', 'value', 'maintenance', 'status', 'created_at', 'updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Setting;
|
||||
};
|
||||
Executable
+135
@@ -0,0 +1,135 @@
|
||||
/*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 { Op } = require("sequelize");
|
||||
const { intersection } = require('lodash');
|
||||
const coreModel = require('./../core/models');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Sms = sequelize.define(
|
||||
"sms",
|
||||
{
|
||||
slug: { type: DataTypes.STRING, validate: {} },
|
||||
tag: DataTypes.TEXT,
|
||||
content: DataTypes.TEXT,
|
||||
status: DataTypes.INTEGER,
|
||||
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) {
|
||||
data.status = 1;
|
||||
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.status_mapping = function (status) {
|
||||
const mapping = { "0": "Inactive", "1": "Active" }
|
||||
|
||||
if (arguments.length === 0) return mapping;
|
||||
else return mapping[status];
|
||||
};
|
||||
|
||||
|
||||
Sms.allowFields = function () {
|
||||
return ['slug', 'tag', 'content', 'status',];
|
||||
};
|
||||
|
||||
Sms.labels = function () {
|
||||
return ['SMS Slug', 'Replacement Tags', 'SMS Body', 'Status',];
|
||||
};
|
||||
|
||||
Sms.validationRules = function () {
|
||||
return [
|
||||
['slug', 'SMS Slug', 'required|is_unique[sms.slug]'],
|
||||
['tag', 'Replacement Tags', 'required'],
|
||||
['content', 'SMS Body', 'required'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
Sms.validationEditRules = function () {
|
||||
return [
|
||||
['slug', 'SMS Slug', ''],
|
||||
['tag', 'Replacement Tags', ''],
|
||||
['content', 'SMS Body', 'required'],
|
||||
['status', 'Status', 'required|integer'],
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ex
|
||||
Sms.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'slug', 'tag', 'content', 'status', 'created_at', 'updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Sms;
|
||||
};
|
||||
Executable
+174
@@ -0,0 +1,174 @@
|
||||
/*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 { 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,
|
||||
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) {
|
||||
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 ["user_id", 'id', 'token', 'data', 'type', 'ttl', 'issue_at', 'expire_at', 'status',];
|
||||
};
|
||||
|
||||
Token.labels = function () {
|
||||
return ['ID', 'Token', 'Data', 'Token Type', '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'],
|
||||
['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'],
|
||||
['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, ...rest) {
|
||||
return Token.getPaginated(...rest, [{
|
||||
model: db.user,
|
||||
as: "user"
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
Token.get_token_user = (id, db) => {
|
||||
return Token.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||
};
|
||||
|
||||
// ex
|
||||
Token.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id', 'token', 'data', 'type', 'ttl', 'issue_at', 'expire_at', 'status', 'created_at', 'updated_at',
|
||||
],
|
||||
Object.keys(fields),
|
||||
);
|
||||
} else return [];
|
||||
};
|
||||
|
||||
|
||||
return Token;
|
||||
};
|
||||
Executable
+482
@@ -0,0 +1,482 @@
|
||||
/*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 { 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,
|
||||
},
|
||||
status: DataTypes.INTEGER,
|
||||
first_name: DataTypes.STRING,
|
||||
last_name: DataTypes.STRING,
|
||||
phone: DataTypes.STRING,
|
||||
image: DataTypes.TEXT,
|
||||
image_id: DataTypes.INTEGER,
|
||||
refer: DataTypes.STRING,
|
||||
profile_id: DataTypes.INTEGER,
|
||||
role_id: DataTypes.INTEGER,
|
||||
stripe_uid: DataTypes.STRING,
|
||||
paypal_uid: DataTypes.STRING,
|
||||
font_color: DataTypes.STRING,
|
||||
time_zone: DataTypes.STRING,
|
||||
time_format: DataTypes.INTEGER,
|
||||
clock_format: DataTypes.INTEGER,
|
||||
date_format: DataTypes.INTEGER,
|
||||
location: DataTypes.STRING,
|
||||
lat: DataTypes.FLOAT,
|
||||
lng: DataTypes.FLOAT,
|
||||
expire_at: DataTypes.DATEONLY,
|
||||
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) {
|
||||
data.image = 'https://i.imgur.com/AzJ7DRw.png'
|
||||
data.refer = Math.round(Math.random() * 1000000000000, 0)
|
||||
data.status = 1
|
||||
data.verify = 0
|
||||
data.font_color = '#ffffff'
|
||||
data.time_zone = 'UTC'
|
||||
data.time_format = 1
|
||||
data.clock_format = 1
|
||||
data.date_format = 1
|
||||
data.location = ''
|
||||
if (!data.profile_id) {
|
||||
data.profile_id = 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.hasMany(models.refer_log, {
|
||||
foreignKey: 'user_id',
|
||||
constraints: false,
|
||||
})
|
||||
User.hasOne(models.credential, {
|
||||
foreignKey: 'user_id',
|
||||
constraints: false,
|
||||
})
|
||||
User.hasMany(models.token, {
|
||||
foreignKey: 'user_id',
|
||||
constraints: false,
|
||||
})
|
||||
User.hasOne(models.code, {
|
||||
foreignKey: 'user_id',
|
||||
constraints: false,
|
||||
})
|
||||
User.hasMany(models.admin_operation, {
|
||||
foreignKey: 'user_id',
|
||||
constraints: false,
|
||||
})
|
||||
User.hasMany(models.member_operation, {
|
||||
foreignKey: 'user_id',
|
||||
constraints: false,
|
||||
})
|
||||
User.hasMany(models.image, {
|
||||
foreignKey: 'user_id',
|
||||
constraints: false,
|
||||
})
|
||||
User.hasMany(models.note, {
|
||||
foreignKey: 'user_id',
|
||||
constraints: false,
|
||||
})
|
||||
User.hasMany(models.calendar, {
|
||||
foreignKey: 'user_id',
|
||||
constraints: false,
|
||||
})
|
||||
User.hasOne(models.profile, {
|
||||
foreignKey: 'user_id',
|
||||
constraints: false,
|
||||
})
|
||||
User.hasMany(models.link, {
|
||||
foreignKey: 'user_id',
|
||||
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.time_format_mapping = function (time_format) {
|
||||
const mapping = { 1: 'AM/PM', 2: '24 hours' }
|
||||
|
||||
if (arguments.length === 0) return mapping
|
||||
else return mapping[time_format]
|
||||
}
|
||||
|
||||
User.clock_format_mapping = function (clock_format) {
|
||||
const mapping = { 1: 'Digital', 2: 'Analog' }
|
||||
|
||||
if (arguments.length === 0) return mapping
|
||||
else return mapping[clock_format]
|
||||
}
|
||||
|
||||
User.date_format_mapping = function (date_format) {
|
||||
const mapping = {
|
||||
1: 'Standard (dd/mm/yyyy)',
|
||||
2: 'Locale (Wed, April 1, 2021)',
|
||||
}
|
||||
|
||||
if (arguments.length === 0) return mapping
|
||||
else return mapping[date_format]
|
||||
}
|
||||
|
||||
User.allowFields = function () {
|
||||
return [
|
||||
'id',
|
||||
'status',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'phone',
|
||||
'image',
|
||||
'image_id',
|
||||
'refer',
|
||||
'profile_id',
|
||||
'role_id',
|
||||
'stripe_uid',
|
||||
'paypal_uid',
|
||||
'font_color',
|
||||
'time_zone',
|
||||
'time_format',
|
||||
'clock_format',
|
||||
'date_format',
|
||||
'location',
|
||||
'lat',
|
||||
'lng',
|
||||
'expire_at',
|
||||
]
|
||||
}
|
||||
|
||||
User.labels = function () {
|
||||
return [
|
||||
'ID',
|
||||
'Status',
|
||||
'First Name',
|
||||
'Last Name',
|
||||
'Phone #',
|
||||
'Image',
|
||||
'Image ID',
|
||||
'Refer Code',
|
||||
'Profile ID',
|
||||
'Role ID',
|
||||
'Stripe ID',
|
||||
'PayPal ID',
|
||||
'Font Color',
|
||||
'Timezone',
|
||||
'Time Format',
|
||||
'Clock Format',
|
||||
'Date Format',
|
||||
'Location',
|
||||
'Latitude',
|
||||
'Longitude',
|
||||
'Expire At',
|
||||
]
|
||||
}
|
||||
|
||||
User.validationRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['status', 'Status', ''],
|
||||
['first_name', 'First Name', 'required'],
|
||||
['last_name', 'Last Name', 'required'],
|
||||
['phone', 'Phone #', ''],
|
||||
['image', 'Image', ''],
|
||||
['image_id', 'Image ID', ''],
|
||||
['refer', 'Refer Code', ''],
|
||||
['profile_id', 'Profile ID', ''],
|
||||
['role_id', 'Role ID', ''],
|
||||
['stripe_uid', 'Stripe ID', ''],
|
||||
['paypal_uid', 'PayPal ID', ''],
|
||||
['font_color', 'Font Color', ''],
|
||||
['time_zone', 'Timezone', 'required'],
|
||||
['time_format', 'Time Format', 'required|integer'],
|
||||
['clock_format', 'Clock Format', 'required|integer'],
|
||||
['date_format', 'Date Format', 'required|integer'],
|
||||
['location', 'Location', ''],
|
||||
['lat', 'Latitude', 'required|integer'],
|
||||
['lng', 'Longitude', ''],
|
||||
['expire_at', 'Expire At', ''],
|
||||
]
|
||||
}
|
||||
|
||||
User.validationEditRules = function () {
|
||||
return [
|
||||
['id', 'ID', ''],
|
||||
['status', 'Status', ''],
|
||||
['first_name', 'First Name', ''],
|
||||
['last_name', 'Last Name', ''],
|
||||
['phone', 'Phone #', ''],
|
||||
['image', 'Image', ''],
|
||||
['image_id', 'Image ID', ''],
|
||||
['refer', 'Refer Code', ''],
|
||||
['profile_id', 'Profile ID', ''],
|
||||
['role_id', 'Role ID', ''],
|
||||
['stripe_uid', 'Stripe ID', ''],
|
||||
['paypal_uid', 'PayPal ID', ''],
|
||||
['font_color', 'Font Color', ''],
|
||||
['time_zone', 'Timezone', 'required'],
|
||||
['time_format', 'Time Format', 'required|integer'],
|
||||
['clock_format', 'Clock Format', 'required|integer'],
|
||||
['date_format', 'Date Format', 'required|integer'],
|
||||
['location', 'Location', ''],
|
||||
['lat', 'Latitude', ''],
|
||||
['lng', 'Longitude', ''],
|
||||
['expire_at', 'Expire At', ''],
|
||||
]
|
||||
}
|
||||
|
||||
User.get_refer_log_paginated = function (db, ...rest) {
|
||||
return User.getPaginated(...rest, [
|
||||
{
|
||||
model: db.refer_log,
|
||||
as: 'refer_log',
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
User.get_credential_paginated = function (db, ...rest) {
|
||||
return User.getPaginated(...rest, [
|
||||
{
|
||||
model: db.credential,
|
||||
as: 'credential',
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
User.get_token_paginated = function (db, ...rest) {
|
||||
return User.getPaginated(...rest, [
|
||||
{
|
||||
model: db.token,
|
||||
as: 'token',
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
User.get_code_paginated = function (db, ...rest) {
|
||||
return User.getPaginated(...rest, [
|
||||
{
|
||||
model: db.code,
|
||||
as: 'code',
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
User.get_admin_operation_paginated = function (db, ...rest) {
|
||||
return User.getPaginated(...rest, [
|
||||
{
|
||||
model: db.admin_operation,
|
||||
as: 'admin_operation',
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
User.get_member_operation_paginated = function (db, ...rest) {
|
||||
return User.getPaginated(...rest, [
|
||||
{
|
||||
model: db.member_operation,
|
||||
as: 'member_operation',
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
User.get_image_paginated = function (db, ...rest) {
|
||||
return User.getPaginated(...rest, [
|
||||
{
|
||||
model: db.image,
|
||||
as: 'image',
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
User.get_note_paginated = function (db, ...rest) {
|
||||
return User.getPaginated(...rest, [
|
||||
{
|
||||
model: db.note,
|
||||
as: 'note',
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
User.get_calendar_paginated = function (db, ...rest) {
|
||||
return User.getPaginated(...rest, [
|
||||
{
|
||||
model: db.calendar,
|
||||
as: 'calendar',
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
User.get_profile_paginated = function (db, ...rest) {
|
||||
return User.getPaginated(...rest, [
|
||||
{
|
||||
model: db.profile,
|
||||
as: 'profile',
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
User.get_link_paginated = function (db, ...rest) {
|
||||
return User.getPaginated(...rest, [
|
||||
{
|
||||
model: db.link,
|
||||
as: 'link',
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
User.get_user_refer_log = (id, db) => {
|
||||
return User.findByPk(id, {
|
||||
include: [{ model: db.refer_log, as: 'refer_log' }],
|
||||
})
|
||||
}
|
||||
User.get_user_credential = (id, db) => {
|
||||
return User.findByPk(id, {
|
||||
include: [{ model: db.credential, as: 'credential' }],
|
||||
})
|
||||
}
|
||||
User.get_user_token = (id, db) => {
|
||||
return User.findByPk(id, { include: [{ model: db.token, as: 'token' }] })
|
||||
}
|
||||
User.get_user_code = (id, db) => {
|
||||
return User.findByPk(id, { include: [{ model: db.code, as: 'code' }] })
|
||||
}
|
||||
User.get_user_admin_operation = (id, db) => {
|
||||
return User.findByPk(id, {
|
||||
include: [{ model: db.admin_operation, as: 'admin_operation' }],
|
||||
})
|
||||
}
|
||||
User.get_user_member_operation = (id, db) => {
|
||||
return User.findByPk(id, {
|
||||
include: [{ model: db.member_operation, as: 'member_operation' }],
|
||||
})
|
||||
}
|
||||
User.get_user_image = (id, db) => {
|
||||
return User.findByPk(id, { include: [{ model: db.image, as: 'image' }] })
|
||||
}
|
||||
User.get_user_note = (id, db) => {
|
||||
return User.findByPk(id, { include: [{ model: db.note, as: 'note' }] })
|
||||
}
|
||||
User.get_user_calendar = (id, db) => {
|
||||
return User.findByPk(id, {
|
||||
include: [{ model: db.calendar, as: 'calendar' }],
|
||||
})
|
||||
}
|
||||
User.get_user_profile = (id, db) => {
|
||||
return User.findByPk(id, {
|
||||
include: [{ model: db.profile, as: 'profile' }],
|
||||
})
|
||||
}
|
||||
User.get_user_link = (id, db) => {
|
||||
return User.findByPk(id, { include: [{ model: db.link, as: 'link' }] })
|
||||
}
|
||||
|
||||
// ex
|
||||
User.intersection = function (fields) {
|
||||
if (fields) {
|
||||
return intersection(
|
||||
[
|
||||
'id',
|
||||
'status',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'phone',
|
||||
'image',
|
||||
'image_id',
|
||||
'refer',
|
||||
'profile_id',
|
||||
'role_id',
|
||||
'stripe_uid',
|
||||
'paypal_uid',
|
||||
'font_color',
|
||||
'time_zone',
|
||||
'time_format',
|
||||
'clock_format',
|
||||
'date_format',
|
||||
'location',
|
||||
'lat',
|
||||
'lng',
|
||||
'expire_at',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
],
|
||||
Object.keys(fields)
|
||||
)
|
||||
} else return []
|
||||
}
|
||||
|
||||
return User
|
||||
}
|
||||
Reference in New Issue
Block a user