|
@ -33,6 +33,29 @@ class SearchRepo {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询正常会话及议题已结束的会话(P2P, MUC)
|
|
|
|
*
|
|
|
|
* @param userId
|
|
|
|
* @param handler
|
|
|
|
*/
|
|
|
|
static findTopicActiveSessionIdList(userId, handler) {
|
|
|
|
let sql = "SELECT s.id " +
|
|
|
|
"FROM sessions s, topics t, participants p " +
|
|
|
|
"WHERE p.participant_id = ? AND p.session_id = s.id AND s.id = t.session_id AND t.end_message_id IS NULL AND s.`type` IN (1,2) " +
|
|
|
|
" UNION " +
|
|
|
|
"SELECT s.id " +
|
|
|
|
"FROM sessions s, participants p " +
|
|
|
|
"WHERE p.participant_id = ? AND p.session_id = s.id AND s.`type` IN (2,3) and s.id not in(" +
|
|
|
|
" select DISTINCT p1.session_id from participants p1 ,topics t where p1.participant_id = ? and t.session_id = p1.session_id " +
|
|
|
|
") ";
|
|
|
|
ImDb.execQuery({
|
|
|
|
sql: sql,
|
|
|
|
args: [userId, userId,userId],
|
|
|
|
handler: handler
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 全部搜索
|
|
* 全部搜索
|
|
*
|
|
*
|
|
@ -87,14 +110,14 @@ class SearchRepo {
|
|
* @param handler
|
|
* @param handler
|
|
*/
|
|
*/
|
|
static searchUser(sessionIdList,userId, keyword, userTable, page, size, handler) {
|
|
static searchUser(sessionIdList,userId, keyword, userTable, page, size, handler) {
|
|
let sql = "SELECT DISTINCT u.name user_name,s.id session_id, s.name session_name, s.type session_type, s.business_type, u.id user_id,u.sex, u.birthdate, u.avatar %s " +
|
|
|
|
|
|
let sql = "SELECT DISTINCT u.name user_name,s.id session_id, s.name session_name, s.type session_type, s.business_type, u.id user_id,u.sex, u.birthdate, u.avatar,u.idcard %s " +
|
|
" FROM participants p, " + userTable +
|
|
" FROM participants p, " + userTable +
|
|
" u,sessions s WHERE s.id in (?) AND s.id = p.session_id AND p.participant_id = u.id and p.participant_id<>? AND u.name like ? ";
|
|
|
|
|
|
" u,sessions s WHERE s.id in (?) AND s.id = p.session_id AND p.participant_id = u.id and p.participant_id<>? AND (u.name like ? or u.idcard like ?) ";
|
|
|
|
|
|
if (userTable === DB_TABLES.Doctors) {
|
|
if (userTable === DB_TABLES.Doctors) {
|
|
sql += " AND s.type in (2) ";
|
|
|
|
|
|
sql += " AND s.type in (2) and s.business_type = 1 ";
|
|
}else{
|
|
}else{
|
|
sql += " AND s.type in (1,2) ";
|
|
|
|
|
|
sql += " AND s.type in (1,2) and s.business_type = 2 ";
|
|
}
|
|
}
|
|
sql += " limit ?, ? ";
|
|
sql += " limit ?, ? ";
|
|
sql = vsprintf(sql, [userTable == DB_TABLES.Doctors ? ', hospital_name' : '']);
|
|
sql = vsprintf(sql, [userTable == DB_TABLES.Doctors ? ', hospital_name' : '']);
|
|
@ -102,7 +125,7 @@ class SearchRepo {
|
|
keyword = '%' + keyword + '%';
|
|
keyword = '%' + keyword + '%';
|
|
ImDb.execQuery({
|
|
ImDb.execQuery({
|
|
sql: sql,
|
|
sql: sql,
|
|
args: [sessionIdList,userId, keyword, page * size, size],
|
|
|
|
|
|
args: [sessionIdList,userId, keyword,keyword, page * size, size],
|
|
handler: handler
|
|
handler: handler
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@ -158,8 +181,7 @@ class SearchRepo {
|
|
static userForge(res) {
|
|
static userForge(res) {
|
|
res.forEach(function (user) {
|
|
res.forEach(function (user) {
|
|
if (!user.avatar) user.avatar = "";
|
|
if (!user.avatar) user.avatar = "";
|
|
|
|
|
|
user.birthdate = user.birthdate ? ObjectUtil.timestampToLong(user.birthdate) : "";
|
|
|
|
|
|
user.birthdate = user.birthdate ? user.birthdate.getTime():"";
|
|
});
|
|
});
|
|
|
|
|
|
return res;
|
|
return res;
|