- Aggiunto bottone Aggiungi al Carrello sulla lista dei libri dei cataloghi

This commit is contained in:
Surya Paolo
2025-06-06 00:07:53 +02:00
parent 28a4fe1952
commit f88f433003
11 changed files with 1661 additions and 1511 deletions

View File

@@ -58,9 +58,6 @@ const CatalogSchema = new Schema({
idPageAssigned: {
type: String,
},
idPageAssigned_stampa: {
type: String,
},
referenti: [
{
type: String,
@@ -169,7 +166,6 @@ CatalogSchema.statics.executeQueryTable = function (idapp, params, user) {
};*/
CatalogSchema.statics.findAllIdApp = async function (idapp) {
try {
const arrrec = await this.aggregate([
{ $match: { idapp } },
@@ -182,7 +178,6 @@ CatalogSchema.statics.findAllIdApp = async function (idapp) {
console.error('Errore:', err);
throw err;
}
};
CatalogSchema.statics.getCatalogById = async function (id) {
@@ -249,7 +244,15 @@ CatalogSchema.statics.getCatalogById = async function (id) {
// controlla prima se nella lista ci sono dei product che non esistono piu allora li devi rimuovere !
for (const catalog of arrrec) {
const originalLength = catalog.lista_prodotti.length;
catalog.lista_prodotti = catalog.lista_prodotti.filter((product) => product.idProductInfo);
catalog.lista_prodotti = catalog.lista_prodotti.filter(
(product) =>
product.idProductInfo &&
product.idProductInfo.code &&
product.idProductInfo.code !== '' &&
product.idProductInfo.imagefile &&
//product.idProductInfo.imagefile !== 'noimg.jpg' &&
!product.delete
);
if (catalog.lista_prodotti.length !== originalLength) {
await catalog.save();
}

View File

@@ -29,7 +29,7 @@ const productSchema = new Schema({
idapp: {
type: String,
},
delete: {
deleted: {
type: Boolean,
},
active: {
@@ -610,7 +610,12 @@ module.exports.findAllIdApp = async function (idapp, code, id, all, isbn) {
},
},
{ $unwind: { path: '$productInfo', preserveNullAndEmptyArrays: true } },
{
$match: {
'productInfo.code': { $exists: true, $ne: '' },
//'productInfo.imagefile': { $ne: 'noimg.jpg' },
},
},
{
$lookup: {
from: 'gasordines',

View File

@@ -16,7 +16,7 @@ const productInfoSchema = new Schema({
idapp: {
type: String,
},
delete: {
deleted: {
type: Boolean,
},
department: {
@@ -212,8 +212,8 @@ module.exports.findAllIdApp = async function (idapp, code, id) {
myfind = {
idapp,
$or: [
{ delete: { $exists: false } },
{ delete: false }
{ deleted: { $exists: false } },
{ deleted: false }
]
};
@@ -550,14 +550,14 @@ module.exports.removeProductInfoWithoutDateUpdatedFromGM = async function (idapp
if (Product) {
await Product.updateMany(
{ idProductInfo: productinfo._id },
{ $set: { delete: true } }
{ $set: { deleted: true } }
);
}
// Ora rimuovi anche questo productInfo
await ProductInfo.updateOne(
{ _id: productinfo._id },
{ $set: { delete: true } }
{ $set: { deleted: true } }
);
}
}

View File

@@ -31,9 +31,6 @@ const RaccoltaCataloghiSchema = new Schema({
idPageAssigned: {
type: String,
},
idPageAssigned_stampa: {
type: String,
},
nomefile_da_generare: String,

View File

@@ -0,0 +1,62 @@
const mongoose = require('mongoose');
const { Schema } = mongoose;
mongoose.Promise = global.Promise;
mongoose.level = "F";
/**
* @typedef {Object} T_Web_Argomenti
* @property {bigint} Id
* @property {number} IdArgomento
* @property {string} Descrizione
* @property {Date} DataOra
* @property {boolean} Enabled
* @property {boolean} EnabledAlFresco
*/
const T_Web_ArgomentiSchema = new Schema({
IdArgomento: Number,
Descrizione: { type: String },
DataOra: Date,
Enabled: Boolean,
EnabledAlFresco: Boolean
}, { collection: 't_web_argomentis' });
const T_Web_Argomenti = module.exports = mongoose.model('T_Web_Argomenti', T_Web_ArgomentiSchema);
module.exports.findAllIdApp = async function () {
const myfind = {};
const myquery = [
{
$sort: { IdTipologia: 1, DataOra: -1 } // ordina per ID e DataOra decrescente
},
{
$group: {
_id: "$IdTipologia",
IdTipologia: { $first: "$IdTipologia" },
Descrizione: { $first: "$Descrizione" },
DataOra: { $first: "$DataOra" },
// aggiungi altri campi se servono
}
},
{
$sort: { IdTipologia: 1 } // opzionale, per ordinare il risultato
},
{
$project: {
_id: 0,
IdTipologia: 1,
Descrizione: 1
}
},
];
const rec = await T_Web_Argomenti.aggregate(myquery);
return rec;
};