明树Git Lab

Commit 40ae8d31 authored by zfp1's avatar zfp1

update

parent 05ce7a67
Pipeline #106375 passed with stage
in 3 seconds
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
const errorMessage = require("../utils/errorMessage"); const errorMessage = require("../utils/errorMessage");
const _ = require("lodash"); const _ = require("lodash");
const { Op } = require('sequelize'); const { Op } = require('sequelize');
const projectModule = require('../module/projectModule');
async function createCgqygl(req, res, next) { async function createCgqygl(req, res, next) {
try { try {
...@@ -106,6 +107,8 @@ async function getCgqyglList(req, res, next) { ...@@ -106,6 +107,8 @@ async function getCgqyglList(req, res, next) {
if (req.body.attributes && req.body.attributes.length) search.attributes = req.body.attributes; if (req.body.attributes && req.body.attributes.length) search.attributes = req.body.attributes;
let ret = await DB.RcCgqygl.findAndCountAll(search); let ret = await DB.RcCgqygl.findAndCountAll(search);
let risMap = await projectModule.getResourceInfoMapByKeys(["xmjd"]);
ret.rows.map(o => {o.xmscjd = risMap[o.xmscjd] || o.xmscjd; return o;});
return res.sendData(ret); return res.sendData(ret);
} catch (error) { } catch (error) {
next(error); next(error);
......
...@@ -80,13 +80,31 @@ async function handleProjectData(ret, queryAttrs) { ...@@ -80,13 +80,31 @@ async function handleProjectData(ret, queryAttrs) {
async function getResourceInfoByIds(resouInfoIds) { async function getResourceInfoByIds(resouInfoIds) {
let ris = await DB.ResourcesInfo.findAll({ let ris = await DB.ResourcesInfo.findAll({
where: { id: { [Op.in]: resouInfoIds } }, where: { key: { [Op.in]: resouInfoIds } },
// raw: true, // raw: true,
}); });
let risMap = {}; let risMap = {};
for (let index = 0; index < ris.length; index++) { for (let index = 0; index < ris.length; index++) {
const element = ris[index]; const element = ris[index];
risMap[element.id] = element.value; risMap[element.key] = element.value || element.name;
}
// console.log(risMap)
return risMap;
}
async function getResourceInfoMapByKeys(keys) {
let ris = await DB.Resources.findAll({
where: { key: { [Op.in]: keys } },
raw: true,
});
let rids = ris.map(o => { return o.id });
let risinfos = await DB.ResourcesInfo.findAll({
where: { resourceId: { [Op.in]: rids } },
raw: true,
});
let risMap = {};
for (let index = 0; index < risinfos.length; index++) {
const element = risinfos[index];
risMap[element.key] = element.value || element.name;
} }
// console.log(risMap) // console.log(risMap)
return risMap; return risMap;
...@@ -325,4 +343,5 @@ module.exports = { ...@@ -325,4 +343,5 @@ module.exports = {
handleProjectData, handleProjectData,
getProjectInfo, getProjectInfo,
getProjectInfoByLixiang, getProjectInfoByLixiang,
getResourceInfoMapByKeys,
} }
\ No newline at end of file
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