明树Git Lab

Commit 4ffa5160 authored by zfp1's avatar zfp1

1

parent 4f029b6c
Pipeline #105872 passed with stage
in 3 seconds
const errorMessage = require("../utils/errorMessage"); const errorMessage = require("../utils/errorMessage");
const { Op } = require("sequelize"); const { Op } = require("sequelize");
const sequelize = require('sequelize');
...@@ -68,16 +69,24 @@ async function getUserMessages(req, res, next) { ...@@ -68,16 +69,24 @@ async function getUserMessages(req, res, next) {
try { try {
const messages = await DB.Message.findAll({ const messages = await DB.Message.findAll({
where: { where: {
receivers: { [Op.contains]: [req.user.id] }, [Op.and]: [sequelize.where(
del: 0 sequelize.fn('JSON_CONTAINS',
sequelize.col('receivers'),
sequelize.cast(req.user.id, 'JSON'), // 直接将数字转换为JSON
sequelize.literal("'$'")
),
true
),
{ del: 0 },
]
}, },
include: [ // include: [
{ // {
model: DB.User, // model: DB.User,
as: 'creatorInfo', // as: 'creatorInfo',
attributes: ['id', 'name', 'avatar'] // attributes: ['id', 'name', 'avatar']
} // }
], // ],
raw: true, raw: true,
order: [['createdAt', 'DESC']], order: [['createdAt', 'DESC']],
}); });
...@@ -102,9 +111,24 @@ async function getMesCount(req, res, next) { ...@@ -102,9 +111,24 @@ async function getMesCount(req, res, next) {
try { try {
const count = await DB.Message.count({ const count = await DB.Message.count({
where: { where: {
receivers: { [Op.contains]: [req.user.id] }, [Op.and]: [sequelize.where(
del: 0, sequelize.fn('JSON_CONTAINS',
alreadyRead: { [Op.not]: {[Op.contains]: [req.user.id]} } sequelize.col('receivers'),
sequelize.cast(req.user.id, 'JSON'), // 直接将数字转换为JSON
sequelize.literal("'$'")
),
true
),
{ del: 0 },
sequelize.where(
sequelize.fn('JSON_CONTAINS',
sequelize.col('alreadyRead'),
sequelize.cast(req.user.id, 'JSON'), // 直接将数字转换为JSON
sequelize.literal("'$'")
),
true
)
]
} }
}); });
return res.sendData({ count }); return res.sendData({ count });
......
...@@ -1133,6 +1133,17 @@ async function getOwnProjects(req, res, next) { ...@@ -1133,6 +1133,17 @@ async function getOwnProjects(req, res, next) {
} }
} }
async function getProFlowRecord(req, res, next) {
try {
let rcs = await DB.FlowRecord.findAll({where: {projectId: req.body.projectId}});
return res.sendData(rcs);
} catch (error) {
next(error);
}
}
module.exports = { module.exports = {
getProjectFields, getProjectFields,
createProject, createProject,
...@@ -1153,4 +1164,5 @@ module.exports = { ...@@ -1153,4 +1164,5 @@ module.exports = {
getProjectCwpj, getProjectCwpj,
approvalLixiang, approvalLixiang,
approvalJuece, approvalJuece,
getProFlowRecord,
} }
\ No newline at end of file
...@@ -46,6 +46,8 @@ router.post('/listProject', projectController.listProject); ...@@ -46,6 +46,8 @@ router.post('/listProject', projectController.listProject);
// router.post('/getOwnProjects', projectController.getOwnProjects); // router.post('/getOwnProjects', projectController.getOwnProjects);
router.post('/getProFlowRecord', projectController.getProFlowRecord)
/** /**
* 投中管理 * 投中管理
......
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