AITools prime cose
This commit is contained in:
61
src/server/models/catai.js
Executable file
61
src/server/models/catai.js
Executable file
@@ -0,0 +1,61 @@
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const CatAISchema = new Schema({
|
||||
_id: {
|
||||
type: Number,
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
},
|
||||
img: {
|
||||
type: String,
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
CatAISchema.statics.getAllCategories = function (callback) {
|
||||
CatAI.find(callback)
|
||||
}
|
||||
|
||||
CatAISchema.statics.getCatAIById = function (id, callback) {
|
||||
CatAI.findById(id, callback);
|
||||
}
|
||||
|
||||
CatAISchema.statics.getFieldsForSearch = function () {
|
||||
return [{ field: 'name', type: tools.FieldType.string }]
|
||||
};
|
||||
|
||||
CatAISchema.statics.executeQueryTable = function (idapp, params) {
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
CatAISchema.statics.findAllIdApp = async function (idapp) {
|
||||
const myfind = {};
|
||||
|
||||
return await CatAI.find(myfind).sort({ name: 1 });
|
||||
};
|
||||
|
||||
const CatAI = mongoose.model('CatAI', CatAISchema);
|
||||
|
||||
CatAI.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = CatAI;
|
||||
59
src/server/models/inventariogm.js
Executable file
59
src/server/models/inventariogm.js
Executable file
@@ -0,0 +1,59 @@
|
||||
mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
// A1P
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const inventariogmSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
var Inventariogm = module.exports = mongoose.model('Inventariogm', inventariogmSchema);
|
||||
|
||||
inventariogmSchema.index({ idapp: 1 });
|
||||
|
||||
module.exports.getFieldsForSearch = function () {
|
||||
return [
|
||||
{ field: 'name', type: tools.FieldType.string },
|
||||
{ field: 'description', type: tools.FieldType.string },
|
||||
]
|
||||
};
|
||||
|
||||
module.exports.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
module.exports.getInventariogmByCode = function (idapp, code) {
|
||||
return Inventariogm.findAllIdApp(idapp, code);
|
||||
}
|
||||
|
||||
module.exports.getInventariogmById = async function (id) {
|
||||
const arrris = await Inventariogm.findAllIdApp('', '', id);
|
||||
return arrris && arrris.length > 0 ? arrris[0] : null
|
||||
}
|
||||
|
||||
module.exports.findAllIdApp = async function (idapp) {
|
||||
const Inventariogm = this;
|
||||
|
||||
const myfind = { idapp, deleted: false };
|
||||
|
||||
return await Inventariogm.find(myfind, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
};
|
||||
86
src/server/models/queryai.js
Executable file
86
src/server/models/queryai.js
Executable file
@@ -0,0 +1,86 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
// const CatAI = require('./catai');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const QueryAISchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
catAI: { type: Schema.Types.ObjectId, ref: 'CatAI' },
|
||||
query: {
|
||||
type: String,
|
||||
},
|
||||
ask: [
|
||||
{
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
value: {
|
||||
type: Number,
|
||||
},
|
||||
}
|
||||
],
|
||||
buttons: [
|
||||
{
|
||||
type: String, //ButtonCodeAction
|
||||
},
|
||||
],
|
||||
output_type: {
|
||||
type: String,
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
},
|
||||
img: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
QueryAISchema.statics.findAllIdApp = async function (idapp) {
|
||||
const QueryAI = this;
|
||||
|
||||
const query = [
|
||||
{ $sort: { descr: 1 } }
|
||||
];
|
||||
|
||||
return await QueryAI
|
||||
.aggregate(query)
|
||||
.then((arrrec) => {
|
||||
return arrrec
|
||||
})
|
||||
|
||||
};
|
||||
|
||||
QueryAISchema.statics.getFieldsForSearch = function () {
|
||||
return [{ field: 'descr', type: tools.FieldType.string }]
|
||||
};
|
||||
|
||||
QueryAISchema.statics.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, 0, params);
|
||||
};
|
||||
|
||||
|
||||
const QueryAI = mongoose.model('QueryAI', QueryAISchema);
|
||||
|
||||
QueryAI.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { QueryAI };
|
||||
@@ -132,6 +132,7 @@ const SiteSchema = new Schema({
|
||||
showConnected: { type: Boolean, default: false },
|
||||
bookingEvents: { type: Boolean, default: false },
|
||||
enableEcommerce: { type: Boolean, default: false },
|
||||
enableAI: { type: Boolean, default: false },
|
||||
enableGroups: { type: Boolean, default: false },
|
||||
enableCircuits: { type: Boolean, default: false },
|
||||
enableProj: { type: Boolean, default: false },
|
||||
|
||||
Reference in New Issue
Block a user