明树Git Lab

Commit e4ad769d authored by zfp1's avatar zfp1

update

parent edc23b60
Pipeline #106418 passed with stage
in 3 seconds
......@@ -792,7 +792,7 @@ async function updateJsqtzjc(req, res, next) {
if (!req.body.projectId) {
return res.sendError(errorMessage.paramsError);
}
let jsqtzjc = await DB.TzJsqtzjc.findOne({ where: {id: req.body.id}, raw: true });
let jsqtzjc = await DB.TzJsqtzjc.findOne({ where: { id: req.body.id }, raw: true });
if (!(jsqtzjc && jsqtzjc.id && jsqtzjc.projectId)) {
return res.sendError(errorMessage.resourceNotFound);
}
......@@ -880,11 +880,24 @@ async function getJsqtzjcList(req, res, next) {
// }
// }
search.where = where;
search.raw = true;
if (req.body.attributes && req.body.attributes.length) {
search.attributes = req.body.attributes;
}
let ret = await DB.TzJsqtzjc.findAndCountAll(search);
let tzjcIds = [];
ret.rows.map(o => { tzjcIds.push(o.id); });
let jsqtzjcTzfxs = await DB.TzJsqtzjcTzfx.findAll({ where: { sourceId: {[Op.in]: tzjcIds} }, raw: true });
let jsqtzjcZxjcs = await DB.TzJsqtzjcZxjc.findAll({ where: { sourceId: {[Op.in]: tzjcIds} }, raw: true });
let tzfxsmap = _.groupBy(jsqtzjcTzfxs, 'sourceId');
let tzzxjcmap = _.groupBy(jsqtzjcZxjcs, 'sourceId');
// console.log(tzfxsmap, "===")
ret.rows = ret.rows.map(o => {
o.jsqtzjcTzfxs = tzfxsmap[String(o.id)] || [];
console.log(o.jsqtzjcTzfxs)
o.jsqtzjcZxjcs = tzzxjcmap[String(o.id)] || [];
return o;
});
return res.sendData(ret);
} catch (error) {
next(error);
......
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