|
@ -22,7 +22,10 @@ class SessionRepo {
|
|
|
* @param handler
|
|
|
*/
|
|
|
static findOne(sessionId, handler) {
|
|
|
let sessionSQL = "select id,name,type,create_date,business_type,status,last_message_time,last_content,last_content_type,last_sender_id,last_sender_name from " + DB_TABLES.Sessions + " s where s.id = ?";
|
|
|
//let sessionSQL = "select id,name,type,create_date,business_type,status,last_message_time,last_content,last_content_type,last_sender_id,last_sender_name from " + DB_TABLES.Sessions + " s where s.id = ?";
|
|
|
let sessionSQL = "SELECT s.\"ID\" AS \"id\",s.\"NAME\" AS \"name\",s.\"TYPE\" AS \"type\",s.\"CREATE_DATE\" AS \"create_date\",s.\"BUSINESS_TYPE\" as \"business_type\"," +
|
|
|
"s.status as \"status\",s.last_message_time as \"last_message_time\",s.last_content as \"last_content\",s.last_content_type as \"last_content_type\",s.last_sender_id as \"last_sender_id\"," +
|
|
|
"s.last_sender_name as \"last_sender_name\" FROM " + DB_TABLES.Sessions + " s WHERE s.id = :ID";
|
|
|
ImDb.execQuery({
|
|
|
"sql": sessionSQL,
|
|
|
"args": [sessionId],
|
|
@ -61,7 +64,10 @@ class SessionRepo {
|
|
|
static findUnEndAll(userId, handler) {
|
|
|
let sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? and participant_role in(0,1) group by w.session_id";
|
|
|
let sys_session = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = 'system' and participant_role in(0,1) group by w.session_id";
|
|
|
let 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 "
|
|
|
// let 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 "
|
|
|
let sessionSQL = "select s.\"ID\" AS \"id\",s.\"NAME\" AS \"name\",s.\"TYPE\" AS \"type\",s.\"CREATE_DATE\" AS \"create_date\",s.\"BUSINESS_TYPE\" as \"business_type\"," +
|
|
|
"s.status as \"status\",s.last_message_time as \"last_message_time\",s.last_content as \"last_content\",s.last_content_type as \"last_content_type\",s.last_sender_id as \"last_sender_id\"," +
|
|
|
"s.last_sender_name as \"last_sender_name\" from "
|
|
|
+ DB_TABLES.Sessions + " s where s.id in(" + sql + ") and s.id not in ("+sys_session+") and s.`status` = 0";
|
|
|
ImDb.execQuery({
|
|
|
"sql": sessionSQL,
|
|
@ -82,7 +88,10 @@ class SessionRepo {
|
|
|
static findAllIgnoreRole(userId, handler) {
|
|
|
let sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? 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 = "select id, name, type, create_date,business_type, last_sender_id, last_sender_name, last_content_type, last_content, last_message_time,status from "
|
|
|
// let 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 "
|
|
|
let sessionSQL = "select s.\"ID\" AS \"id\",s.\"NAME\" AS \"name\",s.\"TYPE\" AS \"type\",s.\"CREATE_DATE\" AS \"create_date\",s.\"BUSINESS_TYPE\" as \"business_type\"," +
|
|
|
"s.status as \"status\",s.last_message_time as \"last_message_time\",s.last_content as \"last_content\",s.last_content_type as \"last_content_type\",s.last_sender_id as \"last_sender_id\"," +
|
|
|
"s.last_sender_name as \"last_sender_name\" from "
|
|
|
+ DB_TABLES.Sessions + " s where s.id in(" + sql + ") and s.id not in ("+sys_session+")";
|
|
|
ImDb.execQuery({
|
|
|
"sql": sessionSQL,
|
|
@ -102,7 +111,10 @@ class SessionRepo {
|
|
|
*/
|
|
|
static findAllByType(userId, type, handler) {
|
|
|
let sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? and type=? 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 "
|
|
|
// let sessionSQL = "select id, name, type, create_date, last_sender_id, last_sender_name, last_content_type, last_content, last_message_time from "
|
|
|
let sessionSQL = "select s.\"ID\" AS \"id\",s.\"NAME\" AS \"name\",s.\"TYPE\" AS \"type\",s.\"CREATE_DATE\" AS \"create_date\",s.\"BUSINESS_TYPE\" as \"business_type\"," +
|
|
|
"s.status as \"status\",s.last_message_time as \"last_message_time\",s.last_content as \"last_content\",s.last_content_type as \"last_content_type\",s.last_sender_id as \"last_sender_id\"," +
|
|
|
"s.last_sender_name as \"last_sender_name\" from "
|
|
|
+ DB_TABLES.Sessions + " s where s.id in(" + sql + ") ";
|
|
|
log.info("获取用户全部会话: sql :" + sql);
|
|
|
log.info("获取用户全部会话: args :" + args);
|
|
@ -124,7 +136,10 @@ 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 "
|
|
|
// let sessionSQL = "select id, name, type, create_date, last_sender_id, last_sender_name, last_content_type, last_content, last_message_time from "
|
|
|
let sessionSQL = "select s.\"ID\" AS \"id\",s.\"NAME\" AS \"name\",s.\"TYPE\" AS \"type\",s.\"CREATE_DATE\" AS \"create_date\",s.\"BUSINESS_TYPE\" as \"business_type\"," +
|
|
|
"s.status as \"status\",s.last_message_time as \"last_message_time\",s.last_content as \"last_content\",s.last_content_type as \"last_content_type\",s.last_sender_id as \"last_sender_id\"," +
|
|
|
"s.last_sender_name as \"last_sender_name\" from "
|
|
|
+ DB_TABLES.Sessions + " s where s.id in(" + sql + ") AND s.status = 0 ";
|
|
|
log.info("获取用户全部会话: sql :" + sessionSQL);
|
|
|
if(type){
|
|
@ -197,7 +212,10 @@ class SessionRepo {
|
|
|
}
|
|
|
|
|
|
sql +=" 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 "
|
|
|
// let sessionSQL = "select id, name, type, create_date, last_sender_id, last_sender_name, last_content_type, last_content, last_message_time from "
|
|
|
let sessionSQL = "select s.\"ID\" AS \"id\",s.\"NAME\" AS \"name\",s.\"TYPE\" AS \"type\",s.\"CREATE_DATE\" AS \"create_date\",s.\"BUSINESS_TYPE\" as \"business_type\"," +
|
|
|
"s.status as \"status\",s.last_message_time as \"last_message_time\",s.last_content as \"last_content\",s.last_content_type as \"last_content_type\",s.last_sender_id as \"last_sender_id\"," +
|
|
|
"s.last_sender_name as \"last_sender_name\" from "
|
|
|
+ DB_TABLES.Sessions + " s where s.id in(" + sql + ") and s.type in("+type+") ";
|
|
|
|
|
|
if(status != null && status != ""){
|
|
@ -236,7 +254,10 @@ class SessionRepo {
|
|
|
}
|
|
|
|
|
|
let sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_role <>0 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 "
|
|
|
// let sessionSQL = "select id, name, type, create_date, last_sender_id, last_sender_name, last_content_type, last_content, last_message_time from "
|
|
|
let sessionSQL = "select s.\"ID\" AS \"id\",s.\"NAME\" AS \"name\",s.\"TYPE\" AS \"type\",s.\"CREATE_DATE\" AS \"create_date\",s.\"BUSINESS_TYPE\" as \"business_type\"," +
|
|
|
"s.status as \"status\",s.last_message_time as \"last_message_time\",s.last_content as \"last_content\",s.last_content_type as \"last_content_type\",s.last_sender_id as \"last_sender_id\"," +
|
|
|
"s.last_sender_name as \"last_sender_name\" from "
|
|
|
+ DB_TABLES.Sessions + " s where s.id not in(" + sql + ") and s.type in("+type+") ";
|
|
|
|
|
|
if(status != null && status != ""){
|
|
@ -270,7 +291,10 @@ class SessionRepo {
|
|
|
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 " +
|
|
|
// sessionSQL = "select s.* from " + DB_TABLES.Sessions + " s, " + DB_TABLES.Participants + " p " +
|
|
|
sessionSQL = "select s.\"ID\" AS \"id\",s.\"NAME\" AS \"name\",s.\"TYPE\" AS \"type\",s.\"CREATE_DATE\" AS \"create_date\",s.\"BUSINESS_TYPE\" as \"business_type\"," +
|
|
|
"s.status as \"status\",s.last_message_time as \"last_message_time\",s.last_content as \"last_content\",s.last_content_type as \"last_content_type\",s.last_sender_id as \"last_sender_id\"," +
|
|
|
"s.last_sender_name as \"last_sender_name\" 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 limit "+page+","+pagesize;
|
|
@ -286,7 +310,10 @@ class SessionRepo {
|
|
|
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 "
|
|
|
// sessionSQL = "select * from "
|
|
|
sessionSQL = "select s.\"ID\" AS \"id\",s.\"NAME\" AS \"name\",s.\"TYPE\" AS \"type\",s.\"CREATE_DATE\" AS \"create_date\",s.\"BUSINESS_TYPE\" as \"business_type\"," +
|
|
|
"s.status as \"status\",s.last_message_time as \"last_message_time\",s.last_content as \"last_content\",s.last_content_type as \"last_content_type\",s.last_sender_id as \"last_sender_id\"," +
|
|
|
"s.last_sender_name as \"last_sender_name\" 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) limit "+page+","+pagesize;
|
|
|
log.info("findAllByTypeAndStatus: sql " + sessionSQL);
|
|
|
log.info("findAllByTypeAndStatus: args " + [userId, businessType,userId,businessType]);
|
|
@ -302,7 +329,10 @@ class SessionRepo {
|
|
|
|
|
|
}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 "
|
|
|
// sessionSQL = "select * from "
|
|
|
sessionSQL = "select s.\"ID\" AS \"id\",s.\"NAME\" AS \"name\",s.\"TYPE\" AS \"type\",s.\"CREATE_DATE\" AS \"create_date\",s.\"BUSINESS_TYPE\" as \"business_type\"," +
|
|
|
"s.status as \"status\",s.last_message_time as \"last_message_time\",s.last_content as \"last_content\",s.last_content_type as \"last_content_type\",s.last_sender_id as \"last_sender_id\"," +
|
|
|
"s.last_sender_name as \"last_sender_name\" from "
|
|
|
+ DB_TABLES.Sessions + " s where s.id in(" + sql + ") and s.business_type in (?) and s.status = ? limit "+page+","+pagesize;
|
|
|
log.info("findAllByTypeAndStatus: sql : "+sessionSQL);
|
|
|
log.info("findAllByTypeAndStatus: args : "+[userId, businessType,status]);
|
|
@ -326,7 +356,10 @@ class SessionRepo {
|
|
|
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 " +
|
|
|
// sessionSQL = "select s.* from " + DB_TABLES.Sessions + " s, " + DB_TABLES.Participants + " p " +
|
|
|
sessionSQL = "select s.\"ID\" AS \"id\",s.\"NAME\" AS \"name\",s.\"TYPE\" AS \"type\",s.\"CREATE_DATE\" AS \"create_date\",s.\"BUSINESS_TYPE\" as \"business_type\"," +
|
|
|
"s.status as \"status\",s.last_message_time as \"last_message_time\",s.last_content as \"last_content\",s.last_content_type as \"last_content_type\",s.last_sender_id as \"last_sender_id\"," +
|
|
|
"s.last_sender_name as \"last_sender_name\" 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 ";
|
|
@ -342,7 +375,10 @@ class SessionRepo {
|
|
|
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 "
|
|
|
// sessionSQL = "select * from "
|
|
|
sessionSQL = "select s.\"ID\" AS \"id\",s.\"NAME\" AS \"name\",s.\"TYPE\" AS \"type\",s.\"CREATE_DATE\" AS \"create_date\",s.\"BUSINESS_TYPE\" as \"business_type\"," +
|
|
|
"s.status as \"status\",s.last_message_time as \"last_message_time\",s.last_content as \"last_content\",s.last_content_type as \"last_content_type\",s.last_sender_id as \"last_sender_id\"," +
|
|
|
"s.last_sender_name as \"last_sender_name\" 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]);
|
|
@ -358,7 +394,10 @@ class SessionRepo {
|
|
|
|
|
|
}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 "
|
|
|
// sessionSQL = "select * from "
|
|
|
sessionSQL = "select s.\"ID\" AS \"id\",s.\"NAME\" AS \"name\",s.\"TYPE\" AS \"type\",s.\"CREATE_DATE\" AS \"create_date\",s.\"BUSINESS_TYPE\" as \"business_type\"," +
|
|
|
"s.status as \"status\",s.last_message_time as \"last_message_time\",s.last_content as \"last_content\",s.last_content_type as \"last_content_type\",s.last_sender_id as \"last_sender_id\"," +
|
|
|
"s.last_sender_name as \"last_sender_name\" from "
|
|
|
+ DB_TABLES.Sessions + " s where s.id in(" + sql + ") and s.business_type in (?) and s.status = ? ";
|
|
|
log.info("findAllByTypeAndStatus: sql : "+sessionSQL);
|
|
|
log.info("findAllByTypeAndStatus: args : "+[userId, businessType,status]);
|
|
@ -382,7 +421,10 @@ class SessionRepo {
|
|
|
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 " +
|
|
|
// sessionSQL = "select s.* from " + DB_TABLES.Sessions + " s, " + DB_TABLES.Participants + " p " +
|
|
|
sessionSQL = "select s.\"ID\" AS \"id\",s.\"NAME\" AS \"name\",s.\"TYPE\" AS \"type\",s.\"CREATE_DATE\" AS \"create_date\",s.\"BUSINESS_TYPE\" as \"business_type\"," +
|
|
|
"s.status as \"status\",s.last_message_time as \"last_message_time\",s.last_content as \"last_content\",s.last_content_type as \"last_content_type\",s.last_sender_id as \"last_sender_id\"," +
|
|
|
"s.last_sender_name as \"last_sender_name\" 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 ";
|
|
@ -398,7 +440,10 @@ class SessionRepo {
|
|
|
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 "
|
|
|
// sessionSQL = "select * from "
|
|
|
sessionSQL = "select s.\"ID\" AS \"id\",s.\"NAME\" AS \"name\",s.\"TYPE\" AS \"type\",s.\"CREATE_DATE\" AS \"create_date\",s.\"BUSINESS_TYPE\" as \"business_type\"," +
|
|
|
"s.status as \"status\",s.last_message_time as \"last_message_time\",s.last_content as \"last_content\",s.last_content_type as \"last_content_type\",s.last_sender_id as \"last_sender_id\"," +
|
|
|
"s.last_sender_name as \"last_sender_name\" 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]);
|
|
@ -414,7 +459,10 @@ class SessionRepo {
|
|
|
|
|
|
}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 "
|
|
|
// sessionSQL = "select * from "
|
|
|
sessionSQL = "select s.\"ID\" AS \"id\",s.\"NAME\" AS \"name\",s.\"TYPE\" AS \"type\",s.\"CREATE_DATE\" AS \"create_date\",s.\"BUSINESS_TYPE\" as \"business_type\"," +
|
|
|
"s.status as \"status\",s.last_message_time as \"last_message_time\",s.last_content as \"last_content\",s.last_content_type as \"last_content_type\",s.last_sender_id as \"last_sender_id\"," +
|
|
|
"s.last_sender_name as \"last_sender_name\" 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]);
|
|
@ -445,7 +493,10 @@ class SessionRepo {
|
|
|
//sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? and participant_role ="+PARTICIPANT_ROLES.HOST+" group by w.session_id";
|
|
|
//中山医院无法查询到所有会话记录,暂时取消participant_role的判断条件 20190619
|
|
|
sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? group by w.session_id";
|
|
|
sessionSQL = "select * from "
|
|
|
// sessionSQL = "select * from "
|
|
|
sessionSQL = "select s.\"ID\" AS \"id\",s.\"NAME\" AS \"name\",s.\"TYPE\" AS \"type\",s.\"CREATE_DATE\" AS \"create_date\",s.\"BUSINESS_TYPE\" as \"business_type\"," +
|
|
|
"s.status as \"status\",s.last_message_time as \"last_message_time\",s.last_content as \"last_content\",s.last_content_type as \"last_content_type\",s.last_sender_id as \"last_sender_id\"," +
|
|
|
"s.last_sender_name as \"last_sender_name\" from "
|
|
|
+ DB_TABLES.Sessions + " s where s.id in(" + sql + ") and s.business_type = ? and s.type!=0 order by s.last_message_time desc limit "+page+","+pagesize;
|
|
|
ImDb.execQuery({
|
|
|
"sql": sessionSQL,
|
|
@ -460,7 +511,10 @@ class SessionRepo {
|
|
|
//sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? and participant_role ="+PARTICIPANT_ROLES.HOST+" group by w.session_id";
|
|
|
//中山医院无法查询到所有会话记录,暂时取消participant_role的判断条件 20190619
|
|
|
sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? group by w.session_id";
|
|
|
sessionSQL = "select * from "
|
|
|
// sessionSQL = "select * from "
|
|
|
sessionSQL = "select s.\"ID\" AS \"id\",s.\"NAME\" AS \"name\",s.\"TYPE\" AS \"type\",s.\"CREATE_DATE\" AS \"create_date\",s.\"BUSINESS_TYPE\" as \"business_type\"," +
|
|
|
"s.status as \"status\",s.last_message_time as \"last_message_time\",s.last_content as \"last_content\",s.last_content_type as \"last_content_type\",s.last_sender_id as \"last_sender_id\"," +
|
|
|
"s.last_sender_name as \"last_sender_name\" from "
|
|
|
+ DB_TABLES.Sessions + " s where s.id in(" + sql + ") and s.type!=0 order by s.last_message_time desc limit "+page+","+pagesize;
|
|
|
ImDb.execQuery({
|
|
|
"sql": sessionSQL,
|
|
@ -485,7 +539,7 @@ class SessionRepo {
|
|
|
* @param handler
|
|
|
*/
|
|
|
static findAllByTimestampAndType(userId, dateSpan, handler) {
|
|
|
let sql = "SELECT DISTINCT s.id, CASE WHEN TYPE = 2 THEN d.name ELSE s.name END 'name',s.last_content_type, s.type, s.create_date, s.business_type " +
|
|
|
let sql = "SELECT DISTINCT s.id as \"id\", CASE WHEN TYPE = 2 THEN d.name ELSE s.name END \"name\",s.last_content_type as \"last_content_type\", s.type as \"type\", s.create_date as \"create_date\", s.business_type as \"business_type\" " +
|
|
|
"FROM sessions s, participants p " +
|
|
|
"LEFT JOIN doctors d ON p.participant_id = d.id " +
|
|
|
"WHERE s.id = p.session_id AND s.last_sender_id <> 'system' " +
|
|
@ -511,7 +565,7 @@ class SessionRepo {
|
|
|
*/
|
|
|
static findStickySessions(userId, handler) {
|
|
|
let sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? group by w.session_id";
|
|
|
let sessionSQL = "select s.id,s.name,s.type,s.create_date from " + DB_TABLES.Sessions + " s," + DB_TABLES.StickySessions + " ss where s.id = ss.session_id s.id in(" + sql + ")";
|
|
|
let sessionSQL = "select s.id as \"id\",s.name as \"name\",s.type as \"type\",s.create_date as \"create_date\" from " + DB_TABLES.Sessions + " s," + DB_TABLES.StickySessions + " ss where s.id = ss.session_id s.id in(" + sql + ")";
|
|
|
ImDb.execQuery({
|
|
|
"sql": sessionSQL,
|
|
|
"args": [userId],
|
|
@ -532,11 +586,14 @@ class SessionRepo {
|
|
|
* @param handler
|
|
|
*/
|
|
|
static saveSession(sessionId, name, type, createDate, businessType, handler) {
|
|
|
let sql = "insert into " + DB_TABLES.Sessions + " (id, name, type, create_date,business_type) VALUES (?,?,?,?,?) " +
|
|
|
"ON DUPLICATE KEY UPDATE name = ?,type = ?";
|
|
|
// let sql = "insert into " + DB_TABLES.Sessions + "(id, name, type, create_date,business_type) VALUES (?,?,?,?,?) " +
|
|
|
// "ON DUPLICATE KEY UPDATE name = ?,type = ?";
|
|
|
let sql = "merge into " +DB_TABLES.Sessions+ " t1 using( select ? id,? name,? type from dual) t2 on (t1.id=t2.id) " +
|
|
|
"WHEN MATCHED THEN update set t1.name = t2.name,t1.type=t2.type " +
|
|
|
"WHEN NOT MATCHED THEN INSERT (id, name, type, create_date,business_type) VALUES (?,?,?,?,?)"
|
|
|
ImDb.execQuery({
|
|
|
"sql": sql,
|
|
|
"args": [sessionId, name, type, createDate, businessType, name,type],
|
|
|
"args": [sessionId, name, type,sessionId, name, type, createDate, businessType],
|
|
|
"handler": handler || function (err, res) {
|
|
|
if(err) log.error(err);
|
|
|
}
|