明树Git Lab

Commit e541bf62 authored by zfp1's avatar zfp1

update

parents a7cb8cb4 00784b27
const errorMessage = require("../utils/errorMessage");
const userModule = require('../module/userModule');
const { Op } = require('sequelize');
async function createRole(req, res, next) {
try {
////
} catch (error) {
next(error);
/**
* 资源库controller
*/
async function createResource(req, res, next) {
try {
const body = req.body;
const ret = await DB.Resources.create(body);
return res.sendData(ret);
} catch (error) {
next(error);
}
};
async function updateResource(req, res, next) {
try {
const body = req.body;
if (!body.id) {
return res.sendError(errorMessage.resourceNotFound)
}
const ret = await DB.Resources.update(body, { where: { id: body.id } });
return res.sendData(ret);
} catch (error) {
next(error);
}
}
async function deleteResource(req, res, next) {
try {
if (!req.body.id) {
return res.sendError(errorMessage.resourceNotFound);
}
const ret = await DB.Resources.update({ del: 1 }, { where: { id: req.body.id } });
return res.sendData(ret);
} catch (error) {
next(error);
}
}
async function listResource(req, res, next) {
try {
let search = { where: { del: 0 } };
let page = req.body.page || 1;
let limit = req.body.pageSize || 10;
//翻页
let offset = (page - 1) * limit;
if (req.body.name) {
search.where = {
[Op.or]: [
//根据名字模糊搜索
{ name: { [Op.like]: `%${req.body.name}%` } }
],
del: 0,
}
}
search.limit = limit;
search.offset = offset;
//指定显示字段,空数组会报错
search.attributes = req.body.attributes || null;
let ret = await DB.Resources.findAndCountAll(search);
return res.sendData(ret);
} catch (error) {
next(error);
}
};
/**
* 资源库字段controller
*/
async function createResourceInfo(req, res, next) {
try {
const body = req.body;
if (!body.resourceId) {
return res.sendError(errorMessage.resourceNotFound)
}
const resource = await DB.Resources.findOne({ where: { id: body.resourceId } });
if (!resource) {
return res.sendError(errorMessage.resourceNotFound)
}
const ret = await DB.ResourcesInfo.create(body);
return res.sendData(ret);
} catch (error) {
next(error);
}
};
async function updateResourceInfo(req, res, next) {
try {
const body = req.body;
if (!body.id) {
return res.sendError(errorMessage.resourceNotFound)
}
const ret = await DB.ResourcesInfo.update(body, { where: { id: body.id } });
return res.sendData(ret);
} catch (error) {
next(error);
}
}
async function deleteResourceInfo(req, res, next) {
try {
if (!req.body.id) {
return res.sendError(errorMessage.resourceNotFound);
}
const ret = await DB.ResourcesInfo.update({ del: 1 }, { where: { id: req.body.id } });
return res.sendData(ret);
} catch (error) {
next(error);
}
}
async function listResourceInfo(req, res, next) {
try {
let search = { where: { del: 0 } };
let page = req.body.page || 1;
let limit = req.body.pageSize || 10;
//翻页
let offset = (page - 1) * limit;
if (req.body.name) {
search.where = {
[Op.or]: [
//根据value值模糊搜索
{ value: { [Op.like]: `%${req.body.name}%` } }
],
del: 0,
}
}
search.limit = limit;
search.offset = offset;
//指定显示字段,空数组会报错
search.attributes = req.body.attributes || null;
let ret = await DB.ResourcesInfo.findAndCountAll(search);
return res.sendData(ret);
} catch (error) {
next(error);
}
};
module.exports = {
createResource,
updateResource,
deleteResource,
listResource,
createResourceInfo,
updateResourceInfo,
deleteResourceInfo,
listResourceInfo
}
\ No newline at end of file
......@@ -54,6 +54,7 @@ async function login(req, res, next) {
}
]
});
// console.log('this is user login', user)
user = user.toJSON();
if (!user) {
return res.sendError(errorMessage.loginError);
......
......@@ -12,9 +12,9 @@ const File = require("./model/system/file");
const Position = require("./model/system/position");
// 业务模型
const Project = require("./model/project/project");
const Resources = require("./model/project/resources");
const ResourcesInfo = require("./model/project/resourcesInfo");
const Project = require("./model/jt/project");
const Resources = require("./model/jt/resources");
const ResourcesInfo = require("./model/jt/resourcesInfo");
/**
* 业务表
......
......@@ -2,8 +2,8 @@
const { Sequelize } = require('sequelize');
// 创建 Sequelize 实例,连接数据库
const sequelize = new Sequelize(sysConfig.database || 'gzbjt', sysConfig.username || 'root', sysConfig.password ||'123456', {
host: sysConfig.host || 'localhost',
const sequelize = new Sequelize(sysConfig.mysql.database || 'gzbjt', sysConfig.mysql.username || 'root', sysConfig.mysql.password ||'123456', {
host: sysConfig.mysql.host || 'localhost',
dialect: 'mysql',
logging: false, // 显示日志(可选)
pool: {
......
Project (项目主表)
ProjectStage (项目阶段表)
ProjectApproval (立项信息表)
Contract (合同信息表)
InvestmentApproval (投资评价及批复信息表)
Investor (投资主体单位落实信息表)
CompanyApproval (项目公司落实批复信息表)
Compliance (项目合法合规性信息表)
项目名称
项目编号
......
......@@ -1730,7 +1730,7 @@ const Project = sequelize.define('Project', {
/* -------------------------------------------------------- */
}, {
tableName: 'system_project', // 指定表名(如果与模型名不同)
tableName: 'jt_project', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
......
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
// 建设规模
const projectBjtj = sequelize.define('projectBjtj', {
// 定义字段
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
type: {
type: DataTypes.STRING,
comment: "业务类型"
},
dwgczjSz: {
type: DataTypes.DECIMAL(20, 4),
comment: "单位工程造价数值"
},
dwgczjDw: {
type: DataTypes.STRING,
comment: "单位工程造价单位"
},
xsfwnlSz: {
type: DataTypes.DECIMAL(20, 4),
comment: "销售服务能力数值"
},
xsfwnlDw: {
type: DataTypes.STRING,
comment: "销售服务能力单位"
},
njfhlSz: {
type: DataTypes.DECIMAL(20, 4),
comment: "年均负荷率数值"
},
njfhlDw: {
type: DataTypes.STRING,
comment: "年均负荷率单位",
defaultValue: "%"
},
dwscfwzcbSz: {
type: DataTypes.DECIMAL(20, 4),
comment: "单位生产服务总成本数值"
},
dwscfwzcbDw: {
type: DataTypes.STRING,
comment: "单位生产服务总成本单位",
defaultValue: "%"
},
dwsjSz: {
type: DataTypes.DECIMAL(20, 4),
comment: "单位售价(含税)数值"
},
dwsjDw: {
type: DataTypes.STRING,
comment: "单位售价(含税)单位",
},
ykphdlx: {
type: DataTypes.STRING,
comment: "盈亏平衡点类型",
},
ykphdsz: {
type: DataTypes.DECIMAL(20, 4),
comment: "盈亏平衡点数值"
},
ykphddw: {
type: DataTypes.STRING,
comment: "盈亏平衡点单位",
defaultValue: "%"
},
bcsm: {
type: DataTypes.STRING,
comment: "核心边界条件补充说明"
},
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
}, {
tableName: 'jt_project_gdxx', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
projectBjtj.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('projectBjtj 表同步成功');
});
module.exports = projectBjtj;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
// 建设规模
const projectCwpjzb = sequelize.define('projectCwpjzb', {
// 定义字段
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
name: {
type: DataTypes.STRING,
comment: "指标名称"
},
num: {
type: DataTypes.DECIMAL(20, 4),
comment: "数量"
},
unit: {
type: DataTypes.STRING,
comment: "单位"
},
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
}, {
tableName: 'jt_project_cwpjzb', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
projectCwpjzb.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('projectCwpjzb 表同步成功');
});
module.exports = projectCwpjzb;
\ No newline at end of file
// models/User.js
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const File = require('./file');
const Project = require('./project');
const projectFile = sequelize.define('projectFile', {
// 定义字段
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
fileId: {
type: DataTypes.INTEGER,
references: { model: File, key: 'id' }
},
projectId: {
type: DataTypes.INTEGER,
references: { model: Project, key: 'id' }
},
projectKey: {
type: DataTypes.STRING, //项目表中文件字段key
}
}, {
tableName: 'jt_project_file', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
projectFile.sync({
// force: false, // force: true 会删除已存在表并重新创建
alter: true
})
.then(() => {
console.log('projectFile 表同步成功');
});
module.exports = projectFile;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
// 建设规模
const projectGdxx = sequelize.define('projectGdxx', {
// 定义字段
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
type: {
type: DataTypes.STRING,
comment: "股东类型"
},
name: {
type: DataTypes.STRING,
comment: "股东名称"
},
cgbl: {
type: DataTypes.DECIMAL(5, 2),
comment: "持股比例(%)"
},
cze: {
type: DataTypes.DECIMAL(20, 4),
comment: "出资额(万元)"
},
yjzczb: {
type: DataTypes.DECIMAL(20, 4),
comment: "应缴注册资本(万元)"
},
ycxmzbj: {
type: DataTypes.DECIMAL(20, 4),
comment: "应出项目资本金(万元)"
},
hzfqk: {
type: DataTypes.TEXT,
comment: "合作方情况"
},
bz: {
type: DataTypes.TEXT,
comment: "备注"
},
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
}, {
tableName: 'jt_project_gdxx', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
projectGdxx.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('projectGdxx 表同步成功');
});
module.exports = projectGdxx;
\ No newline at end of file
......@@ -2,7 +2,7 @@ const { DataTypes } = require('sequelize');
const sequelize = require('../index');
// 建设规模
const projectConScale = sequelize.define('projectConScale', {
const projectJsgm = sequelize.define('projectJsgm', {
// 定义字段
id: {
type: DataTypes.INTEGER,
......@@ -28,10 +28,6 @@ const projectConScale = sequelize.define('projectConScale', {
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
references: {
model: DB.Project,
key: 'id'
}
},
del: {
type: DataTypes.INTEGER,
......@@ -39,19 +35,19 @@ const projectConScale = sequelize.define('projectConScale', {
comment: "0 正常 1 删除"
},
}, {
tableName: 'system_project_con_scale', // 指定表名(如果与模型名不同)
tableName: 'jt_project_jsgm', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
projectConScale.sync({
projectJsgm.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('projectConScale 表同步成功');
console.log('projectJsgm 表同步成功');
});
module.exports = projectConScale;
\ No newline at end of file
module.exports = projectJsgm;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
// 建设规模
const projectXmtzze = sequelize.define('projectXmtzze', {
// 定义字段
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
xh: {
type: DataTypes.STRING,
comment: ""
},
zb: {
type: DataTypes.STRING,
comment: "指标"
},
dw: {
type: DataTypes.STRING,
comment: "单位",
defaultValue: "万元"
},
rmbjj: {
type: DataTypes.DECIMAL(20, 4),
comment: "人民币计价"
},
parentId: {
type: DataTypes.INTEGER,
comment: "上级ID",
defaultValue: 0
},
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
}, {
tableName: 'jt_project_xmtzze', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
projectXmtzze.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('projectXmtzze 表同步成功');
});
module.exports = projectXmtzze;
\ No newline at end of file
......@@ -9,7 +9,10 @@ const Resources = sequelize.define('Resources', {
primaryKey: true,
autoIncrement: true
},
key: {
type: DataTypes.STRING,
comment: "资源库key"
},
name: {
type: DataTypes.STRING,
comment: "资源库名称"
......@@ -31,7 +34,7 @@ const Resources = sequelize.define('Resources', {
comment: "0 正常 1 删除"
},
}, {
tableName: 'system_resources', // 指定表名(如果与模型名不同)
tableName: 'jt_resources', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
......
......@@ -39,7 +39,7 @@ const ResourcesInfo = sequelize.define('ResourcesInfo', {
comment: "0 正常 1 删除"
},
}, {
tableName: 'system_resources_info', // 指定表名(如果与模型名不同)
tableName: 'jt_resources_info', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
......
......@@ -13,7 +13,7 @@ module.exports = async (req, res, next) => {
}
req.headers.authorization = req.headers.authorization || req.headers.Authorization;
const userStr = await ioRedis.get(`token:${req.headers.authorization}`);
// console.log(userStr)
console.log(userStr)
if (userStr) {
try {
req.user = JSON.parse(userStr);
......
const express = require('express');
const router = express.Router();
const resourceController = require('../controller/resourceController');
/**
......@@ -10,9 +8,18 @@ const resourceController = require('../controller/resourceController');
*/
// router.post('/resource', resourceController.createResource);
router.post('/createResource', resourceController.createResource);
router.post('/deleteResource', resourceController.deleteResource);
router.post('/updateResource', resourceController.updateResource);
router.post('/listResource', resourceController.listResource);
// router.post('/getProjectFields', projectController.getProjectFields);
/**
* 资源库字段详情
*/
// router.post('/resourceInfo', resourceController.createResourceInfo);
router.post('/createResourceInfo', resourceController.createResourceInfo);
router.post('/deleteResourceInfo', resourceController.deleteResourceInfo);
router.post('/updateResourceInfo', resourceController.updateResourceInfo);
router.post('/listResourceInfo', resourceController.listResourceInfo);
module.exports = router;
\ 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