明树Git Lab

Commit cd3d8a75 authored by zfp1's avatar zfp1

update

parent 0b9cdcf3
...@@ -5,11 +5,11 @@ async function createDeepPlant(req, res, next) { ...@@ -5,11 +5,11 @@ async function createDeepPlant(req, res, next) {
const body = req.body; const body = req.body;
let count = await DB.ProductDeep.countDocuments(); //没有真实删除 永远递增 let count = await DB.ProductDeep.countDocuments(); //没有真实删除 永远递增
body.productNumber = count; body.productNumber = count;
body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o}); // body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o});
body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o}); // body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
body.productPhotos2 = (body.productPhotos2 || []).map(o => {return o && o._id || o}); body.productPhotos2 = (body.productPhotos2 || []).map(o => {return o && o._id || o});
body.homepageCarouselImgs = (body.homepageCarouselImgs || []).map(o => {return o && o._id || o}); body.homepageCarouselImgs = (body.homepageCarouselImgs || []).map(o => {return o && o._id || o});
body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o}); // body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
let ret = await DB.ProductDeep.create(body); let ret = await DB.ProductDeep.create(body);
res.sendData(ret); res.sendData(ret);
} catch (error) { } catch (error) {
...@@ -26,7 +26,7 @@ async function listDeepPlant(req, res, next) { ...@@ -26,7 +26,7 @@ async function listDeepPlant(req, res, next) {
search.preProductName = {$regex: req.body.name} search.preProductName = {$regex: req.body.name}
} }
const count = await DB.ProductDeep.countDocuments(search); const count = await DB.ProductDeep.countDocuments(search);
let list = await DB.ProductDeep.find(search).populate({path: "productPhotos2"}).populate({path: "qualityInsReportImgs"}).populate({path: "flourMerchantImgs"}).populate({path: "pesticidetImgs"}).populate({path: "homepageCarouselImgs"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec(); let list = await DB.ProductDeep.find(search).populate({path: "productPhotos2"}).populate({path: "homepageCarouselImgs"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec();
res.sendData({ count, list }); res.sendData({ count, list });
} catch (error) { } catch (error) {
next(error); next(error);
...@@ -49,11 +49,11 @@ async function updateDeepPlant(req, res, next) { ...@@ -49,11 +49,11 @@ async function updateDeepPlant(req, res, next) {
return res.sendError(errorMessage.resourceNotFound); return res.sendError(errorMessage.resourceNotFound);
} }
let body = req.body; let body = req.body;
body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o}); // body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o});
body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o}); // body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
body.productPhotos2 = (body.productPhotos2 || []).map(o => {return o && o._id || o}); body.productPhotos2 = (body.productPhotos2 || []).map(o => {return o && o._id || o});
body.homepageCarouselImgs = (body.homepageCarouselImgs || []).map(o => {return o && o._id || o}); body.homepageCarouselImgs = (body.homepageCarouselImgs || []).map(o => {return o && o._id || o});
body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o}); // body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
let upInfo = { let upInfo = {
...body, ...body,
_id: undefined, _id: undefined,
......
...@@ -5,11 +5,11 @@ async function createDirectPlant(req, res, next) { ...@@ -5,11 +5,11 @@ async function createDirectPlant(req, res, next) {
const body = req.body; const body = req.body;
let count = await DB.ProductPlant.countDocuments(); //没有真实删除 永远递增 let count = await DB.ProductPlant.countDocuments(); //没有真实删除 永远递增
body.productNumber = count; body.productNumber = count;
body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o}); // body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o});
body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o}); // body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
// body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
body.homepageCarouselImgs = (body.homepageCarouselImgs || []).map(o => {return o && o._id || o}); body.homepageCarouselImgs = (body.homepageCarouselImgs || []).map(o => {return o && o._id || o});
body.productPhotos2 = (body.productPhotos2 || []).map(o => {return o && o._id || o}); body.productPhotos2 = (body.productPhotos2 || []).map(o => {return o && o._id || o});
body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
let ret = await DB.ProductPlant.create(body); let ret = await DB.ProductPlant.create(body);
res.sendData(ret); res.sendData(ret);
} catch (error) { } catch (error) {
...@@ -27,7 +27,7 @@ async function listDirectPlant(req, res, next) { ...@@ -27,7 +27,7 @@ async function listDirectPlant(req, res, next) {
} }
const count = await DB.ProductPlant.countDocuments(search); const count = await DB.ProductPlant.countDocuments(search);
let list = await DB.ProductPlant.find(search).populate({path: "plantPlan"}).populate({path: "pesticidetImgs"}).populate({path: "homepageCarouselImgs"}).populate({path: "productPhotos2"}).populate({path: "qualityInsReportImgs"}).populate({path: "flourMerchantImgs"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec(); let list = await DB.ProductPlant.find(search).populate({path: "plantPlan"}).populate({path: "homepageCarouselImgs"}).populate({path: "productPhotos2"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec();
res.sendData({ count, list }); res.sendData({ count, list });
} catch (error) { } catch (error) {
next(error); next(error);
...@@ -50,11 +50,11 @@ async function updateDirectPlant(req, res, next) { ...@@ -50,11 +50,11 @@ async function updateDirectPlant(req, res, next) {
return res.sendError(errorMessage.resourceNotFound); return res.sendError(errorMessage.resourceNotFound);
} }
let body = req.body; let body = req.body;
body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o}); // body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o});
body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o}); // body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
// body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
body.homepageCarouselImgs = (body.homepageCarouselImgs || []).map(o => {return o && o._id || o}); body.homepageCarouselImgs = (body.homepageCarouselImgs || []).map(o => {return o && o._id || o});
body.productPhotos2 = (body.productPhotos2 || []).map(o => {return o && o._id || o}); body.productPhotos2 = (body.productPhotos2 || []).map(o => {return o && o._id || o});
body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
let upInfo = { let upInfo = {
...body, ...body,
_id: undefined, _id: undefined,
......
...@@ -6,9 +6,9 @@ async function createPrePlant(req, res, next) { ...@@ -6,9 +6,9 @@ async function createPrePlant(req, res, next) {
const body = req.body; const body = req.body;
let count = await DB.ProductPre.countDocuments(); //没有真实删除 永远递增 let count = await DB.ProductPre.countDocuments(); //没有真实删除 永远递增
body.productNumber = count; body.productNumber = count;
body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o}); // body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o});
body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o}); // body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o}); // body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
body.homepageCarouselImgs = (body.homepageCarouselImgs || []).map(o => {return o && o._id || o}); body.homepageCarouselImgs = (body.homepageCarouselImgs || []).map(o => {return o && o._id || o});
body.productPhotos2 = (body.productPhotos2 || []).map(o => {return o && o._id || o}); body.productPhotos2 = (body.productPhotos2 || []).map(o => {return o && o._id || o});
let ret = await DB.ProductPre.create(body); let ret = await DB.ProductPre.create(body);
...@@ -27,7 +27,7 @@ async function listPrePlant(req, res, next) { ...@@ -27,7 +27,7 @@ async function listPrePlant(req, res, next) {
search.preProductName = {$regex: req.body.name} search.preProductName = {$regex: req.body.name}
} }
const count = await DB.ProductPre.countDocuments(search); const count = await DB.ProductPre.countDocuments(search);
let list = await DB.ProductPre.find(search).populate({path: "productPhotos2"}).populate({path: "sourcePlantProduct"}).populate({path: "qualityInsReportImgs"}).populate({path: "flourMerchantImgs"}).populate({path: "pesticidetImgs"}).populate({path: "homepageCarouselImgs"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec(); let list = await DB.ProductPre.find(search).populate({path: "productPhotos2"}).populate({path: "sourcePlantProduct"}).populate({path: "homepageCarouselImgs"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec();
res.sendData({ count, list }); res.sendData({ count, list });
} catch (error) { } catch (error) {
next(error); next(error);
...@@ -50,9 +50,9 @@ async function updatePrePlant(req, res, next) { ...@@ -50,9 +50,9 @@ async function updatePrePlant(req, res, next) {
return res.sendError(errorMessage.resourceNotFound); return res.sendError(errorMessage.resourceNotFound);
} }
let body = req.body; let body = req.body;
body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o}); // body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o});
body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o}); // body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o}); // body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
body.homepageCarouselImgs = (body.homepageCarouselImgs || []).map(o => {return o && o._id || o}); body.homepageCarouselImgs = (body.homepageCarouselImgs || []).map(o => {return o && o._id || o});
body.productPhotos2 = (body.productPhotos2 || []).map(o => {return o && o._id || o}); body.productPhotos2 = (body.productPhotos2 || []).map(o => {return o && o._id || o});
let upInfo = { let upInfo = {
......
This diff is collapsed.
...@@ -99,6 +99,28 @@ const letianProTraceCodeSchema = new Schema({ ...@@ -99,6 +99,28 @@ const letianProTraceCodeSchema = new Schema({
type: Boolean, type: Boolean,
}, },
flourMerchantImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "面粉商原料检测报告图"
}
],
qualityInsReportImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "质检报告图"
}
],
pesticidetImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "农残质检报告"
}
],
creator: { creator: {
type: mongoose.Types.ObjectId, type: mongoose.Types.ObjectId,
ref: 'User', ref: 'User',
......
...@@ -43,13 +43,6 @@ const letianProductDeepSchema = new Schema({ ...@@ -43,13 +43,6 @@ const letianProductDeepSchema = new Schema({
comment: "产品详情轮播图" comment: "产品详情轮播图"
} }
], ],
pesticidetImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "农残质检报告"
}
],
sellByDate: { sellByDate: {
type: String, type: String,
comment: "保质期" comment: "保质期"
...@@ -83,13 +76,6 @@ const letianProductDeepSchema = new Schema({ ...@@ -83,13 +76,6 @@ const letianProductDeepSchema = new Schema({
type: String, type: String,
comment: "产品编号" comment: "产品编号"
}, },
qualityInsReportImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "质检报告图"
}
],
monitorInfo: { monitorInfo: {
type: [ type: [
{ {
...@@ -164,14 +150,6 @@ const letianProductDeepSchema = new Schema({ ...@@ -164,14 +150,6 @@ const letianProductDeepSchema = new Schema({
get: v => moment(v).format("YYYY-MM-DD"), get: v => moment(v).format("YYYY-MM-DD"),
comment: "生产日期" comment: "生产日期"
}, },
flourMerchantImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "面粉商原料检测报告图"
}
],
createdAt: { createdAt: {
......
...@@ -70,20 +70,20 @@ const letianProductPlantSchema = new Schema({ ...@@ -70,20 +70,20 @@ const letianProductPlantSchema = new Schema({
type: Number, type: Number,
comment: "产品编号" comment: "产品编号"
}, },
qualityInsReportImgs: [ // qualityInsReportImgs: [
{ // {
type: mongoose.Types.ObjectId, // type: mongoose.Types.ObjectId,
ref: 'File', // ref: 'File',
comment: "质检报告图" // comment: "质检报告图"
} // }
], // ],
pesticidetImgs: [ // pesticidetImgs: [
{ // {
type: mongoose.Types.ObjectId, // type: mongoose.Types.ObjectId,
ref: 'File', // ref: 'File',
comment: "农残质检报告" // comment: "农残质检报告"
} // }
], // ],
monitorInfo: { monitorInfo: {
type: [ type: [
{ {
...@@ -145,13 +145,13 @@ const letianProductPlantSchema = new Schema({ ...@@ -145,13 +145,13 @@ const letianProductPlantSchema = new Schema({
get: v => moment(v).format("YYYY-MM-DD"), get: v => moment(v).format("YYYY-MM-DD"),
comment: "生产日期" comment: "生产日期"
}, },
flourMerchantImgs: [ // flourMerchantImgs: [
{ // {
type: mongoose.Types.ObjectId, // type: mongoose.Types.ObjectId,
ref: 'File', // ref: 'File',
comment: "面粉商原料检测报告图" // comment: "面粉商原料检测报告图"
} // }
], // ],
createdAt: { createdAt: {
type: Date, type: Date,
......
...@@ -76,20 +76,20 @@ const letianProductPreSchema = new Schema({ ...@@ -76,20 +76,20 @@ const letianProductPreSchema = new Schema({
type: String, type: String,
comment: "产品编号" comment: "产品编号"
}, },
qualityInsReportImgs: [ // qualityInsReportImgs: [
{ // {
type: mongoose.Types.ObjectId, // type: mongoose.Types.ObjectId,
ref: 'File', // ref: 'File',
comment: "质检报告图" // comment: "质检报告图"
} // }
], // ],
pesticidetImgs: [ // pesticidetImgs: [
{ // {
type: mongoose.Types.ObjectId, // type: mongoose.Types.ObjectId,
ref: 'File', // ref: 'File',
comment: "农残质检报告" // comment: "农残质检报告"
} // }
], // ],
monitorInfo: { //农业 monitorInfo: { //农业
type: [ type: [
{ {
...@@ -152,13 +152,13 @@ const letianProductPreSchema = new Schema({ ...@@ -152,13 +152,13 @@ const letianProductPreSchema = new Schema({
get: v => moment(v).format("YYYY-MM-DD"), get: v => moment(v).format("YYYY-MM-DD"),
comment: "生产日期" comment: "生产日期"
}, },
flourMerchantImgs: [ // flourMerchantImgs: [
{ // {
type: mongoose.Types.ObjectId, // type: mongoose.Types.ObjectId,
ref: 'File', // ref: 'File',
comment: "面粉商原料检测报告图" // comment: "面粉商原料检测报告图"
} // }
], // ],
createdAt: { createdAt: {
type: Date, type: Date,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment