明树Git Lab

Commit fe054255 authored by zfp1's avatar zfp1

update

parent b88b2e7f
...@@ -160,7 +160,7 @@ async function createProject(req, res, next) { ...@@ -160,7 +160,7 @@ async function createProject(req, res, next) {
}); });
let approvers = await userModule.getProjectApprover(req.user.id, 'xmgs_xmspr'); let approvers = await userModule.getProjectApprover(req.user.id, 'xmgs_xmspr');
if (!(approvers && approvers.length > 0)) { if (!(approvers && approvers.length > 0)) {
return res.sendError({code: '60001', msg: '项目已保存,请联系管理员为本公司添加【项目初审】角色人员'}); return res.sendError({ code: '60001', msg: '项目已保存,请联系管理员为本公司添加【项目初审】角色人员' });
} }
await DB.Message.create({ await DB.Message.create({
projectId: project.id, projectId: project.id,
...@@ -646,17 +646,15 @@ async function getOwnProjects(req, res, next) { ...@@ -646,17 +646,15 @@ async function getOwnProjects(req, res, next) {
let messs = await DB.Message.findAll({ let messs = await DB.Message.findAll({
//项目审批信息接收方 //项目审批信息接收方
where: { where: {
[Op.and]: [ [Op.and]: [sequelize.where(
sequelize.where( sequelize.fn('JSON_CONTAINS',
sequelize.fn('JSON_CONTAINS', sequelize.col('receivers'),
sequelize.col('receivers'), sequelize.cast(req.user.id, 'JSON'), // 直接将数字转换为JSON
sequelize.cast(req.user.id, 'JSON'), sequelize.literal("'$'")
'$'
),
true
), ),
, true
{ projectId: { [Op.ne]: null } }, ),
{ projectId: { [Op.ne]: null } },
] ]
}, },
attributes: ['projectId'] attributes: ['projectId']
...@@ -664,16 +662,17 @@ async function getOwnProjects(req, res, next) { ...@@ -664,16 +662,17 @@ async function getOwnProjects(req, res, next) {
console.log(messs) console.log(messs)
let projectIds = messs.map(o => { return o && o.projectId }); let projectIds = messs.map(o => { return o && o.projectId });
// //
let cArr = [
{ projectCreator: req.user.id },
{ id: { [Op.in]: projectIds } }
]
if (req.body.projectName) {
cArr.push({ projectName: { [Op.like]: `%${req.body.projectName}%` } });
}
search.where = { search.where = {
[Op.or]: [ [Op.or]: cArr
{ projectCreator: req.user.id },
{ id: { [Op.in]: projectIds } }
]
}; };
if (req.body.name) {
search.where[[Op.or]].push({ name: { [Op.like]: `%${req.body.name}%` } });
}
search.limit = limit; search.limit = limit;
search.offset = offset; search.offset = offset;
if (req.body.attributes && req.body.attributes.length) { if (req.body.attributes && req.body.attributes.length) {
......
...@@ -26,8 +26,8 @@ const RoleMenu = sequelize.define('RoleMenu', { ...@@ -26,8 +26,8 @@ const RoleMenu = sequelize.define('RoleMenu', {
// 同步模型到数据库(创建表) // 同步模型到数据库(创建表)
RoleMenu.sync({ RoleMenu.sync({
// force: false, // force: true 会删除已存在表并重新创建 force: false, // force: true 会删除已存在表并重新创建
alter: true // alter: true
}) })
.then(() => { .then(() => {
console.log('RoleMenu 表同步成功'); console.log('RoleMenu 表同步成功');
......
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