new version Visualizzazione Service
This commit is contained in:
@@ -15,7 +15,10 @@ mongoose.plugin(schema => {
|
|||||||
|
|
||||||
const MyBachecaSchema = new Schema({
|
const MyBachecaSchema = new Schema({
|
||||||
_id: {
|
_id: {
|
||||||
type: Number,
|
type: String,
|
||||||
|
default: function () {
|
||||||
|
return new ObjectID().toString();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
idapp: {
|
idapp: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -88,17 +91,6 @@ const MyBachecaSchema = new Schema({
|
|||||||
|
|
||||||
MyBachecaSchema.pre('save', async function (next) {
|
MyBachecaSchema.pre('save', async function (next) {
|
||||||
if (this.isNew) {
|
if (this.isNew) {
|
||||||
const myrec = await MyBacheca.findOne().limit(1).sort({ _id: -1 });
|
|
||||||
if (!!myrec) {
|
|
||||||
if (myrec._doc._id === 0)
|
|
||||||
this._id = 1;
|
|
||||||
else
|
|
||||||
this._id = myrec._doc._id + 1;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this._id = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.date_created = new Date();
|
this.date_created = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,6 +163,8 @@ MyBachecaSchema.statics.executeQueryTable = function (idapp, params, user) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
|
'profile.username_telegram': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
date_report: 1,
|
date_report: 1,
|
||||||
username_who_report: 1,
|
username_who_report: 1,
|
||||||
@@ -186,13 +180,21 @@ MyBachecaSchema.statics.executeQueryTable = function (idapp, params, user) {
|
|||||||
MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
||||||
const MyBacheca = this;
|
const MyBacheca = this;
|
||||||
|
|
||||||
|
let myparsid = {
|
||||||
|
$or: [
|
||||||
|
{
|
||||||
|
'_id': parseInt(idGood)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'_id': idGood,
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
const query = [
|
const query = [
|
||||||
{
|
{
|
||||||
'$match': {
|
'$match': {
|
||||||
'$and': [
|
'$and': [
|
||||||
{
|
myparsid,
|
||||||
'_id': parseInt(id),
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -268,6 +270,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -326,6 +329,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -384,6 +388,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -442,6 +447,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -500,6 +506,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = 'F';
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const {ObjectID} = require('mongodb');
|
const { ObjectID } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
@@ -15,13 +15,13 @@ mongoose.plugin(schema => {
|
|||||||
|
|
||||||
const MyGoodSchema = new Schema({
|
const MyGoodSchema = new Schema({
|
||||||
_id: {
|
_id: {
|
||||||
type: Number,
|
type: String,
|
||||||
},
|
},
|
||||||
idapp: {
|
idapp: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
userId: {type: Schema.Types.ObjectId, ref: 'User'},
|
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||||
idSectorGood: {
|
idSectorGood: {
|
||||||
type: Number,
|
type: Number,
|
||||||
},
|
},
|
||||||
@@ -87,9 +87,9 @@ const MyGoodSchema = new Schema({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
MyGoodSchema.pre('save', async function(next) {
|
MyGoodSchema.pre('save', async function (next) {
|
||||||
if (this.isNew) {
|
if (this.isNew) {
|
||||||
const myrec = await MyGood.findOne().limit(1).sort({_id: -1});
|
const myrec = await MyGood.findOne().limit(1).sort({ _id: -1 });
|
||||||
if (!!myrec) {
|
if (!!myrec) {
|
||||||
if (myrec._doc._id === 0)
|
if (myrec._doc._id === 0)
|
||||||
this._id = 1;
|
this._id = 1;
|
||||||
@@ -106,12 +106,12 @@ MyGoodSchema.pre('save', async function(next) {
|
|||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
MyGoodSchema.statics.findAllIdApp = async function(idapp) {
|
MyGoodSchema.statics.findAllIdApp = async function (idapp) {
|
||||||
const MyGood = this;
|
const MyGood = this;
|
||||||
|
|
||||||
const query = [
|
const query = [
|
||||||
{$match: {idapp}},
|
{ $match: { idapp } },
|
||||||
{$sort: {descr: 1}},
|
{ $sort: { descr: 1 } },
|
||||||
];
|
];
|
||||||
|
|
||||||
return await MyGood.aggregate(query).then((arrrec) => {
|
return await MyGood.aggregate(query).then((arrrec) => {
|
||||||
@@ -120,21 +120,21 @@ MyGoodSchema.statics.findAllIdApp = async function(idapp) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
MyGoodSchema.statics.getFieldsForSearch = function() {
|
MyGoodSchema.statics.getFieldsForSearch = function () {
|
||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
MyGoodSchema.statics.getFieldsLastForSearch = function() {
|
MyGoodSchema.statics.getFieldsLastForSearch = function () {
|
||||||
return [
|
return [
|
||||||
{field: 'note', type: tools.FieldType.string},
|
{ field: 'note', type: tools.FieldType.string },
|
||||||
{field: 'descr', type: tools.FieldType.string},
|
{ field: 'descr', type: tools.FieldType.string },
|
||||||
{field: 'recGood.descr', type: tools.FieldType.string},
|
{ field: 'recGood.descr', type: tools.FieldType.string },
|
||||||
{field: 'MyGood.descr', type: tools.FieldType.string},
|
{ field: 'MyGood.descr', type: tools.FieldType.string },
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
MyGoodSchema.statics.executeQueryTable = function(idapp, params, user) {
|
MyGoodSchema.statics.executeQueryTable = function (idapp, params, user) {
|
||||||
params.fieldsearch = this.getFieldsForSearch();
|
params.fieldsearch = this.getFieldsForSearch();
|
||||||
params.fieldsearch_last = this.getFieldsLastForSearch();
|
params.fieldsearch_last = this.getFieldsLastForSearch();
|
||||||
|
|
||||||
@@ -151,6 +151,7 @@ MyGoodSchema.statics.executeQueryTable = function(idapp, params, user) {
|
|||||||
MyGood: 1,
|
MyGood: 1,
|
||||||
idStatusGood: 1,
|
idStatusGood: 1,
|
||||||
idContribType: 1,
|
idContribType: 1,
|
||||||
|
'profile.username_telegram': 1,
|
||||||
idCity: 1,
|
idCity: 1,
|
||||||
pub_to_share: 1,
|
pub_to_share: 1,
|
||||||
numLevel: 1,
|
numLevel: 1,
|
||||||
@@ -172,26 +173,35 @@ MyGoodSchema.statics.executeQueryTable = function(idapp, params, user) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
params = {...params, ...otherparams};
|
params = { ...params, ...otherparams };
|
||||||
|
|
||||||
return tools.executeQueryTable(this, idapp, params, user);
|
return tools.executeQueryTable(this, idapp, params, user);
|
||||||
};
|
};
|
||||||
|
|
||||||
MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
|
||||||
const MyGood = this;
|
const MyGood = this;
|
||||||
|
|
||||||
|
let myparsid = {
|
||||||
|
$or: [
|
||||||
|
{
|
||||||
|
'_id': parseInt(idGood)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'_id': idGood,
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
const query = [
|
const query = [
|
||||||
{
|
{
|
||||||
'$match': {
|
'$match': {
|
||||||
'$and': [
|
'$and': [
|
||||||
{
|
myparsid,
|
||||||
'_id': parseInt(idGood),
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -266,6 +276,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -323,6 +334,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -381,6 +393,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -438,6 +451,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -495,6 +509,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -505,7 +520,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
MyGoodSchema.statics.getCompleteRecord = function(idapp, id) {
|
MyGoodSchema.statics.getCompleteRecord = function (idapp, id) {
|
||||||
const MyGood = this;
|
const MyGood = this;
|
||||||
|
|
||||||
return MyGood.getMyRecById(idapp, id);
|
return MyGood.getMyRecById(idapp, id);
|
||||||
@@ -515,4 +530,4 @@ MyGoodSchema.statics.getCompleteRecord = function(idapp, id) {
|
|||||||
|
|
||||||
const MyGood = mongoose.model('MyGood', MyGoodSchema);
|
const MyGood = mongoose.model('MyGood', MyGoodSchema);
|
||||||
|
|
||||||
module.exports = {MyGood};
|
module.exports = { MyGood };
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ mongoose.plugin(schema => {
|
|||||||
|
|
||||||
const MyGroupSchema = new Schema({
|
const MyGroupSchema = new Schema({
|
||||||
_id: {
|
_id: {
|
||||||
type: Number,
|
type: String,
|
||||||
},
|
},
|
||||||
idapp: {
|
idapp: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ mongoose.plugin(schema => {
|
|||||||
|
|
||||||
const MyHospSchema = new Schema({
|
const MyHospSchema = new Schema({
|
||||||
_id: {
|
_id: {
|
||||||
type: Number,
|
type: String,
|
||||||
},
|
},
|
||||||
idapp: {
|
idapp: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -172,6 +172,7 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params, user) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
'mycities': 1,
|
'mycities': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
@@ -186,13 +187,27 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params, user) {
|
|||||||
MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
||||||
const MyHosp = this;
|
const MyHosp = this;
|
||||||
|
|
||||||
|
let myparsid = {
|
||||||
|
$or: [
|
||||||
|
{
|
||||||
|
'_id': parseInt(idGood)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'_id': idGood,
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
|
if (tools.isNumber(id)) {
|
||||||
|
myparsid = {'_id': parseInt(id)};
|
||||||
|
} else {
|
||||||
|
myparsid = {'_id': id};
|
||||||
|
}
|
||||||
|
|
||||||
const query = [
|
const query = [
|
||||||
{
|
{
|
||||||
'$match': {
|
'$match': {
|
||||||
'$and': [
|
'$and': [
|
||||||
{
|
myparsid,
|
||||||
'_id': parseInt(id),
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -263,6 +278,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -316,6 +332,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -369,6 +386,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -422,6 +440,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -457,6 +476,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
preferences: 1,
|
preferences: 1,
|
||||||
photos: 1,
|
photos: 1,
|
||||||
idContribType: 1,
|
idContribType: 1,
|
||||||
|
'profile.username_telegram': 1,
|
||||||
idCity: 1,
|
idCity: 1,
|
||||||
pub_to_share: 1,
|
pub_to_share: 1,
|
||||||
note: 1,
|
note: 1,
|
||||||
@@ -475,6 +495,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ mongoose.plugin(schema => {
|
|||||||
|
|
||||||
const MySkillSchema = new Schema({
|
const MySkillSchema = new Schema({
|
||||||
_id: {
|
_id: {
|
||||||
type: Number,
|
type: String,
|
||||||
|
default: function () {
|
||||||
|
return new ObjectID().toString();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
idapp: {
|
idapp: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -92,17 +95,6 @@ const MySkillSchema = new Schema({
|
|||||||
|
|
||||||
MySkillSchema.pre('save', async function(next) {
|
MySkillSchema.pre('save', async function(next) {
|
||||||
if (this.isNew) {
|
if (this.isNew) {
|
||||||
const myrec = await MySkill.findOne().limit(1).sort({_id: -1});
|
|
||||||
if (!!myrec) {
|
|
||||||
if (myrec._doc._id === 0)
|
|
||||||
this._id = 1;
|
|
||||||
else
|
|
||||||
this._id = myrec._doc._id + 1;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this._id = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.date_created = new Date();
|
this.date_created = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,6 +145,7 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
|
|||||||
myskill: 1,
|
myskill: 1,
|
||||||
idStatusSkill: 1,
|
idStatusSkill: 1,
|
||||||
idContribType: 1,
|
idContribType: 1,
|
||||||
|
'profile.username_telegram': 1,
|
||||||
idCity: 1,
|
idCity: 1,
|
||||||
pub_to_share: 1,
|
pub_to_share: 1,
|
||||||
numLevel: 1,
|
numLevel: 1,
|
||||||
@@ -173,6 +166,7 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -186,13 +180,19 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
|
|||||||
MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
||||||
const MySkill = this;
|
const MySkill = this;
|
||||||
|
|
||||||
|
let myparskill = {};
|
||||||
|
|
||||||
|
if (tools.isNumber(idSkill)) {
|
||||||
|
myparskill = {'_id': parseInt(idSkill)};
|
||||||
|
} else {
|
||||||
|
myparskill = {'_id': idSkill};
|
||||||
|
}
|
||||||
|
|
||||||
const query = [
|
const query = [
|
||||||
{
|
{
|
||||||
'$match': {
|
'$match': {
|
||||||
'$and': [
|
'$and': [
|
||||||
{
|
myparskill,
|
||||||
'_id': parseInt(idSkill),
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -266,6 +266,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -322,6 +323,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -378,6 +380,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -436,6 +439,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -492,6 +496,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.mycircuits": 1,
|
"profile.mycircuits": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
'profile.resid_province': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -449,7 +449,21 @@ const UserSchema = new mongoose.Schema({
|
|||||||
},
|
},
|
||||||
noFoto: {
|
noFoto: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
}
|
},
|
||||||
|
bookmark: [
|
||||||
|
{
|
||||||
|
_id: false,
|
||||||
|
id: { type: String },
|
||||||
|
tab: { type: Number },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
favorite: [
|
||||||
|
{
|
||||||
|
_id: false,
|
||||||
|
id: { type: String },
|
||||||
|
tab: { type: Number },
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1882,6 +1896,33 @@ UserSchema.statics.removeReqFriend = async function (
|
|||||||
{ $pull: { 'profile.req_friends': { username: { $in: [usernameDest] } } } });
|
{ $pull: { 'profile.req_friends': { username: { $in: [usernameDest] } } } });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Rimuovo il Favorite
|
||||||
|
UserSchema.statics.removeFavorite = async function (
|
||||||
|
idapp, id, tab) {
|
||||||
|
return await User.updateOne({ idapp, username },
|
||||||
|
{ $pull: { 'profile.favorite': { id: { $in: [id] }, tab } } });
|
||||||
|
};
|
||||||
|
|
||||||
|
// Aggiungo il Favorite
|
||||||
|
UserSchema.statics.addFavorite = async function (
|
||||||
|
idapp, username, id, tab) {
|
||||||
|
return await User.updateOne({ idapp, username },
|
||||||
|
{ $push: { 'profile.favorite': { id, tab } } });
|
||||||
|
};
|
||||||
|
// Rimuovo il Bookmark
|
||||||
|
UserSchema.statics.removeBookmark = async function (
|
||||||
|
idapp, id, tab) {
|
||||||
|
return await User.updateOne({ idapp, username },
|
||||||
|
{ $pull: { 'profile.bookmark': { id: { $in: [id] }, tab } } });
|
||||||
|
};
|
||||||
|
|
||||||
|
// Aggiungo il Bookmark
|
||||||
|
UserSchema.statics.addBookmark = async function (
|
||||||
|
idapp, username, id, tab) {
|
||||||
|
return await User.updateOne({ idapp, username },
|
||||||
|
{ $push: { 'profile.bookmark': { id, tab } } });
|
||||||
|
};
|
||||||
|
|
||||||
UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, usernameDest, cmd, value, disablenotif) {
|
UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, usernameDest, cmd, value, disablenotif) {
|
||||||
|
|
||||||
const { SendNotif } = require('../models/sendnotif');
|
const { SendNotif } = require('../models/sendnotif');
|
||||||
|
|||||||
@@ -1436,4 +1436,43 @@ router.post('/mgt', authenticate, async (req, res) => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.post('/cmd', authenticate, async (req, res) => {
|
||||||
|
|
||||||
|
const mydata = req.body.mydata;
|
||||||
|
const idapp = req.body.idapp;
|
||||||
|
const cmd = req.body.cmd;
|
||||||
|
const id = req.body.id;
|
||||||
|
const tab = req.body.tab;
|
||||||
|
const value = req.body.value;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const username = req.user.username;
|
||||||
|
|
||||||
|
let ris = null;
|
||||||
|
|
||||||
|
if (cmd === shared_consts.CMD_USER.SET_FAVORITE) {
|
||||||
|
if (value)
|
||||||
|
ris = await User.addFavorite(idapp, username, id, tab);
|
||||||
|
else
|
||||||
|
ris = await User.removeFavorite(idapp, username, id, tab);
|
||||||
|
} else if (cmd === shared_consts.CMD_USER.SET_BOOKMARK) {
|
||||||
|
if (value)
|
||||||
|
ris = await User.addBookmark(idapp, username, id, tab);
|
||||||
|
else
|
||||||
|
ris = await User.removeBookmark(idapp, username, id, tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
let state = (value && ris && ris.ok === 1) ? 1 : ((!value && ris && ris.ok === 1) ? -1 : 0);
|
||||||
|
|
||||||
|
return res.send({ state });
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
res.status(400).send();
|
||||||
|
res.send({ code: server_constants.RIS_CODE_ERR, msg: e });
|
||||||
|
|
||||||
|
console.log(e.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -134,6 +134,13 @@ module.exports = {
|
|||||||
TABLES_MYGOODS: 'mygoods',
|
TABLES_MYGOODS: 'mygoods',
|
||||||
TABLES_MYEVENTS: 'myevents',
|
TABLES_MYEVENTS: 'myevents',
|
||||||
|
|
||||||
|
MYTABS: ['none', 'myskills', 'mybachecas', 'myhosps', 'mygoods', 'myevents'],
|
||||||
|
|
||||||
|
CMD_USER: {
|
||||||
|
SET_FAVORITE: 1,
|
||||||
|
SET_BOOKMARK: 2,
|
||||||
|
},
|
||||||
|
|
||||||
TABLES_ENABLE_GETREC_BYID: ['mybachecas', 'myhosps', 'myskills', 'mygoods'],
|
TABLES_ENABLE_GETREC_BYID: ['mybachecas', 'myhosps', 'myskills', 'mygoods'],
|
||||||
|
|
||||||
TABLES_USER_INCLUDE_MY: ['mygroups', 'circuits'],
|
TABLES_USER_INCLUDE_MY: ['mygroups', 'circuits'],
|
||||||
@@ -173,11 +180,11 @@ module.exports = {
|
|||||||
'subskills',
|
'subskills',
|
||||||
'cities',
|
'cities',
|
||||||
'provinces',
|
'provinces',
|
||||||
'myskills',
|
// 'myskills',
|
||||||
'mybachecas',
|
// 'mybachecas',
|
||||||
'myhosps',
|
// 'myhosps',
|
||||||
'mygoods',
|
// 'mygoods',
|
||||||
'mygroups'
|
// 'mygroups'
|
||||||
],
|
],
|
||||||
TABLES_USER_ID: ['mygroups', 'myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
TABLES_USER_ID: ['mygroups', 'myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
||||||
TABLES_CREATEDBY: ['mygroups', 'circuits'],
|
TABLES_CREATEDBY: ['mygroups', 'circuits'],
|
||||||
|
|||||||
Reference in New Issue
Block a user