|
@ -125,7 +125,7 @@ class SessionRepo {
|
|
|
static findAllByTypes(userId, type, handler) {
|
|
|
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.STATUS = 0 ";
|
|
|
+ DB_TABLES.Sessions + " s where s.id in(" + sql + ") AND s.STATUS = 0 ";
|
|
|
log.info("获取用户全部会话: sql :" + sessionSQL);
|
|
|
if(type){
|
|
|
sessionSQL +=" and type in("+type+") ";
|
|
@ -373,6 +373,62 @@ class SessionRepo {
|
|
|
|
|
|
}
|
|
|
|
|
|
static findAllByTypeAndBusinessTypeAndNoPage(userId, businessType,handler) {
|
|
|
let sessionSQL ="";
|
|
|
let sql ="";
|
|
|
if(status == SESSION_STATUS.ENDED){
|
|
|
if(businessType == SESSION_BUSINESS_TYPE.PATIENT){//区分居民,有未读消息的置顶排列
|
|
|
//找出已经结束的咨询
|
|
|
sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? group by w.session_id";
|
|
|
//找出角色讨论组中为旁听且未结束的咨询
|
|
|
let sql1 = ("select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? and participant_role ="+PARTICIPANT_ROLES.REGULAR+" group by w.session_id")
|
|
|
sessionSQL = "select s.* from " + DB_TABLES.Sessions + " s, " + DB_TABLES.Participants + " p " +
|
|
|
" where ((s.id in(" + sql + ") and s.business_type = ? and s.status = 1) or (s.id in(" + sql1 + ") and s.business_type = ? and s.status = 0)) " +
|
|
|
// " and s.id = p.session_id and p.participant_id = ? ORDER BY (p.last_fetch_time - s.last_message_time+1)>0,s.create_date desc limit "+page+","+pagesize;
|
|
|
" and s.id = p.session_id and p.participant_id = ? ORDER BY s.last_message_time desc ";
|
|
|
ImDb.execQuery({
|
|
|
"sql": sessionSQL,
|
|
|
"args": [userId, businessType,userId,businessType,userId],
|
|
|
"handler": handler || function (err, res) {
|
|
|
if(err) log.error(err);
|
|
|
}
|
|
|
});
|
|
|
}else{
|
|
|
//找出已经结束的咨询
|
|
|
sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? group by w.session_id";
|
|
|
//找出角色讨论组中为旁听且未结束的咨询
|
|
|
let sql1 = ("select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? and participant_role ="+PARTICIPANT_ROLES.REGULAR+" group by w.session_id")
|
|
|
sessionSQL = "select * from "
|
|
|
+ DB_TABLES.Sessions + " s where (s.id in(" + sql + ") and s.business_type = ? and s.status = 1) or (s.id in(" + sql1 + ") and s.business_type = ? and s.status = 0) ";
|
|
|
log.info("findAllByTypeAndStatus: sql " + sessionSQL);
|
|
|
log.info("findAllByTypeAndStatus: args " + [userId, businessType,userId,businessType]);
|
|
|
ImDb.execQuery({
|
|
|
"sql": sessionSQL,
|
|
|
"args": [userId, businessType,userId,businessType],
|
|
|
"handler": handler || function (err, res) {
|
|
|
if(err) log.error(err);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
}else{
|
|
|
sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? and participant_role ="+PARTICIPANT_ROLES.HOST+" group by w.session_id";
|
|
|
sessionSQL = "select * from "
|
|
|
+ DB_TABLES.Sessions + " s where s.id in(" + sql + ") and s.business_type in (?) ";
|
|
|
log.info("findAllByTypeAndStatus: sql : "+sessionSQL);
|
|
|
log.info("findAllByTypeAndStatus: args : "+[userId, businessType]);
|
|
|
ImDb.execQuery({
|
|
|
"sql": sessionSQL,
|
|
|
"args": [userId, businessType.split(",")],
|
|
|
"handler": handler || function (err, res) {
|
|
|
if(err) log.error(err);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
static findAllByType(userId, businessType,page,pagesize, handler) {
|
|
|
if (page > 0) {
|
|
|
if (page == 1) {
|