bing преди 3 години
родител
ревизия
801bf9b82b
променени са 3 файла, в които са добавени 19 реда и са изтрити 6 реда
  1. 2 1
      src/server/endpoints/v2/session.endpoint.js
  2. 2 2
      src/server/models/sessions/sessions.js
  3. 15 3
      src/server/repository/mysql/session.repo.js

+ 2 - 1
src/server/endpoints/v2/session.endpoint.js

@ -236,6 +236,7 @@ router.get(APIv2.Sessions.SessionListByType, function (req, res) {
    let type = req.query.type;
    let status = req.query.status;
    let name = req.query.name;
    let searchType = req.query.search_type;//p2p会话类型 1医生 2患者
    if (!page) {
        throw {httpStatus: 406, message: 'Missing page.'};
    }
@ -255,7 +256,7 @@ router.get(APIv2.Sessions.SessionListByType, function (req, res) {
    let sessions = new Sessions();
    ControllerUtil.regModelEventHandler(sessions, res);
    sessions.getUserSessionsByType(userId,type,page,size,status,name);
    sessions.getUserSessionsByType(userId,type,page,size,status,name,searchType);
});
router.get(APIv2.Sessions.SessionListByNoParticipant, function (req, res) {

+ 2 - 2
src/server/models/sessions/sessions.js

@ -933,7 +933,7 @@ class Sessions extends RedisModel {
     * @param businessType
     * @param status 0:进行中的会话1:结束的会话
     */
    getUserSessionsByType(userId,type,page, size,status,name) {
    getUserSessionsByType(userId,type,page, size,status,name,searchType) {
        logger.info("根据用户类型获取用户的session列表1: ");
        let userSessionKey = RedisModel.makeRedisKey(REDIS_KEYS.UserSessions, userId);
        let self = this;
@ -941,7 +941,7 @@ class Sessions extends RedisModel {
        async.waterfall([
            // 获取会话ID列表
            function (callback) {
                SessionRepo.findListByType(userId,type,page,size,status,name,function(err,res){
                SessionRepo.findListByType(userId,type,page,size,status,name,searchType,function(err,res){
                    logger.info("根据用户类型获取用户的session列表: res :"+res);
                    if (res == null || res.length == 0) {
                        ModelUtil.emitOK(self.eventEmitter, []);

+ 15 - 3
src/server/repository/mysql/session.repo.js

@ -10,6 +10,7 @@ const DB_TABLES = require('../../include/commons').DB_TABLES;
const PARTICIPANT_ROLES = require('../../include/commons').PARTICIPANT_ROLES;
const SESSION_STATUS = require('../../include/commons').SESSION_STATUS;
const SESSION_BUSINESS_TYPE = require('../../include/commons').SESSION_BUSINESS_TYPE;
const SESSION_TYPES = require('../../include/commons').SESSION_TYPES;
class SessionRepo {
    constructor() {
    }
@ -166,7 +167,7 @@ class SessionRepo {
     * @param type
     * @param handler
     */
    static findListByType(userId, type,page,pagesize, status,name,handler) {
    static findListByType(userId, type,page,pagesize, status,name,searchType,handler) {
        log.info("type="+type);
        if (page > 0) {
            if (page == 1) {
@ -181,10 +182,21 @@ class SessionRepo {
         * userId 为传值时:管理员调度大屏获取im消息
         */
        if (userId != null && userId != "") {
            sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id in(?) group by w.session_id";
            sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id in(?)";
            if (searchType!= null&&type==SESSION_TYPES.P2P){
                if (1==searchType){
                    sql += "and EXISTS( select p.id from participants ww  INNER JOIN doctors p on p.id = ww.participant_id " +
                        "  where ww.session_id  = w.session_id and p.id<>'"+userId+"' )"
                }if (2==searchType){
                    sql += " and EXISTS( select p.id from participants ww  INNER JOIN patients p on p.id = ww.participant_id " +
                        "  where ww.session_id  = w.session_id and p.id<>'"+userId+"' ) ";
                }
            }
        } else {
            sql = "select session_id from " + DB_TABLES.Participants + " w group by w.session_id"
            sql = "select session_id from " + DB_TABLES.Participants + " w "
        }
        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 "
            + DB_TABLES.Sessions + " s where s.id in(" + sql + ") and s.type in("+type+") ";