@ -245,9 +245,13 @@ router.get(APIv2.Sessions.SessionListByType, function (req, res) {
if (!type) {
throw {httpStatus: 406, message: 'Missing type.'};
}
if (!userId) {
throw {httpStatus: 406, message: 'Missing user.'};
/**
* userId 为传值时:管理员调度大屏获取im消息
*/
// if (!userId) {
// throw {httpStatus: 406, message: 'Missing user.'};
// }
let sessions = new Sessions();
ControllerUtil.regModelEventHandler(sessions, res);
@ -966,6 +966,14 @@ class Sessions extends RedisModel {
let sessionId = mysqlSession.id;
let sessionKey = RedisModel.makeRedisKey(REDIS_KEYS.Session, sessionId);
let sessionParticipantsKey = RedisModel.makeRedisKey(REDIS_KEYS.SessionParticipants, sessionId);
if (userId == null || userId == "") {
userId = sessionId.substring(0,sessionId.indexOf('_'));
redis.multi()
.hgetall(sessionKey) // 会话实体
.zscore(sessionParticipantsKey, userId) // 用户在此会话中最后一次获取未读消息的时间
@ -176,7 +176,15 @@ class SessionRepo {
let sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id in(?) group by w.session_id";
let sql = "";
if (userId != null && userId != "") {
sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id in(?) group by w.session_id";
} else {
sql = "select session_id from " + DB_TABLES.Participants + " w group by w.session_id"
let sessionSQL = "select id, name, type, create_date, last_sender_id, last_sender_name, last_content_type, last_content, last_message_time from "
+ DB_TABLES.Sessions + " s where s.id in(" + sql + ") and s.type in("+type+") ";