|
@ -15,7 +15,7 @@ class SessionRepo {
|
|
|
* @param handler
|
|
|
*/
|
|
|
static getUserSessionsFromMysql(userId,handler){
|
|
|
let sql ="select select session_id from participants w where w.participaint_id = ? group by w.session_id";
|
|
|
let sql ="select session_id from participants w where w.participaint_id = ? group by w.session_id";
|
|
|
let sessionsql = "select id,name,type,create_date from session s where s.id in("+sql+")";
|
|
|
ImDb.execQuery({
|
|
|
"sql": sessionsql,
|
|
@ -31,6 +31,28 @@ class SessionRepo {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取置顶的消息
|
|
|
* @param userId
|
|
|
* @param handler
|
|
|
*/
|
|
|
static getUserStickSessionsFromMysql(userId,handler){
|
|
|
let sql ="select session_id from participants w where w.participaint_id = ? group by w.session_id";
|
|
|
let sessionsql = "select s.id,s.name,s.type,s.create_date from session s,sticky_sessions ss where s.id = ss.session_id s.id in("+sql+")";
|
|
|
ImDb.execQuery({
|
|
|
"sql": sessionsql,
|
|
|
"args": [userId],
|
|
|
"handler": function (err, res) {
|
|
|
if(err) {
|
|
|
log.error("sql:"+sessionsql+"data:userId:"+userId);
|
|
|
}else{
|
|
|
log.info("getMysqlUserSessions success by userId :"+userId);
|
|
|
}
|
|
|
handler(err,res);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取session单个对象
|
|
|
* @param sessionId
|
|
@ -75,6 +97,35 @@ class SessionRepo {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
static stickSession(sessionId,user,score){
|
|
|
let sql ="insert into "+IMTABLE.STICKY_SESSION+" (user_id,session_id,score) VALUES (?,?,?) ";
|
|
|
ImDb.execQuery({
|
|
|
"sql": sql,
|
|
|
"args": [user,sessionId,score],
|
|
|
"handler": function (err, res) {
|
|
|
if(err) {
|
|
|
log.error("sql:"+sql+"data:sessionId:"+sessionId+",user:"+user+",score:"+score);
|
|
|
}else{
|
|
|
log.info("save stickSession to mysql is success by session :"+sessionId);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
static unstickSession(sessionId,user){
|
|
|
let sql ="delete from "+IMTABLE.STICKY_SESSION+" where user_id=? and session_id=? ";
|
|
|
ImDb.execQuery({
|
|
|
"sql": sql,
|
|
|
"args": [user,sessionId],
|
|
|
"handler": function (err, res) {
|
|
|
if(err) {
|
|
|
log.error("sql:"+sql+"data:sessionId:"+sessionId+",user:"+user);
|
|
|
}else{
|
|
|
log.info("delete unstickSession to mysql is success by session :"+sessionId);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
module.exports = SessionRepo;
|