明树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');
async function createResource(req, res, next) {
try {
const body = req.body;
// await DB.Resources.bulkCreate(
// [
// { "key": "k1a92f", "name": "公交车" },
// { "key": "u3b81x", "name": "地铁" },
// { "key": "p9c44m", "name": "高铁" },
// { "key": "n7d22t", "name": "出租车" },
// { "key": "q4e93z", "name": "轻轨" },
// { "key": "t6f81k", "name": "磁悬浮列车" },
// { "key": "r8g55w", "name": "轮渡" },
// { "key": "s2h19p", "name": "共享单车" },
// { "key": "w9j73v", "name": "电动车" },
// { "key": "a5k33q", "name": "自驾车" },
// { "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);
let ret = await DB.Resources.create(body);
ret = ret.toJSON();
console.log(ret);
if (body.resourceInfos && body.resourceInfos.length && ret.id) {
let ris = [];
for (let index = 0; index < body.resourceInfos.length; index++) {
const element = body.resourceInfos[index];
element.resourceId = ret.id;
ris.push(element);
}
console.log(ris, "===")
await DB.ResourcesInfo.bulkCreate(ris);
}
return res.sendData(ret);
} catch (error) {
next(error);
......@@ -187,7 +175,7 @@ async function saveAllResourceInfo(req, res, next) {
if (!resource) {
return res.sendError(errorMessage.resourceNotFound);
}
if(resource && resource.type == 2) {
if (resource && resource.type == 2) {
data = utils.disTree(data)
}
let toCreate = [], toKeep = [];
......@@ -202,12 +190,12 @@ async function saveAllResourceInfo(req, res, next) {
}
}
}
if(toKeep.length) {
if (toKeep.length) {
await DB.ResourcesInfo.destory({
where: {[Op.nin]: toKeep}
where: { [Op.nin]: toKeep }
})
}
if(toCreate.length) {
if (toCreate.length) {
await DB.ResourcesInfo.bulkCreate(toCreate);
}
return res.sendData();
......@@ -233,7 +221,7 @@ async function listResourceAll(req, res, next) {
let obj = {};
for (let index = 0; index < datas.length; index++) {
const element = datas[index];
if(element.type == 2) {
if (element.type == 2) {
element.resourcesInfos = utils.buildTree(element.resourcesInfos);
}
obj[element.key] = element.resourcesInfos || [];
......
......@@ -107,7 +107,7 @@ const Project = sequelize.define('Project', {
zsqy: { type: DataTypes.STRING, allowNull: true, comment: "直属企业" },
sfnjzdhzytz: { 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:下拉
sflxbqyscx: { type: DataTypes.INTEGER, allowNull: true, comment: "是否履行标前预审程序" },
xmztz: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "项目总投资" },
......@@ -119,7 +119,7 @@ const Project = sequelize.define('Project', {
xmlx: { type: DataTypes.STRING, allowNull: true, comment: "项目类型" }, //TODO:下拉
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:下拉
cityOrCountry: { type: DataTypes.STRING, allowNull: true, comment: "地市(境内)/国家(境外)" },//TODO:下拉
qxjngjjw: { type: DataTypes.STRING, allowNull: true, comment: "区县(境内)/国家(境外)" },//TODO:下拉
......@@ -1765,9 +1765,9 @@ const Project = sequelize.define('Project', {
// 同步模型到数据库(创建表)
Project.sync({
force: false,
// force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
alter: true
})
.then(() => {
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