diff --git a/README.md b/README.md index 59260a6..789e21a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Freeplanet_serverside -A Node JS +- Node JS (ver. 16.14.0 or up) ## Install the dependencies ```bash @@ -12,11 +12,31 @@ yarn node src/server/server.js ``` -### Build the test ambient +### Creating the ambient test + +Create your .env.test file copying from .env.development +```bash +cp .env.development .env.test +``` + +And modifying the file with your configuration + + +### Build the ambient test + ```bash ./deploynodejs_on_test.js ``` +### Creating the ambient Production + +Create your .env.production file copying from .env.development +```bash +cp .env.development .env.production +``` + +And modifying the file with your configuration + ### Build the production ```bash ./deploynodejs_on_production.js diff --git a/ecosystem.config.js b/ecosystem.config.js index 3f6e936..2d0f518 100755 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -4,7 +4,7 @@ module.exports = { name: "FreePlanetServerSide", script: "./src/server/server.js", ignore_watch : ["node_modules"], - watch: true, + watch: false, env: { "PORT": 3000, "NODE_ENV": "development" diff --git a/package.json b/package.json index faa8d16..579e148 100755 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "test-watch": "nodemon --exec 'npm test'" }, "engines": { - "node": "^14.4.0" + "node": "^16.14.0" }, "author": "Paolo Arena", "license": "MIT", diff --git a/src/server/models/adtypegood.js b/src/server/models/adtypegood.js new file mode 100755 index 0000000..d65ac5e --- /dev/null +++ b/src/server/models/adtypegood.js @@ -0,0 +1,67 @@ +const mongoose = require('mongoose').set('debug', false); +const Schema = mongoose.Schema; + +mongoose.Promise = global.Promise; +mongoose.level = ""; + +const tools = require('../tools/general'); + +const {ObjectID} = require('mongodb'); + +// Resolving error Unknown modifier: $pushAll +mongoose.plugin(schema => { + schema.options.usePushEach = true; +}); + +const AdTypeGoodSchema = new Schema({ + _id: { + type: Number, + }, + descr: { + type: String, + }, +}); + +AdTypeGoodSchema.pre('save', async function (next) { + if (this.isNew) { + const myrec = await AdTypeGood.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; + } + } + + next(); +}); + + +AdTypeGoodSchema.statics.findAllIdApp = async function(idapp) { + const AdTypeGood = this; + + const query = [ + {$sort: {_id: 1}}, + ]; + + return AdTypeGood.aggregate(query).then((arrrec) => { + return arrrec; + }); + +}; + +AdTypeGoodSchema.statics.getFieldsForSearch = function() { + return [ + {field: 'descr', type: tools.FieldType.string}]; +}; + +AdTypeGoodSchema.statics.executeQueryTable = function(idapp, params) { + params.fieldsearch = this.getFieldsForSearch(); + return tools.executeQueryTable(this, 0, params); +}; + +const AdTypeGood = mongoose.model('AdTypeGood', AdTypeGoodSchema); + +module.exports = {AdTypeGood}; diff --git a/src/server/models/city.js b/src/server/models/city.js index b83dc8c..49635de 100755 --- a/src/server/models/city.js +++ b/src/server/models/city.js @@ -109,16 +109,29 @@ CitySchema.statics.executeQueryPickup = async function(idapp, params) { const strfind = params.search; - if (strfind === '') { + if (strfind === '' && !params.filter) { return []; } - let filterfindexact = {comune: strfind}; - const risexact = await City.find(filterfindexact, {comune: 1, prov: 1, reg: 1}).lean(); + let filterfindexact = {}; + if (strfind){ + filterfindexact = {comune: strfind}; + } + + let limit = 10 + let risexact = [] + let filterfind = {comune: {$regex: '^' + strfind, $options: 'i'}}; - let ris = await City.find(filterfind, {comune: 1, prov: 1, reg: 1}).lean().limit(10); + if (params.filter) { + filterfind = {...params.filter, ...filterfind} + limit = 200 + } else{ + risexact = await City.find(filterfindexact, {comune: 1, prov: 1, reg: 1}).lean(); + } + + let ris = await City.find(filterfind, {comune: 1, prov: 1, reg: 1}).lean().limit(limit); return [...risexact, ...ris]; diff --git a/src/server/models/good.js b/src/server/models/good.js new file mode 100755 index 0000000..6f41b38 --- /dev/null +++ b/src/server/models/good.js @@ -0,0 +1,83 @@ +const mongoose = require('mongoose').set('debug', false) +const Schema = mongoose.Schema; + +mongoose.Promise = global.Promise; +mongoose.level = "F"; + +const tools = require('../tools/general'); + +const { ObjectID } = require('mongodb'); + +// Resolving error Unknown modifier: $pushAll +mongoose.plugin(schema => { + schema.options.usePushEach = true +}); + +const GoodSchema = new Schema({ + _id: { + type: Number, + }, + descr: { + type: String, + }, + idSectorGood: [{ + type: Number + }], + icon: { + type: String, + }, + img: { + type: String, + }, +}); + +GoodSchema.statics.findAllIdApp = async function (idapp) { + const Good = this; + + const query = [ + { $sort: { descr: 1 } } + ]; + + const res = Good + .aggregate(query) + .then((arrrec) => { + return arrrec + }) + + return res; + +}; + +GoodSchema.pre('save', async function (next) { + if (this.isNew) { + const myrec = await Good.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; + } + } + + next(); +}); + + + +GoodSchema.statics.getFieldsForSearch = function () { + return [{ field: 'label', type: tools.FieldType.string }, + { field: 'descr', type: tools.FieldType.string }] +}; + +GoodSchema.statics.executeQueryTable = function (idapp, params) { + params.fieldsearch = this.getFieldsForSearch(); + return tools.executeQueryTable(this, 0, params); +}; + + +const Good = mongoose.model('Good', GoodSchema); + +module.exports = { Good }; diff --git a/src/server/models/mybacheca.js b/src/server/models/mybacheca.js index e22cda0..3381e20 100755 --- a/src/server/models/mybacheca.js +++ b/src/server/models/mybacheca.js @@ -29,11 +29,6 @@ const MyBachecaSchema = new Schema({ type: Number, default: 0, }, - idSubSkill: [ - { - type: Number, - default: 0, - }], idStatusSkill: [ { type: Number, @@ -361,14 +356,14 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) { 'profile.qualifica': 1, }, }, - { + /*{ '$lookup': { 'from': 'subskills', 'localField': 'idSubSkill', 'foreignField': '_id', 'as': 'MyBacheca', }, - }, + },*/ { '$replaceRoot': { 'newRoot': { @@ -390,7 +385,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) { 'sector': 1, 'idSector': 1, 'idSkill': 1, - 'idSubSkill': 1, + // 'idSubSkill': 1, 'idStatusSkill': 1, 'idContribType': 1, 'idCity': 1, @@ -442,7 +437,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) { 'sector': 1, 'idSector': 1, 'idSkill': 1, - 'idSubSkill': 1, + // 'idSubSkill': 1, 'idStatusSkill': 1, 'idContribType': 1, 'idCity': 1, diff --git a/src/server/models/mygood.js b/src/server/models/mygood.js new file mode 100755 index 0000000..7f56976 --- /dev/null +++ b/src/server/models/mygood.js @@ -0,0 +1,481 @@ +const mongoose = require('mongoose').set('debug', false); +const Schema = mongoose.Schema; + +mongoose.Promise = global.Promise; +mongoose.level = 'F'; + +const tools = require('../tools/general'); + +const {ObjectID} = require('mongodb'); + +// Resolving error Unknown modifier: $pushAll +mongoose.plugin(schema => { + schema.options.usePushEach = true; +}); + +const MyGoodSchema = new Schema({ + _id: { + type: Number, + }, + idapp: { + type: String, + required: true, + }, + userId: {type: Schema.Types.ObjectId, ref: 'User'}, + idSectorGood: { + type: Number, + }, + idGood: { + type: Number, + default: 0, + }, + idShipping: [ + { + type: Number, + }], + + idContribType: [ + { + type: String, + }], + idCity: [ + { + type: Number, + }], + numLevel: { + type: Number, + default: 0, + }, + adType: { + type: Number, + }, + photos: [ + { + imagefile: { + type: String, + }, + alt: { + type: String, + }, + description: { + type: String, + }, + }], + note: { + type: String, + default: '', + }, + descr: { + type: String, + }, + //**ADDFIELD_MyGood + website: { + type: String, + }, + date_created: { + type: Date, + default: Date.now, + }, + date_updated: { + type: Date, + default: Date.now, + }, +}); + +MyGoodSchema.pre('save', async function(next) { + if (this.isNew) { + const myrec = await MyGood.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(); + } + + next(); +}); + +MyGoodSchema.statics.findAllIdApp = async function(idapp) { + const MyGood = this; + + const query = [ + {$match: {idapp}}, + {$sort: {descr: 1}}, + ]; + + return MyGood.aggregate(query).then((arrrec) => { + return arrrec; + }); + +}; + +MyGoodSchema.statics.getFieldsForSearch = function() { + return []; +}; + +MyGoodSchema.statics.getFieldsLastForSearch = function() { + return [ + {field: 'note', type: tools.FieldType.string}, + {field: 'descr', type: tools.FieldType.string}, + {field: 'recGood.descr', type: tools.FieldType.string}, + {field: 'MyGood.descr', type: tools.FieldType.string}, + ]; +}; + + +MyGoodSchema.statics.executeQueryTable = function(idapp, params) { + params.fieldsearch = this.getFieldsForSearch(); + params.fieldsearch_last = this.getFieldsLastForSearch(); + + const otherparams = { + lookup1: { + lk_tab: 'users', + lk_LF: 'userId', + lk_FF: '_id', + lk_as: 'user', + af_objId_tab: 'myId', + lk_proj: { + idGood: 1, + idShipping: 1, + MyGood: 1, + idStatusGood: 1, + idContribType: 1, + idCity: 1, + numLevel: 1, + adType: 1, + photos: 1, + note: 1, + website: 1, + //**ADDFIELD_MyGood + descr: 1, + date_created: 1, + date_updated: 1, + userId: 1, + username: 1, + name: 1, + surname: 1, + 'profile.img': 1, + 'profile.qualifica': 1, + }, + }, + }; + + params = {...params, ...otherparams}; + + return tools.executeQueryTable(this, idapp, params); +}; + +MyGoodSchema.statics.getMyGoodById = function(idapp, idGood) { + const MyGood = this; + + const query = [ + { + '$match': { + '$and': [ + { + '_id': parseInt(idGood), + }, + ], + }, + }, + { + '$match': { + 'idapp': idapp, + }, + }, + { + '$sort': { + 'desc': 1, + }, + }, + { + '$addFields': { + 'myId1': { + '$toObjectId': '$userId', + }, + }, + }, + { + '$lookup': { + 'from': 'users', + 'localField': 'myId1', + 'foreignField': '_id', + 'as': 'user', + }, + }, + { + '$replaceRoot': { + 'newRoot': { + '$mergeObjects': [ + { + '$arrayElemAt': [ + '$user', + 0, + ], + }, + '$$ROOT', + ], + }, + }, + }, + { + '$project': { + 'recGood': 1, + 'sectorgood': 1, + 'idSectorGood': 1, + 'idGood': 1, + 'idShipping': 1, + 'idStatusGood': 1, + 'idContribType': 1, + 'idCity': 1, + 'numLevel': 1, + adType: 1, + 'photos': 1, + note: 1, + website: 1, + //**ADDFIELD_MyGood + 'descr': 1, + 'date_created': 1, + 'date_updated': 1, + 'userId': 1, + 'username': 1, + 'name': 1, + 'surname': 1, + 'comune': 1, + 'mycities': 1, + 'profile.img': 1, + 'profile.qualifica': 1, + }, + }, + { + '$lookup': { + 'from': 'goods', + 'localField': 'idGood', + 'foreignField': '_id', + 'as': 'recGood', + }, + }, + { + '$replaceRoot': { + 'newRoot': { + '$mergeObjects': [ + { + '$arrayElemAt': [ + '$recGood', + 0, + ], + }, + '$$ROOT', + ], + }, + }, + }, + { + '$project': { + 'recGood': 1, + 'sectorgood': 1, + 'idSectorGood': 1, + 'idGood': 1, + 'idShipping': 1, + 'idStatusGood': 1, + 'idContribType': 1, + 'idCity': 1, + 'numLevel': 1, + adType: 1, + 'photos': 1, + 'note': 1, + website: 1, + //**ADDFIELD_MyGood + 'descr': 1, + 'date_created': 1, + 'date_updated': 1, + 'userId': 1, + 'username': 1, + 'name': 1, + 'surname': 1, + 'comune': 1, + 'mycities': 1, + 'profile.img': 1, + 'profile.qualifica': 1, + }, + }, + { + '$lookup': { + 'from': 'sectorgoods', + 'localField': 'recGood.idSectorGood', + 'foreignField': '_id', + 'as': 'sectorgood', + }, + }, + { + '$replaceRoot': { + 'newRoot': { + '$mergeObjects': [ + { + '$arrayElemAt': [ + '$sectorgood', + 0, + ], + }, + '$$ROOT', + ], + }, + }, + }, + { + '$project': { + 'recGood': 1, + 'sectorgood': 1, + 'idSectorGood': 1, + 'idGood': 1, + 'idShipping': 1, + 'idStatusGood': 1, + 'idContribType': 1, + 'idCity': 1, + 'numLevel': 1, + adType: 1, + 'photos': 1, + 'note': 1, + website: 1, + //**ADDFIELD_MyGood + 'descr': 1, + 'date_created': 1, + 'date_updated': 1, + 'userId': 1, + 'username': 1, + 'name': 1, + 'surname': 1, + 'comune': 1, + 'mycities': 1, + 'profile.img': 1, + 'profile.qualifica': 1, + }, + }, + { + '$lookup': { + 'from': 'subgoods', + 'localField': 'idShipping', + 'foreignField': '_id', + 'as': 'MyGood', + }, + }, + { + '$replaceRoot': { + 'newRoot': { + '$mergeObjects': [ + { + '$arrayElemAt': [ + '$MyGood', + 0, + ], + }, + '$$ROOT', + ], + }, + }, + }, + { + '$project': { + 'recGood': 1, + 'sectorgood': 1, + 'idSectorGood': 1, + 'idGood': 1, + 'idShipping': 1, + 'idStatusGood': 1, + 'idContribType': 1, + 'idCity': 1, + 'numLevel': 1, + adType: 1, + 'photos': 1, + 'note': 1, + website: 1, + //**ADDFIELD_MyGood + 'descr': 1, + 'date_created': 1, + 'date_updated': 1, + 'userId': 1, + 'username': 1, + 'name': 1, + 'surname': 1, + 'comune': 1, + 'mycities': 1, + 'profile.img': 1, + 'profile.qualifica': 1, + }, + }, + { + '$lookup': { + 'from': 'cities', + 'localField': 'idCity', + 'foreignField': '_id', + 'as': 'mycities', + }, + }, + { + '$replaceRoot': { + 'newRoot': { + '$mergeObjects': [ + { + '$arrayElemAt': [ + '$mycities', + 0, + ], + }, + '$$ROOT', + ], + }, + }, + }, + { + '$project': { + 'recGood': 1, + 'sectorgood': 1, + 'idSectorGood': 1, + 'idGood': 1, + 'idShipping': 1, + 'idStatusGood': 1, + 'idContribType': 1, + 'idCity': 1, + 'numLevel': 1, + adType: 1, + 'photos': 1, + 'note': 1, + website: 1, + //**ADDFIELD_MyGood + 'descr': 1, + 'date_created': 1, + 'date_updated': 1, + 'userId': 1, + 'username': 1, + 'name': 1, + 'surname': 1, + 'comune': 1, + 'mycities': 1, + 'profile.img': 1, + 'profile.qualifica': 1, + }, + }, + ]; + + return MyGood.aggregate(query).then((rec) => { + return rec ? rec[0] : null; + }); +}; + +MyGoodSchema.statics.getCompleteRecord = function(idapp, id) { + const MyGood = this; + + return MyGood.getMyGoodById(idapp, id); + +}; + + +const MyGood = mongoose.model('MyGood', MyGoodSchema); + +module.exports = {MyGood}; diff --git a/src/server/models/mygroup.js b/src/server/models/mygroup.js index 25c9e7b..ef840f9 100755 --- a/src/server/models/mygroup.js +++ b/src/server/models/mygroup.js @@ -106,9 +106,10 @@ MyGroupSchema.statics.executeQueryTable = function(idapp, params) { params.fieldsearch = this.getFieldsForSearch(); if (params.options) { - if (tools.isBitActive(params.options, - shared_consts.OPTIONS_SEARCH_USER_ONLY_FULL_WORDS)) { + if (tools.isBitActive(params.options, shared_consts.OPTIONS_SEARCH_USER_ONLY_FULL_WORDS)) { params.fieldsearch = User.getFieldsForSearchUserFriend(); + } else if (tools.isBitActive(params.options, shared_consts.OPTIONS_SEARCH_USER_ALL_WORDS)) { + params.fieldsearch = User.getFieldsForSearchUserFriend_AllWords(); } } diff --git a/src/server/models/myskill.js b/src/server/models/myskill.js index 2819aa6..b62d106 100755 --- a/src/server/models/myskill.js +++ b/src/server/models/myskill.js @@ -29,11 +29,13 @@ const MySkillSchema = new Schema({ type: Number, default: 0, }, - idSubSkill: [ + /*idSubSkill: [ { type: Number, default: 0, }], + + */ idStatusSkill: [ { type: Number, @@ -146,7 +148,7 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params) { af_objId_tab: 'myId', lk_proj: { idSkill: 1, - idSubSkill: 1, + // idSubSkill: 1, myskill: 1, idStatusSkill: 1, idContribType: 1, @@ -234,7 +236,7 @@ MySkillSchema.statics.getMySkillByIdkill = function(idapp, idSkill) { 'sector': 1, 'idSector': 1, 'idSkill': 1, - 'idSubSkill': 1, + // 'idSubSkill': 1, 'idStatusSkill': 1, 'idContribType': 1, 'idCity': 1, @@ -286,7 +288,7 @@ MySkillSchema.statics.getMySkillByIdkill = function(idapp, idSkill) { 'sector': 1, 'idSector': 1, 'idSkill': 1, - 'idSubSkill': 1, + // 'idSubSkill': 1, 'idStatusSkill': 1, 'idContribType': 1, 'idCity': 1, @@ -338,7 +340,7 @@ MySkillSchema.statics.getMySkillByIdkill = function(idapp, idSkill) { 'sector': 1, 'idSector': 1, 'idSkill': 1, - 'idSubSkill': 1, + //'idSubSkill': 1, 'idStatusSkill': 1, 'idContribType': 1, 'idCity': 1, @@ -361,7 +363,7 @@ MySkillSchema.statics.getMySkillByIdkill = function(idapp, idSkill) { 'profile.qualifica': 1, }, }, - { + /*{ '$lookup': { 'from': 'subskills', 'localField': 'idSubSkill', @@ -369,6 +371,8 @@ MySkillSchema.statics.getMySkillByIdkill = function(idapp, idSkill) { 'as': 'myskill', }, }, + + */ { '$replaceRoot': { 'newRoot': { @@ -390,7 +394,7 @@ MySkillSchema.statics.getMySkillByIdkill = function(idapp, idSkill) { 'sector': 1, 'idSector': 1, 'idSkill': 1, - 'idSubSkill': 1, + // 'idSubSkill': 1, 'idStatusSkill': 1, 'idContribType': 1, 'idCity': 1, @@ -442,7 +446,7 @@ MySkillSchema.statics.getMySkillByIdkill = function(idapp, idSkill) { 'sector': 1, 'idSector': 1, 'idSkill': 1, - 'idSubSkill': 1, + // 'idSubSkill': 1, 'idStatusSkill': 1, 'idContribType': 1, 'idCity': 1, diff --git a/src/server/models/sectorgood.js b/src/server/models/sectorgood.js new file mode 100755 index 0000000..9ff3002 --- /dev/null +++ b/src/server/models/sectorgood.js @@ -0,0 +1,83 @@ +const mongoose = require('mongoose').set('debug', false) +const Schema = mongoose.Schema; + +mongoose.Promise = global.Promise; +mongoose.level = "F"; + +const tools = require('../tools/general'); + +const { ObjectID } = require('mongodb'); + +// Resolving error Unknown modifier: $pushAll +mongoose.plugin(schema => { + schema.options.usePushEach = true +}); + +const SectorGoodSchema = new Schema({ + _id: { + type: Number, + }, + descr: { + type: String, + }, + idSectorGood: { + type: Number + }, + icon: { + type: String, + }, + img: { + type: String, + }, + color: { + type: String, + }, + theme: { + type: String, + }, +}); + +SectorGoodSchema.pre('save', async function (next) { + if (this.isNew) { + const myrec = await SectorGood.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; + } + } + + next(); +}); + +SectorGoodSchema.statics.findAllIdApp = async function (idapp) { + const SectorGood = this; + + const query = [ + { $sort: { descr: 1 } } + ]; + + return SectorGood + .aggregate(query) + .then((arrrec) => { + return arrrec + }) + +}; + +SectorGoodSchema.statics.getFieldsForSearch = function () { + return [{ field: 'descr', type: tools.FieldType.string }] +}; + +SectorGoodSchema.statics.executeQueryTable = function (idapp, params) { + params.fieldsearch = this.getFieldsForSearch(); + return tools.executeQueryTable(this, 0, params); +}; + + +const SectorGood = mongoose.model('SectorGood', SectorGoodSchema); + +module.exports = { SectorGood }; diff --git a/src/server/models/statusSkill.js b/src/server/models/statusSkill.js index 1c357c8..36216ad 100755 --- a/src/server/models/statusSkill.js +++ b/src/server/models/statusSkill.js @@ -21,6 +21,9 @@ const StatusSkillSchema = new Schema({ color: { type: String, }, + icon: { + type: String, + }, theme: { type: String, }, diff --git a/src/server/models/user.js b/src/server/models/user.js index 44e05fb..b2e5ef1 100755 --- a/src/server/models/user.js +++ b/src/server/models/user.js @@ -260,6 +260,9 @@ const UserSchema = new mongoose.Schema({ type: String, trim: true, }, + born_city_id: { + type: Number, + }, born_province: { type: String, trim: true, @@ -1217,7 +1220,7 @@ UserSchema.statics.getUserProfileByUsername = async function( 'profile.img': 1, 'profile.sex': 1, 'profile.dateofbirth': 1, - 'profile.born_city': 1, + 'profile.born_city_id': 1, 'profile.born_province': 1, 'profile.born_country': 1, email: 1, @@ -1245,23 +1248,72 @@ UserSchema.statics.getUserProfileByUsername = async function( 'profile.img': 1, 'profile.sex': 1, 'profile.dateofbirth': 1, - 'profile.born_city': 1, + 'profile.born_city_id': 1, 'profile.born_province': 1, 'profile.born_country': 1, + 'mycities': 1, + 'comune': 1, email: 1, date_reg: 1, }; } - return User.findOne({ + const myfind = { idapp, username, $or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}], + }; + + const query = [ + {$match: myfind}, + { + $lookup: { + from: 'cities', + localField: 'profile.born_city_id', + foreignField: '_id', + as: 'mycities', + }, + }, + { + '$replaceRoot': { + 'newRoot': { + '$mergeObjects': [ + { + '$arrayElemAt': [ + '$mycities', + 0, + ], + }, + '$$ROOT', + ], + }, + }, + }, + {$project: whatToShow}, + + ]; + + try { + const ris = await User.aggregate(query); + + if (ris && ris.length > 0) + return ris[0]; + } catch (e) { + return null; + } + + return null; + + /* + return User.findOne({ }, whatToShow).then((rec) => { return (rec._doc); }).catch((e) => { return null; }); + + */ + }; UserSchema.statics.getArrUsernameFromFieldByUsername = async function( @@ -1417,7 +1469,8 @@ UserSchema.statics.setFriendsCmd = async function( } if (ris) { // Invia una notifica alla persona - tools.sendNotificationByUsername(idapp, usernameDest, cmd, true, usernameOrig); + tools.sendNotificationByUsername(idapp, usernameDest, cmd, true, + usernameOrig); } } else { if (foundIfAlreadyAskFriend) { @@ -1587,7 +1640,7 @@ function getWhatToShow(idapp, username) { 'profile.img': 1, 'profile.sex': 1, 'profile.dateofbirth': 1, - 'profile.born_city': 1, + 'profile.born_city_id': 1, 'profile.born_province': 1, 'profile.born_country': 1, email: 1, @@ -2218,12 +2271,19 @@ UserSchema.statics.getFieldsForSearchUserFriend = function() { return [{field: 'username', type: tools.FieldType.exact}]; }; +UserSchema.statics.getFieldsForSearchUserFriend_AllWords = function() { + return [{field: 'username', type: tools.FieldType.string}]; +}; + UserSchema.statics.executeQueryTable = function(idapp, params) { params.fieldsearch = this.getFieldsForSearch(); if (params.options) { if (tools.isBitActive(params.options, - shared_consts.OPTIONS_SEARCH_ONLY_FULL_WORDS)) { + shared_consts.OPTIONS_SEARCH_USER_ONLY_FULL_WORDS)) { params.fieldsearch = this.getFieldsForSearchUserFriend(); + } else if (tools.isBitActive(params.options, + shared_consts.OPTIONS_SEARCH_USER_ALL_WORDS)) { + params.fieldsearch = this.getFieldsForSearchUserFriend_AllWords(); } } return tools.executeQueryTable(this, idapp, params); @@ -2557,25 +2617,31 @@ UserSchema.statics.checkUser = async function(idapp, username) { UserSchema.statics.calculateStat = async function(idapp, username) { const User = this; - const {MySkill} = require('../models/myskill'); - const {MyBacheca} = require('../models/mybacheca'); - const {MyGroup} = require('../models/mygroup'); + try { + const {MySkill} = require('../models/myskill'); + const {MyGood} = require('../models/mygood'); + const {MyBacheca} = require('../models/mybacheca'); + const {MyGroup} = require('../models/mygroup'); - const numUsersReg = await User.countDocuments( - { - idapp, - $or: [ - {deleted: {$exists: false}}, - {deleted: {$exists: true, $eq: false}}], - }); + const numUsersReg = await User.countDocuments( + { + idapp, + $or: [ + {deleted: {$exists: false}}, + {deleted: {$exists: true, $eq: false}}], + }); - const numMySkills = await MySkill.countDocuments({idapp}); + const numMySkills = await MySkill.countDocuments({idapp}); + const numMyGoods = await MyGood.countDocuments({idapp}); - const numMyBachecas = await MyBacheca.countDocuments({idapp}); + const numMyBachecas = await MyBacheca.countDocuments({idapp}); - const numGroups = await MyGroup.countDocuments({idapp}); + const numGroups = await MyGroup.countDocuments({idapp}); - return {numMySkills, numMyBachecas, numUsersReg, numGroups}; + return {numMySkills, numMyGoods, numMyBachecas, numUsersReg, numGroups}; + } catch (e) { + console.error(e.message); + } }; diff --git a/src/server/populate/adtypegoods.js b/src/server/populate/adtypegoods.js new file mode 100644 index 0000000..28531ab --- /dev/null +++ b/src/server/populate/adtypegoods.js @@ -0,0 +1,6 @@ +module.exports = { + list: [ + {_id: 1, descr: 'Offro'}, + {_id: 2, descr: 'Cerco'}, + ], +}; diff --git a/src/server/populate/catgrps.js b/src/server/populate/catgrps.js index 97a84c8..aecb443 100644 --- a/src/server/populate/catgrps.js +++ b/src/server/populate/catgrps.js @@ -2,71 +2,71 @@ module.exports = { list: [ { _id: 1, - descr: "Abitare", + descr: 'Abitare', }, { _id: 2, - descr: "Arte", + descr: 'Arte', }, { _id: 3, - descr: "Alimentazione", + descr: 'Alimentazione', }, { _id: 4, - descr: "Artigianato", + descr: 'Artigianato', }, { _id: 5, - descr: "Assistenza Legale", + descr: 'Assistenza Legale', }, { _id: 6, - descr: "Benessere e Salute", + descr: 'Benessere e Salute', }, { _id: 7, - descr: "Gruppi Locali", + descr: 'Gruppi Locali', }, { _id: 8, - descr: "Istruzione", + descr: 'Istruzione', }, { _id: 2, - descr: "Arte", + descr: 'Arte', }, { _id: 9, - descr: "Mobilità", + descr: 'Mobilità', }, { _id: 10, - descr: "Sport", + descr: 'Sport', }, { _id: 11, - descr: "Servizi", + descr: 'Servizi', }, { _id: 12, - descr: "Tecnologia", + descr: 'Tecnologia', }, { _id: 13, - descr: "Turismo", + descr: 'Turismo', }, { _id: 14, - descr: "Ecovillaggi", + descr: 'Ecovillaggi', }, { _id: 15, - descr: "Feste", + descr: 'Feste', }, { _id: 16, - descr: "Altro", + descr: 'Altro', }, - ] -} + ], +}; diff --git a/src/server/populate/contribtypes.js b/src/server/populate/contribtypes.js index f2e21b4..98c5733 100644 --- a/src/server/populate/contribtypes.js +++ b/src/server/populate/contribtypes.js @@ -57,7 +57,7 @@ module.exports = { { "_id" : ObjectID("61bc454867de9a1f54b254f2"), "idapp" : "12", - "label" : "Baratto (scambio Beni o Servizi)", + "label" : "Baratto", "__v" : 0 }, { @@ -69,7 +69,7 @@ module.exports = { { "_id" : ObjectID("61bc482667de9a1f64b254ab"), "idapp" : "12", - "label" : "Monete Alternative", + "label" : "Monete Alternative (Ris, Sardex, Gaiax, Val, Cripto)", "__v" : 0 }, { @@ -158,31 +158,7 @@ module.exports = { { "_id" : ObjectID("51bc482667de9a1f64b254ab"), "idapp" : "13", - "label" : "Monete Alternative", - "__v" : 0 - }, - { - "_id" : ObjectID("51bc482667de9a1f64b254ac"), - "idapp" : "13", - "label" : "Ris (RISO)", - "__v" : 0 - }, - { - "_id" : ObjectID("51bc482667de9a1f64b254ad"), - "idapp" : "13", - "label" : "Sardex", - "__v" : 0 - }, - { - "_id" : ObjectID("51bc482667de9a1f64b254ae"), - "idapp" : "13", - "label" : "Gaiax (ProItaly)", - "__v" : 0 - }, - { - "_id" : ObjectID("51bc482667de9a1f64b254af"), - "idapp" : "13", - "label" : "Val (VAL.AZ.CO.)", + "label" : "Monete Alternative (Ris, Sardex, Gaiax, Val, Cripto)", "__v" : 0 }, { @@ -191,11 +167,5 @@ module.exports = { "label" : "Euro", "__v" : 0 }, - { - "_id" : ObjectID("51bc482667de9a1f64b257fb"), - "idapp" : "13", - "label" : "Criptomonete", - "__v" : 0 - }, ] } diff --git a/src/server/populate/goods.js b/src/server/populate/goods.js new file mode 100644 index 0000000..4037e9d --- /dev/null +++ b/src/server/populate/goods.js @@ -0,0 +1,58 @@ +module.exports = { + list: [ + {_id: 1, idSectorGood: [1], descr: 'Abbigliamento donna'}, + {_id: 2, idSectorGood: [1], descr: 'Abbigliamento uomo'}, + {_id: 3, idSectorGood: [1], descr: 'Accessori'}, + {_id: 4, idSectorGood: [1], descr: 'Scarpe donna'}, + {_id: 5, idSectorGood: [1], descr: 'Scarpe uomo'}, + {_id: 6, idSectorGood: [2], descr: 'Bagno'}, + {_id: 7, idSectorGood: [2], descr: 'Camera'}, + {_id: 8, idSectorGood: [2], descr: 'Complementi d\'arredo'}, + {_id: 9, idSectorGood: [2], descr: 'Cucina'}, + {_id: 10, idSectorGood: [2], descr: 'Esterno'}, + {_id: 11, idSectorGood: [2], descr: 'Soggiorno'}, + {_id: 12, idSectorGood: [3], descr: 'Altri veicoli'}, + {_id: 13, idSectorGood: [3], descr: 'Auto'}, + {_id: 14, idSectorGood: [3], descr: 'Moto'}, + {_id: 15, idSectorGood: [3], descr: 'Camper'}, + {_id: 16, idSectorGood: [3], descr: 'Van (furgoni camperizzati)'}, + {_id: 17, idSectorGood: [4], descr: 'Bigiotteria'}, + {_id: 18, idSectorGood: [4], descr: 'Lavoretti'}, + {_id: 19, idSectorGood: [4], descr: 'Mangia e bevi'}, + {_id: 20, idSectorGood: [5], descr: 'Accessori bellezza'}, + {_id: 21, idSectorGood: [5], descr: 'Creme e detergenti'}, + {_id: 22, idSectorGood: [5], descr: 'Trucchi e profumi'}, + {_id: 23, idSectorGood: [6], descr: 'Giocattoli e giochi di società'}, + {_id: 24, idSectorGood: [6], descr: 'Igiene e pannolini'}, + {_id: 25, idSectorGood: [6], descr: 'Lettini e culle'}, + {_id: 26, idSectorGood: [6], descr: 'Passeggini & co'}, + {_id: 27, idSectorGood: [6], descr: 'Vestiti e scarpe'}, + {_id: 28, idSectorGood: [7], descr: 'Bere'}, + {_id: 29, idSectorGood: [7], descr: 'Mangiare'}, + {_id: 30, idSectorGood: [8], descr: 'Antiquariato'}, + {_id: 31, idSectorGood: [8], descr: 'Collezionismo'}, + {_id: 32, idSectorGood: [9], descr: 'Altro'}, + {_id: 33, idSectorGood: [9], descr: 'Cellulari e accessori'}, + {_id: 34, idSectorGood: [9], descr: 'Computer e software'}, + {_id: 35, idSectorGood: [9], descr: 'Elettrodomestici'}, + {_id: 36, idSectorGood: [9], descr: 'Fotografia'}, + {_id: 37, idSectorGood: [9], descr: 'Videogiochi e console'}, + {_id: 38, idSectorGood: [10], descr: 'Console'}, + {_id: 39, idSectorGood: [10], descr: 'Giochi di società'}, + {_id: 40, idSectorGood: [10], descr: 'PC games'}, + {_id: 41, idSectorGood: [11], descr: 'Attrezzatura'}, + {_id: 42, idSectorGood: [11], descr: 'Materiali'}, + {_id: 43, idSectorGood: [11], descr: 'Prodotti'}, + {_id: 44, idSectorGood: [11], descr: 'Strumentazione'}, + {_id: 45, idSectorGood: [12], descr: ' riviste e fumetti'}, + {_id: 46, idSectorGood: [13], descr: 'CD e vinili'}, + {_id: 47, idSectorGood: [13], descr: 'Film e DVD'}, + {_id: 48, idSectorGood: [13], descr: 'Strumenti musicali'}, + {_id: 49, idSectorGood: [14], descr: 'Arredamento'}, + {_id: 50, idSectorGood: [14], descr: 'Attrezzature e accessori'}, + {_id: 51, idSectorGood: [14], descr: 'Cancelleria e cartucce'}, + {_id: 52, idSectorGood: [15], descr: 'Abbigliamento'}, + {_id: 53, idSectorGood: [15], descr: 'Attrezzature e accessori Sport'}, + {_id: 54, idSectorGood: [15], descr: 'Bici e accessori'}, + ], +}; diff --git a/src/server/populate/levels.js b/src/server/populate/levels.js index 3980a38..08396e2 100644 --- a/src/server/populate/levels.js +++ b/src/server/populate/levels.js @@ -2,7 +2,7 @@ module.exports = { list: [ {_id: 0, descr: '[Nessuno]', years_of_exp: 0}, {_id: 1, descr: 'Elementare', years_of_exp: 1}, - {_id: 2, descr: 'Intermedio', years_of_exp: 3}, - {_id: 3, descr: 'Avanzato', years_of_exp: 5}, + {_id: 2, descr: 'Intermedio', years_of_exp: 2}, + {_id: 3, descr: 'Avanzato', years_of_exp: 3}, ], }; diff --git a/src/server/populate/subskills.js b/src/server/populate/off_subskills.js.off similarity index 100% rename from src/server/populate/subskills.js rename to src/server/populate/off_subskills.js.off diff --git a/src/server/populate/populate.js b/src/server/populate/populate.js index cb67a1d..1a609fd 100644 --- a/src/server/populate/populate.js +++ b/src/server/populate/populate.js @@ -1,5 +1,10 @@ + const tools = require('../tools/general'); -const Path = require('path') +const Path = require('path'); + +const shared_consts = require('../tools/shared_nodejs'); + +const globalTables = require('../tools/globalTables'); module.exports = { @@ -18,7 +23,7 @@ module.exports = { }); } } - }catch (e){ + } catch (e) { console.log('error insertIntoDb', e); } @@ -39,7 +44,7 @@ module.exports = { if (mydbfile && mydbfile.list) { for (const rec of mydbfile.list) { - let obj = {} + let obj = {}; obj[field] = rec[field]; var mynewrec = new table(rec); @@ -55,24 +60,22 @@ module.exports = { if (ris) { numrec++; } - }catch (e){ + } catch (e) { console.log('error ', e); } - //await table.insertMany(rec, {ordered: false}); } } if (numrec > 0) - console.log('*** Insert', numrec, 'record on '+tablename); + console.log('*** Insert', numrec, 'record on ' + tablename); } } - }catch (e){ + } catch (e) { console.log('error insertIntoDb', e); } - }, async rewriteTable(table) { @@ -80,102 +83,89 @@ module.exports = { let mytab = null; let field = ''; - const {City} = require('../models/city'); - const {Province} = require('../models/province'); - const {Sector} = require('../models/sector'); - const {Skill} = require('../models/skill'); - const {SubSkill} = require('../models/subskill'); - const {Contribtype} = require('../models/contribtype'); - const {Level} = require('../models/level'); + try { + const {City} = require('../models/city'); + const {Province} = require('../models/province'); + const {Sector} = require('../models/sector'); + const {SectorGood} = require('../models/sectorgood'); + const {Skill} = require('../models/skill'); + const {Good} = require('../models/good'); + // const {SubSkill} = require('../models/subskill'); + const {Contribtype} = require('../models/contribtype'); + const {Level} = require('../models/level'); - if (table === 'cities') { - mytab = City; - field = 'comune'; - } else if (table === 'provinces') { - mytab = Province; - field = 'descr'; - } else if (table === 'sectors') { - mytab = Sector; - field = 'descr'; - } else if (table === 'skills') { - mytab = Skill; - field = 'descr'; - } else if (table === 'subskills') { - mytab = SubSkill; - field = 'descr'; - } else if (table === 'contribtypes') { - mytab = Contribtype; - field = 'label'; - } else if (table === 'levels') { - mytab = Level; - field = 'descr'; + if (table === 'cities') { + mytab = City; + field = 'comune'; + } else if (table === 'provinces') { + mytab = Province; + field = 'descr'; + } else if (table === 'sectors') { + mytab = Sector; + field = 'descr'; + } else if (table === 'sectorgoods') { + mytab = SectorGood; + field = 'descr'; + } else if (table === 'skills') { + mytab = Skill; + field = 'descr'; + } else if (table === 'goods') { + mytab = Good; + field = 'descr'; + //} else if (table === 'subskills') { + // mytab = SubSkill; + // field = 'descr'; + } else if (table === 'contribtypes') { + mytab = Contribtype; + field = 'label'; + } else if (table === 'levels') { + mytab = Level; + field = 'descr'; + } + + if (mytab) { + console.log('Delete ', table); + await mytab.deleteMany({}); + + await this.insertIntoDb_NoDuplicate(false, table, mytab, field); + } + return true; + } catch (e) { + console.error('Err: ' + e); } - - if (mytab) { - console.log('Delete ', table) - await mytab.deleteMany({}); - - await this.insertIntoDb_NoDuplicate(false, table, mytab, field) - } - - return true; - + return false; }, async popolaTabelleNuove() { const abilita = true; const scrivi_citta = false; + const scrivi_contribtype = false; let ris = null; try { + console.log('INIZIO - popolaTabelleNuove'); - console.log('INIZIO - popolaTabelleNuove') + for (const rec of shared_consts.TABLES_POPULATE_DATA) { + let mytable = globalTables.getTableByTableName(rec.table); - // Sectors - const {Sector} = require('../models/sector'); - await this.insertIntoDb_NoDuplicate(abilita, 'sectors', Sector, 'descr') + let attiva = abilita; + if (rec.table === 'cities' || rec.table === 'province') { + attiva = scrivi_citta; + } + if (rec.table === 'contribtypes') { + attiva = scrivi_contribtype; + } - // CatGrps - const {CatGrp} = require('../models/catgrp'); - await this.insertIntoDb_NoDuplicate(abilita, 'catgrps', CatGrp, 'descr') + await this.insertIntoDb_NoDuplicate(attiva, rec.table, mytable, rec.key); + } - // Skills (Competenze) - const {Skill} = require('../models/skill'); - await this.insertIntoDb_NoDuplicate(abilita, 'skills', Skill, 'descr') + console.log('FINE - popolaTabelleNuove'); - // SubSectors - const {SubSkill} = require('../models/subskill'); - await this.insertIntoDb_NoDuplicate(abilita, 'subskills', SubSkill, 'descr') - - // Levels - const {Level} = require('../models/level'); - await this.insertIntoDb_NoDuplicate(abilita, 'levels', Level, 'descr') - - // Status - const {StatusSkill} = require('../models/statusSkill'); - await this.insertIntoDb_NoDuplicate(abilita, 'statusskills', StatusSkill, 'descr') - - // Cities - const {City} = require('../models/city'); - await this.insertIntoDb_NoDuplicate(scrivi_citta, 'cities', City, 'comune') - - // Province - const {Province} = require('../models/province'); - await this.insertIntoDb_NoDuplicate(scrivi_citta, 'provinces', Province, 'descr') - - // Contribtypes - const {Contribtype} = require('../models/contribtype'); - await this.insertIntoDb_NoDuplicate(false, 'contribtypes', Contribtype, 'label') - - // AdTypes - const {AdType} = require('../models/adtype'); - await this.insertIntoDb_NoDuplicate(abilita, 'adtypes', AdType, 'descr') - - console.log('FINE - popolaTabelleNuove') - - }catch (e) { + return true; + } catch (e) { console.error('Err: ' + e); + return false; } }, diff --git a/src/server/populate/sectorgoods.js b/src/server/populate/sectorgoods.js new file mode 100644 index 0000000..553fb4c --- /dev/null +++ b/src/server/populate/sectorgoods.js @@ -0,0 +1,19 @@ +module.exports = { + list: [ + {_id: 1, descr: 'Abbigliamento'}, + {_id: 2, descr: 'Arredamento'}, + {_id: 3, descr: 'Auto e Moto'}, + {_id: 4, descr: 'Autoproduzione'}, + {_id: 5, descr: 'Bellezza e igiene'}, + {_id: 6, descr: 'Bimbi'}, + {_id: 7, descr: 'Cibo'}, + {_id: 8, descr: 'Collezionismo e Antiquariato'}, + {_id: 9, descr: 'Elettronica'}, + {_id: 10, descr: 'Giochi'}, + {_id: 11, descr: 'Hobby'}, + {_id: 12, descr: 'Libri'}, + {_id: 13, descr: 'Musica e film'}, + {_id: 14, descr: 'Scuola e ufficio'}, + {_id: 15, descr: 'Sport'}, + {_id: 16, descr: 'Un po\' di tutto'}], +}; diff --git a/src/server/populate/sectors.js b/src/server/populate/sectors.js index c45a8ae..5fdc211 100644 --- a/src/server/populate/sectors.js +++ b/src/server/populate/sectors.js @@ -1,31 +1,17 @@ module.exports = { list: [ - { - descr: 'Abitare', - }, - { - descr: 'Alimentazione', - }, - { - descr: 'Animali', - }, - { - descr: 'Arte e Cultura', - }, - { - descr: 'Benessere e Salute', - }, - { - descr: 'Servizi per la Casa', - }, - { - descr: 'Servizi per la Persona', - }, - { - descr: 'Tecnologia', - }, - { - descr: 'Turismo', - }, + {_id: 1, descr: 'Abitare'}, + {_id: 2, descr: 'Agricoltura'}, + {_id: 3, descr: 'Alimentazione'}, + {_id: 4, descr: 'Animali'}, + {_id: 5, descr: 'Auto e Veicoli'}, + {_id: 6, descr: 'Benessere'}, + {_id: 7, descr: 'Casa'}, + {_id: 8, descr: 'Intrattenimento'}, + {_id: 9, descr: 'Ospitalità'}, + {_id: 10, descr: 'Persona'}, + {_id: 11, descr: 'Progetti di Gruppo'}, + {_id: 12, descr: 'Salute'}, + {_id: 13, descr: 'Tecnologia'}, ], }; diff --git a/src/server/populate/skills.js b/src/server/populate/skills.js index 86f8a18..ead06ea 100644 --- a/src/server/populate/skills.js +++ b/src/server/populate/skills.js @@ -1,108 +1,106 @@ module.exports = { list: [ - {idSector: [1], descr: 'Arredamento'}, - {idSector: [1], descr: 'Costruzioni'}, - {idSector: [1], descr: 'Ecovillaggi / Comunità'}, - {idSector: [1], descr: 'Giardini'}, - {idSector: [1], descr: 'Impianti TV'}, - {idSector: [1], descr: 'Pozzi Acqua'}, - {idSector: [1], descr: 'Prodotti Casa'}, - {idSector: [1], descr: 'Pulizie'}, - {idSector: [1], descr: 'Restaurazioni'}, - {idSector: [1], descr: 'Riparazioni'}, - {idSector: [1], descr: 'Servizi Casa'}, - {idSector: [1], descr: 'Sgombero'}, - {idSector: [1], descr: 'Sicurezza'}, - {idSector: [2], descr: 'Agricoltura'}, - {idSector: [2], descr: 'Alimentari'}, - {idSector: [2], descr: 'Cucina'}, - {idSector: [2], descr: 'Altro'}, - {idSector: [2], descr: 'Autoproduzioni'}, - {idSector: [2], descr: 'Azienda Agricola'}, - {idSector: [3], descr: 'Dog sitter'}, - {idSector: [3], descr: 'Pet sitter'}, - {idSector: [3], descr: 'Toelettatura cani'}, - {idSector: [3], descr: 'Toelettatura gatti'}, - {idSector: [3], descr: 'Vendita prodotti'}, - {idSector: [3], descr: 'Cura degli animali'}, - {idSector: [3], descr: 'Veterinario'}, - {idSector: [4], descr: 'Ballo'}, - {idSector: [4], descr: 'Canto'}, - {idSector: [4], descr: 'Cinema'}, - {idSector: [4], descr: 'Fotografia'}, - {idSector: [4], descr: 'Letteratura'}, - {idSector: [4], descr: 'Musica'}, - {idSector: [4], descr: 'Pittura'}, - {idSector: [4], descr: 'Libri'}, - {idSector: [4], descr: 'Teatro'}, - {idSector: [4], descr: 'Moda'}, - {idSector: [5], descr: 'Benessere Corpo'}, - {idSector: [5], descr: 'Benessere Olistico'}, - {idSector: [5], descr: 'Centro Benessere'}, - {idSector: [5], descr: 'Gravidanza'}, - {idSector: [5], descr: 'Medicina Alternativa'}, - {idSector: [5], descr: 'Medicina Convenzionale'}, - {idSector: [5], descr: 'Pronto Soccorso'}, - {idSector: [5], descr: 'Operatore Olistico'}, - {idSector: [5], descr: 'Operatori Sanitari'}, - {idSector: [5], descr: 'Salute Corpo'}, - {idSector: [5], descr: 'Salute Globale'}, - {idSector: [5], descr: 'Salute Psiche'}, - {idSector: [5], descr: 'Servizi per la Persona'}, - {idSector: [5], descr: 'Strutture'}, - {idSector: [6], descr: 'Aspetti Burocratici'}, - {idSector: [6], descr: 'Elettricista'}, - {idSector: [6], descr: 'Fabbro e lavorazioni ferro/acciaio'}, - {idSector: [6], descr: 'Falegname'}, - {idSector: [6], descr: 'Frigorista'}, - {idSector: [6], descr: 'Giardiniere'}, - {idSector: [6], descr: 'Idraulico'}, - {idSector: [6], descr: 'Imbianchino'}, - {idSector: [6], descr: 'Impermeabilizzazioni'}, - {idSector: [6], descr: 'Installatore Linea Telefono e Modem'}, - {idSector: [6], descr: 'Installazioni'}, - {idSector: [6], descr: 'Restaurazione'}, - {idSector: [6], descr: 'Riparazioni Casa'}, - {idSector: [6], descr: 'Servizio Traslochi'}, - {idSector: [6], descr: 'Riscaldamento'}, - {idSector: [6], descr: 'Smontaggio e Montaggio'}, - {idSector: [6], descr: 'Strutturazioni e Riparazioni'}, - {idSector: [6], descr: 'Tuttofare'}, - {idSector: [6], descr: 'Vetraio'}, - {idSector: [7], descr: 'Abbigliamento'}, - {idSector: [7], descr: 'Assicurazioni'}, - {idSector: [7], descr: 'Assistenza Anziani'}, - {idSector: [7], descr: 'Assistenza Fiscale'}, - {idSector: [7], descr: 'Assistenza Legale'}, - {idSector: [7], descr: 'Assistenza Persone'}, - {idSector: [7], descr: 'Baby sitter'}, - {idSector: [7], descr: 'Corsi'}, - {idSector: [7], descr: 'Corsi per Bambini e Adolescenti'}, - {idSector: [7], descr: 'Finanza'}, - {idSector: [7], descr: 'Insegnante'}, - {idSector: [7], descr: 'Interprete e traduzioni'}, - {idSector: [7], descr: 'Educazione'}, - {idSector: [7], descr: 'Formazione'}, - {idSector: [7], descr: 'Gruppi di Acquisto'}, - {idSector: [7], descr: 'Banca del Tempo'}, - {idSector: [7], descr: 'Collabora con noi'}, - {idSector: [7], descr: 'Eventi'}, - {idSector: [7], descr: 'Laboratori'}, - {idSector: [7], descr: 'Idee'}, - {idSector: [7], descr: 'Progetti'}, - {idSector: [7], descr: 'Mobilità'}, - {idSector: [7], descr: 'Oggettistica'}, - {idSector: [7], descr: 'Solidarietà'}, - {idSector: [7], descr: 'Sport'}, - {idSector: [7], descr: 'Trasporti'}, - {idSector: [8], descr: 'Audio/Video'}, - {idSector: [8], descr: 'Biologia'}, - {idSector: [8], descr: 'Chimica'}, - {idSector: [8], descr: 'Informatica'}, - {idSector: [8], descr: 'Elettronica'}, - {idSector: [8], descr: 'Meccanica'}, - {idSector: [8], descr: 'Telefonia'}, - {idSector: [9], descr: 'Vacanze'}, - {idSector: [9], descr: 'Receptionist'} - ] -} + {_id: 1, idSector: [1], descr: 'Autocostruzione'}, + {_id: 2, idSector: [1], descr: 'Ecovillaggi / Comunità'}, + {_id: 3, idSector: [1], descr: 'Cohousing'}, + {_id: 4, idSector: [2], descr: 'Orto sinergico'}, + {_id: 5, idSector: [2], descr: 'Pacciamatura'}, + {_id: 6, idSector: [2], descr: 'Orto tradizionale'}, + {_id: 7, idSector: [2], descr: 'Permacultura'}, + {_id: 8, idSector: [2], descr: 'Cultura idroponica'}, + {_id: 9, idSector: [2], descr: 'Elettrocultura'}, + {_id: 10, idSector: [2], descr: 'Aratura + semina'}, + {_id: 11, idSector: [2], descr: 'Potatura'}, + {_id: 12, idSector: [2], descr: 'Raccolta'}, + {_id: 13, idSector: [3], descr: 'Preparazione cibi'}, + {_id: 14, idSector: [3], descr: 'Preparazione bevande'}, + {_id: 15, idSector: [3], descr: 'Autoproduzione alimenti e bevande'}, + {_id: 16, idSector: [4], descr: 'Servizi per Cani'}, + {_id: 17, idSector: [4], descr: 'Servizi per Gatti'}, + {_id: 18, idSector: [4], descr: 'Servizi per Anumali da allevamento'}, + {_id: 19, idSector: [4], descr: 'Veterinario'}, + {_id: 20, idSector: [5], descr: 'Riparazioni Auto'}, + {_id: 21, idSector: [5], descr: 'Riparazioni Moto'}, + {_id: 22, idSector: [5], descr: 'Riparazioni Camper / Van'}, + {_id: 23, idSector: [5], descr: 'Creazione di Van Camperizzati'}, + {_id: 24, idSector: [5], descr: 'Noleggio veicoli'}, + {_id: 25, idSector: [5], descr: 'Lavaggio auto'}, + {_id: 26, idSector: [6], descr: 'Alimentazione Naturale'}, + {_id: 27, idSector: [6], descr: 'Ginnastica'}, + {_id: 28, idSector: [6], descr: 'Yoga'}, + {_id: 29, idSector: [6], descr: 'Trattamenti Olistici'}, + {_id: 30, idSector: [6], descr: 'Meditazione e mindfulness'}, + {_id: 31, idSector: [6], descr: 'Trattamenti Energetici'}, + {_id: 32, idSector: [6], descr: 'Trattamenti Sonori'}, + {_id: 33, idSector: [6], descr: 'Arteterapia'}, + {_id: 34, idSector: [6], descr: 'Teatroterapia'}, + {_id: 35, idSector: [6], descr: 'Cantoterapia'}, + {_id: 36, idSector: [6], descr: 'Trattamenti Luminosi'}, + {_id: 37, idSector: [6], descr: 'Fitoterapia'}, + {_id: 38, idSector: [6], descr: 'Kinesiologia'}, + {_id: 39, idSector: [6], descr: 'Terapie Naturali'}, + {_id: 40, idSector: [7], descr: 'Muratore'}, + {_id: 41, idSector: [7], descr: 'Imbianchino'}, + {_id: 42, idSector: [7], descr: 'Elettricista - TV'}, + {_id: 43, idSector: [7], descr: 'Falegname e restauro'}, + {_id: 44, idSector: [7], descr: 'Fabbro'}, + {_id: 45, idSector: [7], descr: 'Arredamento'}, + {_id: 46, idSector: [7], descr: 'Idraulico'}, + {_id: 47, idSector: [7], descr: 'Giardiniere'}, + {_id: 48, idSector: [7], descr: 'Canne fumarie e camini e stufe'}, + {_id: 49, idSector: [7], descr: 'Pannelli solari e pompe calore'}, + {_id: 50, idSector: [7], descr: 'Riparazioni varie'}, + {_id: 51, idSector: [7], descr: 'Tuttofare'}, + {_id: 52, idSector: [7], descr: 'Traslochi'}, + {_id: 53, idSector: [7], descr: 'Piastrellista'}, + {_id: 54, idSector: [7], descr: 'Pulizie'}, + {_id: 55, idSector: [8], descr: 'Ballo'}, + {_id: 56, idSector: [8], descr: 'Canto'}, + {_id: 57, idSector: [8], descr: 'Musica'}, + {_id: 58, idSector: [8], descr: 'Letteratura e poesia'}, + {_id: 59, idSector: [8], descr: 'Teatro'}, + {_id: 60, idSector: [8], descr: 'Fotografia'}, + {_id: 61, idSector: [8], descr: 'Film making'}, + {_id: 62, idSector: [8], descr: 'Sport'}, + {_id: 63, idSector: [8], descr: 'Arte'}, + {_id: 64, idSector: [9], descr: 'Offresi Ospitalità'}, + {_id: 65, idSector: [9], descr: 'Affitto casa'}, + {_id: 66, idSector: [9], descr: 'Affittacamere'}, + {_id: 67, idSector: [9], descr: 'Affitto mini appartamento'}, + {_id: 68, idSector: [9], descr: 'Bed & Breakfast'}, + {_id: 69, idSector: [9], descr: 'Scambio Casa'}, + {_id: 70, idSector: [10], descr: 'Parrucchiere'}, + {_id: 71, idSector: [10], descr: 'Estetista'}, + {_id: 72, idSector: [10], descr: 'Omeopatia'}, + {_id: 73, idSector: [10], descr: 'Assistenza anziani'}, + {_id: 74, idSector: [10], descr: 'Contabile/commercialista'}, + {_id: 75, idSector: [10], descr: 'Avvocato'}, + {_id: 76, idSector: [10], descr: 'Baby sitter'}, + {_id: 77, idSector: [10], descr: 'Sarto'}, + {_id: 78, idSector: [10], descr: 'Autoproduzione prodotti persona'}, + {_id: 79, idSector: [10], descr: 'Corsi e Formazione'}, + {_id: 80, idSector: [10], descr: 'Supporto spesa'}, + {_id: 81, idSector: [10], descr: 'Volontariato'}, + {_id: 82, idSector: [11], descr: 'Gruppi di acquisto'}, + {_id: 83, idSector: [11], descr: 'Banca del tempo'}, + {_id: 84, idSector: [11], descr: 'Collabora con noi'}, + {_id: 85, idSector: [11], descr: 'Eventi'}, + {_id: 86, idSector: [11], descr: 'Laboratori'}, + {_id: 87, idSector: [11], descr: 'Idee e suggerimenti'}, + {_id: 88, idSector: [12], descr: 'Medico di base '}, + {_id: 89, idSector: [12], descr: 'Specialista'}, + {_id: 90, idSector: [12], descr: 'Pediatra'}, + {_id: 91, idSector: [12], descr: 'Dentista'}, + {_id: 92, idSector: [12], descr: 'Psicologo'}, + {_id: 93, idSector: [12], descr: 'Psicoterapeuta'}, + {_id: 94, idSector: [12], descr: 'Ostetrica'}, + {_id: 95, idSector: [12], descr: 'Nutrizionista'}, + {_id: 96, idSector: [12], descr: 'Naturopata'}, + {_id: 97, idSector: [12], descr: 'Counseling'}, + {_id: 98, idSector: [13], descr: 'Assistenza PC / software'}, + {_id: 99, idSector: [13], descr: 'Assistenza Cellulari'}, + {_id: 100, idSector: [13], descr: 'Realizzazione Siti web'}, + {_id: 101, idSector: [13], descr: 'Realizzazione App / Piattaforme'}, + {_id: 102, idSector: [13], descr: 'Corsi d\'Informatica'}, + {_id: 103, idSector: [13], descr: 'Riparazione Elettrodomestici'}], +}; diff --git a/src/server/populate/statusSkills.js b/src/server/populate/statusSkills.js new file mode 100644 index 0000000..888f49f --- /dev/null +++ b/src/server/populate/statusSkills.js @@ -0,0 +1,6 @@ +module.exports = { + list: [ + {_id: 1, descr: 'Di Persona', icon:'fas fa-people-carry' }, + {_id: 2, descr: 'On Line', icon:'fas fa-desktop'}, + ], +}; diff --git a/src/server/populate/statusskills.js b/src/server/populate/statusskills.js deleted file mode 100644 index 09939cc..0000000 --- a/src/server/populate/statusskills.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - list: [ - {_id: 1, descr: 'Di Persona'}, - {_id: 2, descr: 'On Line'}, - ], -}; diff --git a/src/server/router/index_router.js b/src/server/router/index_router.js index 221fb9f..9d3a678 100755 --- a/src/server/router/index_router.js +++ b/src/server/router/index_router.js @@ -46,15 +46,19 @@ const {Contribtype} = require('../models/contribtype'); const {PaymentType} = require('../models/paymenttype'); const {Discipline} = require('../models/discipline'); const {Skill} = require('../models/skill'); +const {Good} = require('../models/good'); const {SubSkill} = require('../models/subskill'); const {MySkill} = require('../models/myskill'); +const {MyGood} = require('../models/mygood'); const {StatusSkill} = require('../models/statusSkill'); const {City} = require('../models/city'); const {Province} = require('../models/province'); const {Sector} = require('../models/sector'); +const {SectorGood} = require('../models/sectorgood'); const {CatGrp} = require('../models/catgrp'); const {Level} = require('../models/level'); const {AdType} = require('../models/adtype'); +const {AdTypeGood} = require('../models/adtypegood'); const Pickup = require('../models/pickup'); const {Newstosent} = require('../models/newstosent'); const {MyPage} = require('../models/mypage'); @@ -1021,10 +1025,13 @@ function load(req, res, version) { // SKILLS: let levels = Level.findAllIdApp(idapp); let adtypes = AdType.findAllIdApp(idapp); + let adtypegoods = AdTypeGood.findAllIdApp(idapp); let skills = Skill.findAllIdApp(idapp); - let subSkills = SubSkill.findAllIdApp(idapp); + let goods = Good.findAllIdApp(idapp); + //let subSkills = SubSkill.findAllIdApp(idapp); let statusSkills = StatusSkill.findAllIdApp(idapp); let sectors = Sector.findAllIdApp(idapp); + let sectorgoods = SectorGood.findAllIdApp(idapp); let catgrps = CatGrp.findAllIdApp(idapp); let cities = City.findAllIdApp(idapp); let cart = null; @@ -1078,19 +1085,22 @@ function load(req, res, version) { internalpages, levels, skills, - subSkills, + //subSkills, + myuserextra, sectors, statusSkills, cities, - myuserextra, catgrps, adtypes, + adtypegoods, + sectorgoods, + goods, ]).then((arrdata) => { // console.table(arrdata); let myuser = req.user; if (myuser) { try { - myuser = arrdata[30]; + myuser = arrdata[26]; if (myuser) { myuser.password = ''; myuser._doc.calcstat = arrdata[13]; @@ -1152,13 +1162,16 @@ function load(req, res, version) { internalpages: arrdata[23], levels: arrdata[24], skills: arrdata[25], - subSkills: arrdata[26], + // subSkills: arrdata[26], + // myuser arrdata[26] sectors: arrdata[27], statusSkills: arrdata[28], cities: arrdata[29], - // myuser arrdata[30] - catgrps: arrdata[31], - adtypes: arrdata[32], + catgrps: arrdata[30], + adtypes: arrdata[31], + adtypegoods: arrdata[32], + sectorgoods: arrdata[33], + goods: arrdata[34], }); } diff --git a/src/server/router/mygoods_router.js b/src/server/router/mygoods_router.js new file mode 100755 index 0000000..00e5554 --- /dev/null +++ b/src/server/router/mygoods_router.js @@ -0,0 +1,50 @@ +const shared_consts = require('../tools/shared_nodejs'); + +const express = require('express'); +const router = express.Router(); + +const tools = require('../tools/general'); + +var server_constants = require('../tools/server_constants'); + +var {authenticate, auth_default} = require('../middleware/authenticate'); + +var mongoose = require('mongoose').set('debug', false); +const Subscription = mongoose.model('subscribers'); + +const _ = require('lodash'); +const {MyGood} = require('../models/mygood'); +var {User} = require('../models/user'); + +const {ObjectID} = require('mongodb'); + +//GET orders +router.post('/page', authenticate, function(req, res, next) { + let idGood = req.body.idGood; + let idapp = req.body.idapp; + + return MyGood.getMyGoodByIdkill(idapp, idGood). + then((ris) => { + + if (ris) { + res.send(ris); + /* + const userId = ris.userId; + return User.getUsernameById(idapp, userId).then((username) => + { + res.send({...ris, username}); + }); + */ + + } else { + res.status(400).send(); + } + }).catch((e) => { + console.error('Err', e); + res.status(400).send(e); + }) + + +}); + +module.exports = router; diff --git a/src/server/router/users_router.js b/src/server/router/users_router.js index 58e1efe..fb1381d 100755 --- a/src/server/router/users_router.js +++ b/src/server/router/users_router.js @@ -872,15 +872,15 @@ async function eseguiDbOp(idapp, mydata, locale) { */ } else if (mydata.dbop === 'CorreggiTabHours') { - await Hours.correggiHours(idapp); + ris = await Hours.correggiHours(idapp); } else if (mydata.dbop === 'setVerifiedByAportadorToALL') { - await User.setVerifiedByAportadorToALL(); + ris = await User.setVerifiedByAportadorToALL(); } else if (mydata.dbop === 'RewriteContribType') { - populate.rewriteTable('contribtypes'); + ris = populate.rewriteTable('contribtypes'); } else if (mydata.dbop === 'copyFrom1To13') { const idapporig = 1; @@ -906,27 +906,50 @@ async function eseguiDbOp(idapp, mydata, locale) { numrectot += numrec; }); } + + ris = numrectot; + } catch (e) { console.log('e', e); } + } else if (mydata.dbop === 'emptyTabCatServiziBeni') { + + const {Sector} = require('../models/sector'); + const {SectorGood} = require('../models/sectorgood'); + const {Skill} = require('../models/skill'); + const {Good} = require('../models/good'); + + await Sector.deleteMany({}); + await SectorGood.deleteMany({}); + await Skill.deleteMany({}); + ris = await Good.deleteMany({}); + } else if (mydata.dbop === 'emptyDbSkill') { // Svuota e Ricrea const {Sector} = require('../models/sector'); + const {SectorGood} = require('../models/sectorgood'); const {Skill} = require('../models/skill'); + const {Good} = require('../models/good'); const {SubSkill} = require('../models/subskill'); const {Contribtype} = require('../models/contribtype'); const {AdType} = require('../models/adtype'); + const {AdTypeGood} = require('../models/adtypegood'); + const {StatusSkill} = require('../models/statusSkill'); await Sector.deleteMany({}); + await SectorGood.deleteMany({}); await Skill.deleteMany({}); + await Good.deleteMany({}); await SubSkill.deleteMany({}); await Contribtype.deleteMany({}); await AdType.deleteMany({}); + await AdTypeGood.deleteMany({}); + await StatusSkill.deleteMany({}); - await populate.popolaTabelleNuove(); + ris = await populate.popolaTabelleNuove(); } else if (mydata.dbop === 'ricreaTabCitiesProvinces') { @@ -938,22 +961,22 @@ async function eseguiDbOp(idapp, mydata, locale) { await City.deleteMany({}); await Province.deleteMany({}); - await populate.popolaTabelleNuove(); + ris = await populate.popolaTabelleNuove(); } else if (mydata.dbop === 'PopulateTables') { - populate.popolaTabelleNuove(); + ris = populate.popolaTabelleNuove(); } else if (mydata.dbop === 'RewriteCitiesTable') { - populate.rewriteTable('cities'); - } else if (mydata.dbop === 'RewriteLevelTable') { - - populate.rewriteTable('levels'); - + ris = populate.rewriteTable('cities'); } else if (mydata.dbop === 'RewriteLevelsTable') { - populate.rewriteTable('provinces'); + ris = populate.rewriteTable('levels'); + + } else if (mydata.dbop === 'RewriteProvincesTable') { + + ris = populate.rewriteTable('provinces'); } else if (mydata.dbop === 'emptyCityProvinces') { @@ -1005,9 +1028,17 @@ router.post('/dbop', authenticate, async (req, res) => { idapp = req.body.idapp; locale = req.body.locale; - const ris = await eseguiDbOp(idapp, mydata, locale); + try{ + const ris = await eseguiDbOp(idapp, mydata, locale); - res.send(ris); + res.send(ris); + + } catch (e) { + res.status(400).send(); + res.send({code: server_constants.RIS_CODE_ERR, msg: e}); + + console.log(e.message); + } }); diff --git a/src/server/server.js b/src/server/server.js index 8f994db..d421aae 100755 --- a/src/server/server.js +++ b/src/server/server.js @@ -104,6 +104,7 @@ myLoad().then(ris => { const cart_router = require('./router/cart_router'); const orders_router = require('./router/orders_router'); const myskills_router = require('./router/myskills_router'); + const mygoods_router = require('./router/mygoods_router'); const mygen_router = require('./router/mygen_router'); const { MyEvent } = require('./models/myevent'); @@ -159,6 +160,7 @@ myLoad().then(ris => { app.use('/cart', cart_router); app.use('/orders', orders_router); app.use('/myskills', myskills_router); + app.use('/mygoods', mygoods_router); app.use('/mygen', mygen_router); // catch 404 and forward to error handler diff --git a/src/server/telegram/telegrambot.js b/src/server/telegram/telegrambot.js index 7d11b4e..e54d737 100755 --- a/src/server/telegram/telegrambot.js +++ b/src/server/telegram/telegrambot.js @@ -130,6 +130,13 @@ MsgBot = { 'grazie 😘', 'grazie😘'], PRINCIPE_AZZURRO: ['principe azzurro'], + COSE_COVID: [ + 'cos\'è il covid', + 'cosa è il covid', + ], + COVID: [ + 'covid', + ], SPOSAMI: [ 'sposami', 'vuoi sposar', @@ -158,6 +165,7 @@ MsgBot = { 'conferenz', 'zoom'], LAVAGNA: ['lavagna', 'Lavagna', 'LAVAGNA'], + SEI_LIBERO_DI_RESPIRARE: ['sei libero di respirare'], SEI_LIBERO: ['sei liber', 'sei sposat', 'sei fidanzat', 'sei single'], AIUTO: [ 'help', @@ -1544,6 +1552,14 @@ class Telegram { } else if (MsgBot.PRINCIPE_AZZURRO.find( (rec) => testo.indexOf(rec) > -1)) { risp = 'Chissà... Forse si!\nAnche se meglio averne un altro di scorta, nel caso il Principe non sia disponibile.'; + } else if (MsgBot.COSE_COVID.find( + (rec) => testo.indexOf(rec) > -1)) { + risp = 'Un \'influenza più "grave", dovuta a paure e a fattori interiori di evoluzione, oltre ad una pulizia del corpo. '; + } else if (MsgBot.COVID.find( + (rec) => testo.indexOf(rec) > -1)) { + risp = 'Guarda, è meglio che sorvoliamo questo argomento. Anche un robot capisce che è stato realizzato ' + + 'il più grande esperimento dell\'Uomo di ipnosi di massa, riempiendo di bugie i media mondiali, che servono sostanzialmente a controllare i popoli.' + + 'E con questo ti ho detto tutto. :D '; } else if (MsgBot.AIUTO.find((rec) => testo.indexOf(rec) > -1)) { risp = 'Clicca qui per entrare nella Chat HELP di Supporto\n' + tools.HELP_CHAT + @@ -1559,6 +1575,8 @@ class Telegram { } else if (MsgBot.SEI_LIBERO.find((rec) => testo.indexOf(rec) > -1)) { risp = 'Io? Sono per la Libertà! ' + emo.JOY + '\nMa se vuoi possiamo conoscerci meglio!' + emo.DANCER + emo.FIRE; + } else if (MsgBot.SEI_LIBERO_DI_RESPIRARE.find((rec) => testo.indexOf(rec) > -1)) { + risp = 'Assolutamente Sì ! Respirare è fondamentale per l\'essere umano !' + emo.DANCER + emo.FIRE; } else if (MsgBot.FARE_DOMANDA.find((rec) => testo.indexOf(rec) > -1)) { risp = 'Dipende ' + emo.SMILE_STAR + '\nProvaci!'; } else if (MsgBot.DIVENTERO_RICCA.find( diff --git a/src/server/tools/general.js b/src/server/tools/general.js index 6dfbb45..cb4f2c8 100755 --- a/src/server/tools/general.js +++ b/src/server/tools/general.js @@ -64,7 +64,7 @@ const textlang = { 'partecipanti a Cena Condivisa': 'partecipanti a Cena Condivisa', 'TESTO_ASSISTENZA': '👉 Per entrare nel Sito\n\n' + '👉 Hai dimenticato la password?\n\n', - 'BENVENUTO': 'Benvenuto', + 'BENVENUTO': 'Benvenut@', 'TUE_NAVI': 'Ecco le tue Navi programmate', 'HAI_I_7_REQUISITI': 'PRIMI PASSI OK!\nHai i Primi Requisiti per Entrare nella Lista !', 'NON_HAI_I_7_REQUISITI': 'Attenzione!\nAncora non hai i 7 Requisiti per Entrare nella Lista !', diff --git a/src/server/tools/globalTables.js b/src/server/tools/globalTables.js index b119ace..9e31be0 100755 --- a/src/server/tools/globalTables.js +++ b/src/server/tools/globalTables.js @@ -20,16 +20,20 @@ const {Contribtype} = require('../models/contribtype'); const {PaymentType} = require('../models/paymenttype'); const {Discipline} = require('../models/discipline'); const {Skill} = require('../models/skill'); +const {Good} = require('../models/good'); const {SubSkill} = require('../models/subskill'); const {MySkill} = require('../models/myskill'); +const {MyGood} = require('../models/mygood'); const {MyBacheca} = require('../models/mybacheca'); const {StatusSkill} = require('../models/statusSkill'); const {City} = require('../models/city'); const {Province} = require('../models/province'); const {Sector} = require('../models/sector'); +const {SectorGood} = require('../models/sectorgood'); const {CatGrp} = require('../models/catgrp'); const {Level} = require('../models/level'); const {AdType} = require('../models/adtype'); +const {AdTypeGood} = require('../models/adtypegood'); const Pickup = require('../models/pickup'); const {Newstosent} = require('../models/newstosent'); const {MyPage} = require('../models/mypage'); @@ -155,12 +159,16 @@ module.exports = { mytable = Graduatoria; else if (tablename === 'skills') mytable = Skill; + else if (tablename === 'goods') + mytable = Good; else if (tablename === 'subskills') mytable = SubSkill; else if (tablename === shared_consts.TABLES_MYSKILLS) mytable = MySkill; else if (tablename === shared_consts.TABLES_MYBACHECAS) mytable = MyBacheca; + else if (tablename === shared_consts.TABLES_MYGOODS) + mytable = MyGood; else if (tablename === 'statusSkills') mytable = StatusSkill; else if (tablename === 'cities') @@ -169,10 +177,16 @@ module.exports = { mytable = Province; else if (tablename === 'sectors') mytable = Sector; + else if (tablename === 'sectorgoods') + mytable = SectorGood; else if (tablename === 'catgrps') mytable = CatGrp; else if (tablename === 'levels') mytable = Level; + else if (tablename === 'adtypes') + mytable = AdType; + else if (tablename === 'adtypegoods') + mytable = AdTypeGood; else if (shared_consts.TablePickup.includes(tablename)) mytable = Pickup; //else if (shared_consts.TableCities.includes(tablename)) diff --git a/src/server/tools/shared_nodejs.js b/src/server/tools/shared_nodejs.js index f3d4fa3..cfd9a2b 100755 --- a/src/server/tools/shared_nodejs.js +++ b/src/server/tools/shared_nodejs.js @@ -32,9 +32,9 @@ module.exports = { FILTER_MEMBERSHIP_CARD_OK: 1048576, FILTER_USER_NO_VERIFIED_APORTADOR: 2097152, - FILTER_MYSKILL_SKILL: 1, - OPTIONS_SEARCH_ONLY_FULL_WORDS: 1, + OPTIONS_SEARCH_USER_ONLY_FULL_WORDS: 2, + OPTIONS_SEARCH_USER_ALL_WORDS: 4, FRIENDSCMD: { SETTRUST: 121, @@ -80,29 +80,69 @@ module.exports = { 'Nessuno', 'Bonifico Bancario', 'Paypal', - 'In Contanti alla CNM' + 'In Contanti alla CNM', ], PARAM_SHOW_PROVINCE: 1, TABLES_MYSKILLS: 'myskills', TABLES_MYBACHECAS: 'mybachecas', + TABLES_MYGOODS: 'mygoods', TABLES_ENABLE_GETREC_BYID: ['mybachecas'], TABLES_USER_INCLUDE_MY: ['mygroups'], - TABLES_GETCOMPLETEREC: ['myskills', 'mybachecas'], - TABLES_PERM_NEWREC: ['skills', 'subskills', 'mygroups'], + TABLES_GETCOMPLETEREC: ['myskills', 'mybachecas', 'mygoods'], + TABLES_PERM_NEWREC: ['skills', 'goods', 'subskills', 'mygroups'], + TABLES_REC_ID: ['skills', 'goods', 'subskills'], - TABLES_ID_NUMBER: ['permissions', 'levels', 'adtypes', 'statusSkills', 'sectors', 'catgrps', 'skills', 'subskills', 'cities', 'provinces', 'myskills', 'mybachecas', 'mygroups'], - TABLES_USER_ID: ['myskills', 'mybachecas'], - TABLES_UPDATE_LASTMODIFIED: ['myskills', 'mybachecas', 'mybots'], - TABLES_FINDER: ['myskills', 'mybachecas', 'mygroups'], + TABLES_ID_NUMBER: [ + 'permissions', + 'levels', + 'adtypes', + 'adtypegoods', + 'statusSkills', + 'sectors', + 'sectorgoods', + 'catgrps', + 'skills', + 'subskills', + 'cities', + 'provinces', + 'myskills', + 'mybachecas', + 'mygoods', + 'mygroups'], + TABLES_USER_ID: ['myskills', 'mybachecas', 'mygoods'], + TABLES_UPDATE_LASTMODIFIED: ['myskills', 'mybachecas', 'mygoods', 'mybots'], + TABLES_FINDER: ['myskills', 'mybachecas', 'mygoods', 'mygroups'], + TABLES_VISU_CMYSRECCARD: ['myskills', 'mybachecas', 'mygoods'], - TABLES_PERM_CHANGE_FOR_USERS: ['myskills', 'mybachecas'], - TABLES_VISU_LISTA_USER: ['myskills', 'mybachecas', 'users'], - TABLES_NOT_SHOW_IF_USERNAME: ['myskills', 'mybachecas'], + TABLES_PERM_CHANGE_FOR_USERS: ['myskills', 'mybachecas', 'mygoods'], + TABLES_VISU_LISTA_USER: ['myskills', 'mybachecas', 'mygoods', 'users'], + TABLES_POPULATE_DATA: [ + { + table: 'adtypegoods', + key: 'descr', + }, { + table: 'adtypes', + key: 'descr', + }, + {table: 'catgrps', key: 'descr'}, + { + table: 'contribtypes', + key: 'descr', + }, + {table: 'goods', key: 'descr'}, + {table: 'levels', key: 'descr'}, + {table: 'cities', key: 'comune'}, + {table: 'provinces', key: 'descr'}, + {table: 'sectorgoods', key: 'descr'}, + {table: 'sectors', key: 'descr'}, + {table: 'skills', key: 'descr'}, + {table: 'statusSkills', key: 'descr'}, + ], VISIB_ALL: 0, VISIB_ONLYIF_VERIFIED: 1, @@ -144,7 +184,7 @@ module.exports = { MessageOptions: { Notify_ByEmail: 2, - Notify_ByPushNotification: 4 + Notify_ByPushNotification: 4, }, TypeMsg: { @@ -153,7 +193,7 @@ module.exports = { SEND_TO_SOCIO_RESIDENTE: 3, SEND_TO_CONSIGLIO: 5, SEND_TO_NON_SOCI: 10, - SEND_TO_PAOLO: 20 + SEND_TO_PAOLO: 20, }, TypeMsg_Actions: { @@ -170,7 +210,7 @@ module.exports = { GET_VALBYTABLE: 400, SET_VALBYTABLE: 410, ZOOM_GIA_PARTECIPATO: 510, - REGISTRATION: 6 + REGISTRATION: 6, }, OrderStatus: { @@ -189,12 +229,34 @@ module.exports = { ORDER_CONFIRMED: 3, PAYED: 4, RECEIVED: 6, - CANCELED: 10 + CANCELED: 10, }, - fieldsUserToChange() { - return ['_id', 'index', 'username', 'group', 'email', 'name', 'surname', 'perm', 'date_reg', 'verified_email', 'verified_by_aportador', 'ipaddr', 'lasttimeonline', 'profile', 'calcstat', 'news_on', 'aportador_solidario', 'made_gift', 'ind_order', 'old_order', 'numinvitati', 'numinvitatiattivi', 'qualified'] - } + return [ + '_id', + 'index', + 'username', + 'group', + 'email', + 'name', + 'surname', + 'perm', + 'date_reg', + 'verified_email', + 'verified_by_aportador', + 'ipaddr', + 'lasttimeonline', + 'profile', + 'calcstat', + 'news_on', + 'aportador_solidario', + 'made_gift', + 'ind_order', + 'old_order', + 'numinvitati', + 'numinvitatiattivi', + 'qualified']; + }, };