|
@ -51,6 +51,27 @@ class SessionRepo {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
static findAllSessionByTypeAndStatus(userId,type,status, handler) {
|
|
|
let sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? and participant_role =0 group by w.session_id";
|
|
|
let sys_session = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = 'system' and participant_role =0 group by w.session_id";
|
|
|
let sessionSQL;
|
|
|
if (!status){
|
|
|
sessionSQL = "select id, name, type, create_date,business_type, last_sender_id, last_sender_name, last_content_type, last_content, last_message_time,status from "
|
|
|
+ DB_TABLES.Sessions + " s where s.id in(" + sql + ") and s.type="+type+" and s.id not in ("+sys_session+")";
|
|
|
}
|
|
|
else{
|
|
|
sessionSQL = "select id, name, type, create_date,business_type, last_sender_id, last_sender_name, last_content_type, last_content, last_message_time,status from "
|
|
|
+ DB_TABLES.Sessions + " s where s.id in(" + sql + ") and s.type="+type+" and s.status="+status+" and s.id not in ("+sys_session+")";
|
|
|
}
|
|
|
ImDb.execQuery({
|
|
|
"sql": sessionSQL,
|
|
|
"args": [userId],
|
|
|
"handler": handler || function (err, res) {
|
|
|
if(err) log.error(err);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取用户全部(未结束的)会话不包含角色未1的会话
|
|
|
* @param userId
|
|
@ -137,7 +158,7 @@ class SessionRepo {
|
|
|
* @param type
|
|
|
* @param handler
|
|
|
*/
|
|
|
static findListByType(userId, type,page,pagesize, handler) {
|
|
|
static findListByType(userId, type,page,pagesize,status, handler) {
|
|
|
if (page > 0) {
|
|
|
if (page == 1) {
|
|
|
page = 0;
|
|
@ -147,8 +168,15 @@ class SessionRepo {
|
|
|
}
|
|
|
|
|
|
let sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? 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=? order by s.last_message_time desc limit "+page+","+pagesize;
|
|
|
let sessionSQL;
|
|
|
if (!status){
|
|
|
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=? order by s.last_message_time desc limit "+page+","+pagesize;
|
|
|
}
|
|
|
else {
|
|
|
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=? and s.status="+status+" order by s.last_message_time desc limit "+page+","+pagesize;
|
|
|
}
|
|
|
ImDb.execQuery({
|
|
|
"sql": sessionSQL,
|
|
|
"args": [userId, type],
|