- Aggiunto Filtri
- Finder
This commit is contained in:
@@ -1,18 +1,24 @@
|
|||||||
|
|
||||||
class CParamsQuery {
|
class CParamsQuery {
|
||||||
constructor(params) {
|
constructor(params) {
|
||||||
|
this.table = params.table;
|
||||||
this.startRow = params.startRow;
|
this.startRow = params.startRow;
|
||||||
this.endRow = params.endRow;
|
this.endRow = params.endRow;
|
||||||
// this.count = params.count;
|
|
||||||
this.filter = params.filter;
|
this.filter = params.filter;
|
||||||
|
this.filterand = params.filterand;
|
||||||
|
this.filtersearch = params.filtersearch;
|
||||||
|
this.filtercustom = params.filtercustom;
|
||||||
this.sortBy = params.sortBy;
|
this.sortBy = params.sortBy;
|
||||||
this.descending = params.descending;
|
this.descending = params.descending;
|
||||||
|
this.userId = params.userId;
|
||||||
|
this.codeId = params.codeId;
|
||||||
this.lk_tab = params.lk_tab;
|
this.lk_tab = params.lk_tab;
|
||||||
this.af_objId_tab = params.af_objId_tab;
|
this.af_objId_tab = params.af_objId_tab;
|
||||||
this.lk_LF = params.lk_LF;
|
this.lk_LF = params.lk_LF;
|
||||||
this.lk_FF = params.lk_FF;
|
this.lk_FF = params.lk_FF;
|
||||||
this.lk_as = params.lk_as;
|
this.lk_as = params.lk_as;
|
||||||
this.lk_proj = params.lk_proj;
|
this.lk_proj = params.lk_proj;
|
||||||
|
this.lk_col2 = params.lk_col2;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,11 +99,40 @@ MySkillSchema.statics.findAllIdApp = function(idapp) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
MySkillSchema.statics.getFieldsForSearch = function() {
|
MySkillSchema.statics.getFieldsForSearch = function() {
|
||||||
return [{field: 'idSkill', type: tools.FieldType.Number}];
|
return [{field: 'idSkill', type: tools.FieldType.Number}
|
||||||
|
,{field: 'note', type: tools.FieldType.String}
|
||||||
|
,{field: 'subTitle', type: tools.FieldType.String}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
MySkillSchema.statics.executeQueryTable = function(idapp, params) {
|
MySkillSchema.statics.executeQueryTable = function(idapp, params) {
|
||||||
params.fieldsearch = this.getFieldsForSearch();
|
params.fieldsearch = this.getFieldsForSearch();
|
||||||
|
|
||||||
|
const otherparams = {
|
||||||
|
lk_tab: 'users',
|
||||||
|
lk_LF: 'userId',
|
||||||
|
lk_FF: '_id',
|
||||||
|
lk_as: 'user',
|
||||||
|
af_objId_tab: 'myId',
|
||||||
|
lk_proj: {
|
||||||
|
idSkill: 1,
|
||||||
|
idStatusSkill: 1,
|
||||||
|
idCity: 1,
|
||||||
|
numLevel: 1,
|
||||||
|
photos: 1,
|
||||||
|
note: 1,
|
||||||
|
subTitle: 1,
|
||||||
|
date_created: 1,
|
||||||
|
date_updated: 1,
|
||||||
|
userId: 1,
|
||||||
|
username: 1,
|
||||||
|
name: 1,
|
||||||
|
surname: 1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
params = { ...params, ...otherparams };
|
||||||
|
|
||||||
return tools.executeQueryTable(this, idapp, params);
|
return tools.executeQueryTable(this, idapp, params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -319,9 +319,9 @@ router.post('/settable', authenticate, (req, res) => {
|
|||||||
mydata.idapp = req.user.idapp;
|
mydata.idapp = req.user.idapp;
|
||||||
|
|
||||||
if (shared_consts.TABLES_ID_NUMBER.includes(params.table)) {
|
if (shared_consts.TABLES_ID_NUMBER.includes(params.table)) {
|
||||||
if (mydata['_id'] === undefined) {
|
//if (mydata['_id'] === undefined) {
|
||||||
mydata._id = 1;
|
// mydata._id = 1;
|
||||||
}
|
//}
|
||||||
} else if (params.table === 'hours') {
|
} else if (params.table === 'hours') {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1106,9 +1106,7 @@ module.exports = {
|
|||||||
return (myapp) ? myapp.telegram_key : '';
|
return (myapp) ? myapp.telegram_key : '';
|
||||||
},
|
},
|
||||||
|
|
||||||
getQueryTable(idapp, params) {
|
getQueryTable: function(idapp, params) {
|
||||||
// console.log('idapp', idapp);
|
|
||||||
// console.table(params);
|
|
||||||
|
|
||||||
if (typeof params.startRow !== 'number') {
|
if (typeof params.startRow !== 'number') {
|
||||||
throw new Error('startRow must be number');
|
throw new Error('startRow must be number');
|
||||||
@@ -1257,6 +1255,14 @@ module.exports = {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (params.filtercustom) {
|
||||||
|
filtriadded.push(...params.filtercustom);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.filtersearch) {
|
||||||
|
filtriadded.push(...params.filtersearch);
|
||||||
|
}
|
||||||
|
|
||||||
if (filtriadded.length > 0)
|
if (filtriadded.length > 0)
|
||||||
query.push({$match: {$and: filtriadded}});
|
query.push({$match: {$and: filtriadded}});
|
||||||
|
|
||||||
@@ -1340,14 +1346,18 @@ module.exports = {
|
|||||||
async executeQueryTable(mythistable, idapp, params) {
|
async executeQueryTable(mythistable, idapp, params) {
|
||||||
let query = this.getQueryTable(idapp, params);
|
let query = this.getQueryTable(idapp, params);
|
||||||
|
|
||||||
const [ris] = await mythistable.aggregate(query);
|
try {
|
||||||
|
const [ris] = await mythistable.aggregate(query);
|
||||||
|
|
||||||
if (ris) {
|
if (ris) {
|
||||||
// console.table(ris.rows);
|
// console.table(ris.rows);
|
||||||
// console.log('ROW ', ris.count);
|
// console.log('ROW ', ris.count);
|
||||||
return ({count: ris.count, rows: ris.rows});
|
return ({count: ris.count, rows: ris.rows});
|
||||||
} else {
|
} else {
|
||||||
return ({count: 0, rows: []});
|
return ({count: 0, rows: []});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log('error', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ module.exports = {
|
|||||||
FILTER_TO_MAKE_MEMBERSHIP_CARD: 524288,
|
FILTER_TO_MAKE_MEMBERSHIP_CARD: 524288,
|
||||||
FILTER_MEMBERSHIP_CARD_OK: 1048576,
|
FILTER_MEMBERSHIP_CARD_OK: 1048576,
|
||||||
|
|
||||||
|
FILTER_MYSKILL_SKILL: 1,
|
||||||
|
|
||||||
REPORT_FILT_RESP: 1,
|
REPORT_FILT_RESP: 1,
|
||||||
REPORT_FILT_ATTIVITA: 2,
|
REPORT_FILT_ATTIVITA: 2,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user