Browse Source

成员变化的时候时间更新为空问题处理

8 years ago
parent
commit
57b5ae0be7

+ 5 - 5
src/server/models/search/object.searcher.js

@ -42,7 +42,7 @@ class ObjectSearcher extends RedisModel {
                function (sessionIdList, keyword, targetRole, entityType, callback) {
                    var sessionList=[];
                    for(var j in sessionIdList){
                        sessionList.push(sessionIdList[j].id);
                        sessionList.push(sessionIdList[j].id||sessionIdList[j]);
                    }
                    if(sessionList.length==0){
                        callback(null, "");
@ -56,25 +56,25 @@ class ObjectSearcher extends RedisModel {
                    // 综合搜索与分类搜索
                    if (entityType === 'all') {
                        SearchRepo.searchAll(sessionList, keyword, userTable, function (err, res) {
                        SearchRepo.searchAll(sessionList,userId, keyword, userTable, function (err, res) {
                            if (err) return callback(err, null);
                            callback(null, res);
                        });
                    } else if (entityType === 'user') {
                        SearchRepo.searchUser(sessionList, keyword, userTable, page, size, function (err, res) {
                        SearchRepo.searchUser(sessionList,userId, keyword, userTable, page, size, function (err, res) {
                            if (err) return callback(err, null);
                            callback(null, {users: SearchRepo.userForge(res)});
                        });
                    } else if (entityType === 'session') {
                        SearchRepo.searchSessions(sessionList, keyword, page, size, function (err, res) {
                        SearchRepo.searchSessions(sessionList,userId, keyword, page, size, function (err, res) {
                            if (err) return callback(err, null);
                            callback(null, {sessions: SearchRepo.sessionForge(res, keyword)});
                        });
                    } else if (entityType === 'message') {
                        SearchRepo.searchMessages(sessionList, keyword, page, size, function (err, res) {
                        SearchRepo.searchMessages(sessionList,userId, keyword, page, size, function (err, res) {
                            if (err) return callback(err, null);
                            callback(null, {messages: SearchRepo.messageForge(res)});

+ 4 - 2
src/server/models/user/users.js

@ -338,8 +338,10 @@ class Users extends RedisModel {
                        "sql": "select case when count(*) > 0 then true else false end 'is_patient' from patients where id = ?",
                        "args": [userId],
                        "handler": function (err, res) {
                            if (err) callback(err, res);
                            if (err) {
                                callback(err, res);
                                return;
                            }
                            callback(null, res);
                        }
                    });

+ 23 - 26
src/server/repository/mysql/search.repo.js

@ -41,12 +41,12 @@ class SearchRepo {
     * @param userTable
     * @param handler
     */
    static searchAll(sessionIdList, keyword, userTable, handler) {
    static searchAll(sessionIdList,userId, keyword, userTable, handler) {
        let data = {};
        async.waterfall([
            function (callback) {
                SearchRepo.searchUser(sessionIdList, keyword, userTable, 0, 3, function (err, res) {
                SearchRepo.searchUser(sessionIdList,userId, keyword, userTable, 0, 4, function (err, res) {
                    if (err) return handler(err, null);
                    let buffer = SearchRepo.userForge(res);
@ -56,7 +56,7 @@ class SearchRepo {
                });
            },
            function (callback) {
                SearchRepo.searchSessions(sessionIdList, keyword, 0, 3, function (err, res) {
                SearchRepo.searchSessions(sessionIdList,userId, keyword, 0, 4, function (err, res) {
                    if (err) return handler(err, null);
                    data.sessions = SearchRepo.sessionForge(res, keyword);
@ -65,7 +65,7 @@ class SearchRepo {
                })
            },
            function (callback) {
                SearchRepo.searchMessages(sessionIdList, keyword, 0, 3, function (err, res) {
                SearchRepo.searchMessages(sessionIdList,userId, keyword, 0, 4, function (err, res) {
                    if (err) return handler(err, null);
                    data.messages = SearchRepo.messageForge(res);
@ -86,22 +86,23 @@ class SearchRepo {
     * @param size
     * @param handler
     */
    static searchUser(sessionIdList, keyword, userTable, page, size, handler) {
        let sql = "SELECT DISTINCT s.id session_id, s.name session_name, s.type session_type, s.business_type, u.id user_id, u.name user_name, u.sex, u.birthdate, u.avatar %s" +
            " FROM sessions s, participants p, " + userTable +
            " u WHERE s.id in (?) AND s.id = p.session_id AND p.participant_id = u.id AND u.name like ? ";
    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 " +
            " 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 ? ";
        if (userTable === DB_TABLES.Doctors) {
            sql += " AND s.type in (2,3) ";
            sql += " AND s.type in (2) ";
        }else{
            sql += " AND s.type in (1,2) ";
        }
        sql += " limit ?, ? ";
        sql = vsprintf(sql, [userTable == DB_TABLES.Doctors ? ', hospital_name' : '']);
        keyword = '%' + keyword + '%';
        ImDb.execQuery({
            sql: sql,
            args: [sessionIdList, keyword, page * size, size],
            args: [sessionIdList,userId, keyword, page * size, size],
            handler: handler
        });
    }
@ -109,25 +110,21 @@ class SearchRepo {
    /**
     * 会话搜索。搜索会话名称与会话成员的名称。若有一个符合,就选中。
     */
    static searchSessions(sessionIdList, keyword, page, size, handler) {
        if (sessionIdList.length == 0) {
    static searchSessions(sessionIdList,userId, keyword, page, size, handler) {
          if (sessionIdList.length == 0) {
            return handler(null, []);
        }
        let sql = "SELECT * FROM(" +
            "SELECT s.id, s.name, s.type, s.create_date, s.business_type, u.name participant_name " +
            "FROM sessions s, participants p, doctors u " +
            "WHERE s.id IN (?) AND s.id = p.session_id AND p.participant_id = u.id AND (s.name LIKE ? or u.name like ?) " +
            " UNION " +
            "SELECT s.id, s.name, s.type, s.create_date, s.business_type, u.name participant_name " +
            "FROM sessions s, participants p, patients u " +
            "WHERE s.id IN (?) AND s.id = p.session_id AND p.participant_id = u.id AND (s.name LIKE ? or u.name like ?) " +
            "SELECT s.id, s.name, s.type, s.create_date, s.business_type,GROUP_CONCAT(u. NAME) as participant_name " +
            "FROM sessions s,  doctors u ,participants p " +
            "WHERE s.id IN (?) and s.type = 3 AND s.id = p.session_id AND p.participant_id = u.id and p.participant_id<>? AND (u.name like ? or s.name like ?) group by s.id " +
            ") X LIMIT ?, ?";
        keyword = '%' + keyword + '%';
        ImDb.execQuery({
            sql: sql,
            args: [sessionIdList, keyword, keyword, sessionIdList, keyword, keyword, page * size, size],
            args: [sessionIdList,userId, keyword,keyword, page * size, size],
            handler: handler
        });
    }
@ -135,7 +132,7 @@ class SearchRepo {
    /**
     * 消息搜索
     */
    static searchMessages(sessionIdList, keyword, page, size, handler) {
    static searchMessages(sessionIdList,userId, keyword, page, size, handler) {
        let sql = "SELECT * FROM(" +
            "SELECT s.id session_id, s.name session_name, s.type session_type, s.business_type session_business_type, m.id message_id, m.sender_id, m.sender_name, m.timestamp, m.content " +
            "FROM sessions s, muc_messages m " +
@ -174,21 +171,21 @@ class SearchRepo {
        let lastSessionId = null;
        let tempSession = null;
        res.forEach(function (session) {
            if (session.session_id !== lastSessionId) {
                lastSessionId = session.session_id;
            if (session.id !== lastSessionId) {
                lastSessionId = session.id;
                tempSession = {
                    id: session.id,
                    name: session.name,
                    type: session.type,
                    business_type: session.business_type,
                    /*create_date: ObjectUtil.timestampToLong(session.create_date),*/
                    participants: []
                    members: []
                };
                result.push(tempSession);
            }
            if (session.participant_name.indexOf(keyword) >= 0) tempSession.participants.push({name: session.participant_name});
            if (session.participant_name.indexOf(keyword) >= 0) tempSession.members.push({name: session.participant_name});
        });
        return result;

+ 3 - 3
src/server/resources/config/config.dev.js

@ -19,9 +19,9 @@ let redisConfig = {
// 三师后台
let wlyyServerConfig = {
    host: '192.168.131.104',
    port: 8090,
    model:""
    host: '172.19.103.87',
    port: 9092,
    model:"/wlyy"
};
// 个推AppStore版参数