明树Git Lab

Commit fbd84ce0 authored by zhangqi's avatar zhangqi

Merge branch 'dev' of gitlab.bridata.com:zengfanpei/jt_backend into dev

parents 384ce04a 3c714327
...@@ -9,31 +9,19 @@ const { Op } = require('sequelize'); ...@@ -9,31 +9,19 @@ const { Op } = require('sequelize');
async function createResource(req, res, next) { async function createResource(req, res, next) {
try { try {
const body = req.body; const body = req.body;
// await DB.Resources.bulkCreate( let ret = await DB.Resources.create(body);
// [ ret = ret.toJSON();
// { "key": "k1a92f", "name": "公交车" }, console.log(ret);
// { "key": "u3b81x", "name": "地铁" }, if (body.resourceInfos && body.resourceInfos.length && ret.id) {
// { "key": "p9c44m", "name": "高铁" }, let ris = [];
// { "key": "n7d22t", "name": "出租车" }, for (let index = 0; index < body.resourceInfos.length; index++) {
// { "key": "q4e93z", "name": "轻轨" }, const element = body.resourceInfos[index];
// { "key": "t6f81k", "name": "磁悬浮列车" }, element.resourceId = ret.id;
// { "key": "r8g55w", "name": "轮渡" }, ris.push(element);
// { "key": "s2h19p", "name": "共享单车" }, }
// { "key": "w9j73v", "name": "电动车" }, console.log(ris, "===")
// { "key": "a5k33q", "name": "自驾车" }, await DB.ResourcesInfo.bulkCreate(ris);
// { "key": "y1l87u", "name": "长途客车" }, }
// { "key": "d3m41b", "name": "飞机" },
// { "key": "f8n22h", "name": "直升机" },
// { "key": "c4p66r", "name": "城际铁路" },
// { "key": "m2q99s", "name": "轨道交通" },
// { "key": "j7r55d", "name": "大巴车" },
// { "key": "z3s13e", "name": "顺风车" },
// { "key": "e9t80y", "name": "三轮车" },
// { "key": "h5u28i", "name": "地面有轨电车" },
// { "key": "b6v71o", "name": "高速公路客运" }
// ]
// )
const ret = await DB.Resources.create(body);
return res.sendData(ret); return res.sendData(ret);
} catch (error) { } catch (error) {
next(error); next(error);
...@@ -187,7 +175,7 @@ async function saveAllResourceInfo(req, res, next) { ...@@ -187,7 +175,7 @@ async function saveAllResourceInfo(req, res, next) {
if (!resource) { if (!resource) {
return res.sendError(errorMessage.resourceNotFound); return res.sendError(errorMessage.resourceNotFound);
} }
if(resource && resource.type == 2) { if (resource && resource.type == 2) {
data = utils.disTree(data) data = utils.disTree(data)
} }
let toCreate = [], toKeep = []; let toCreate = [], toKeep = [];
...@@ -202,12 +190,12 @@ async function saveAllResourceInfo(req, res, next) { ...@@ -202,12 +190,12 @@ async function saveAllResourceInfo(req, res, next) {
} }
} }
} }
if(toKeep.length) { if (toKeep.length) {
await DB.ResourcesInfo.destory({ await DB.ResourcesInfo.destory({
where: {[Op.nin]: toKeep} where: { [Op.nin]: toKeep }
}) })
} }
if(toCreate.length) { if (toCreate.length) {
await DB.ResourcesInfo.bulkCreate(toCreate); await DB.ResourcesInfo.bulkCreate(toCreate);
} }
return res.sendData(); return res.sendData();
...@@ -233,7 +221,7 @@ async function listResourceAll(req, res, next) { ...@@ -233,7 +221,7 @@ async function listResourceAll(req, res, next) {
let obj = {}; let obj = {};
for (let index = 0; index < datas.length; index++) { for (let index = 0; index < datas.length; index++) {
const element = datas[index]; const element = datas[index];
if(element.type == 2) { if (element.type == 2) {
element.resourcesInfos = utils.buildTree(element.resourcesInfos); element.resourcesInfos = utils.buildTree(element.resourcesInfos);
} }
obj[element.key] = element.resourcesInfos || []; obj[element.key] = element.resourcesInfos || [];
......
...@@ -107,7 +107,7 @@ const Project = sequelize.define('Project', { ...@@ -107,7 +107,7 @@ const Project = sequelize.define('Project', {
zsqy: { type: DataTypes.STRING, allowNull: true, comment: "直属企业" }, zsqy: { type: DataTypes.STRING, allowNull: true, comment: "直属企业" },
sfnjzdhzytz: { type: DataTypes.INTEGER, allowNull: true, comment: "是否能建重大或重要投资" }, sfnjzdhzytz: { type: DataTypes.INTEGER, allowNull: true, comment: "是否能建重大或重要投资" },
sfzzjc: { type: DataTypes.INTEGER, allowNull: true, comment: "是否自主决策" }, sfzzjc: { type: DataTypes.INTEGER, allowNull: true, comment: "是否自主决策" },
financialStatementType: { type: DataTypes.STRING, allowNull: true, comment: "财务报表类型" }, //TODO:下拉 cwbblx: { type: DataTypes.STRING, allowNull: true, comment: "财务报表类型" }, //TODO:下拉
zfsphzbajb: { type: DataTypes.STRING, allowNull: true, comment: "政府审批(核准、备案)级别" }, //TODO:下拉 zfsphzbajb: { type: DataTypes.STRING, allowNull: true, comment: "政府审批(核准、备案)级别" }, //TODO:下拉
sflxbqyscx: { type: DataTypes.INTEGER, allowNull: true, comment: "是否履行标前预审程序" }, sflxbqyscx: { type: DataTypes.INTEGER, allowNull: true, comment: "是否履行标前预审程序" },
xmztz: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "项目总投资" }, xmztz: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "项目总投资" },
...@@ -119,7 +119,7 @@ const Project = sequelize.define('Project', { ...@@ -119,7 +119,7 @@ const Project = sequelize.define('Project', {
xmlx: { type: DataTypes.STRING, allowNull: true, comment: "项目类型" }, //TODO:下拉 xmlx: { type: DataTypes.STRING, allowNull: true, comment: "项目类型" }, //TODO:下拉
sfpppxm: { type: DataTypes.INTEGER, allowNull: true, comment: "是否PPP项目" }, sfpppxm: { type: DataTypes.INTEGER, allowNull: true, comment: "是否PPP项目" },
//项目所在地 //项目所在地
domesticOrOverseas: { type: DataTypes.STRING, allowNull: true, comment: "境内/外" },//TODO:下拉 jnw: { type: DataTypes.STRING, allowNull: true, comment: "境内/外" },//TODO:下拉
sjnzjjw: { type: DataTypes.STRING, allowNull: true, comment: "省(境内)/洲际(境外)" },//TODO:下拉 sjnzjjw: { type: DataTypes.STRING, allowNull: true, comment: "省(境内)/洲际(境外)" },//TODO:下拉
cityOrCountry: { type: DataTypes.STRING, allowNull: true, comment: "地市(境内)/国家(境外)" },//TODO:下拉 cityOrCountry: { type: DataTypes.STRING, allowNull: true, comment: "地市(境内)/国家(境外)" },//TODO:下拉
qxjngjjw: { type: DataTypes.STRING, allowNull: true, comment: "区县(境内)/国家(境外)" },//TODO:下拉 qxjngjjw: { type: DataTypes.STRING, allowNull: true, comment: "区县(境内)/国家(境外)" },//TODO:下拉
...@@ -1765,9 +1765,9 @@ const Project = sequelize.define('Project', { ...@@ -1765,9 +1765,9 @@ const Project = sequelize.define('Project', {
// 同步模型到数据库(创建表) // 同步模型到数据库(创建表)
Project.sync({ Project.sync({
force: false, // force: false,
// force: true ,//会删除已存在表并重新创建 // force: true ,//会删除已存在表并重新创建
// alter: true alter: true
}) })
.then(() => { .then(() => {
console.log('Project 表同步成功'); console.log('Project 表同步成功');
......
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