Przeglądaj źródła

用户历史记录查询优化

WH01243 3 lat temu
rodzic
commit
3a438faf16
1 zmienionych plików z 2 dodań i 2 usunięć
  1. 2 2
      service/message_mail_box.go

+ 2 - 2
service/message_mail_box.go

@@ -285,8 +285,8 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) (*[]map[strin
 			countSql = "SELECT  count(b.id)  FROM   socialize_message_mailbox a   LEFT JOIN socialize_message b ON a.messag_id = b.id   LEFT JOIN socialize_chat_session c ON   IF   ( a.send_user_type = 1, c.id = a.send_user_id, c.id = a.receive_user_id )   LEFT JOIN socialize_tenant_robot d ON c.ent_id = d.ent_id       WHERE   a.own_type = 1    AND c.ent_id = " + quitl.InterfaceToStr(in.EntId) + "   AND c.user_id = " + quitl.InterfaceToStr(in.SendId) + "    AND (a.type = 5 or a.type=4 or a.type = 5  or  a.type=6 or  a.type=7)  " + lastStr
 		} else {
 			//用户聊天记录查看
-			sqlStr = "SELECT a.messag_id as messageId,  b.*,   IF   ( a.own_id = a.send_user_id, 1, 2 ) AS fool ,   a.send_user_type,   a.type as  itemType,   d.nickname as  robotName,   d.headimage as  robotImg,   c.customer_service_name as  setName   FROM   socialize_message_mailbox a   LEFT JOIN socialize_message b ON a.messag_id = b.id   LEFT JOIN socialize_chat_session c ON   IF   ( a.send_user_type = 1, c.id = a.send_user_id, c.id = a.receive_user_id )    left join  socialize_tenant_robot d on  c.ent_id=d.ent_id    WHERE   a.own_type = 2    AND c.ent_id = " + quitl.InterfaceToStr(in.SendId) + "    AND a.own_id = " + quitl.InterfaceToStr(in.NewUserId) + "     AND ( a.type = 4 OR a.type = 5 or a.type=6 or  a.type=7) " + lastStr + "    ORDER BY a.create_time desc ,a.id   asc limit 0 ,  " + quitl.InterfaceToStr(in.PageSize)
-			countSql = "SELECT   count(a.id)  FROM   socialize_message_mailbox a   LEFT JOIN socialize_message b ON a.messag_id = b.id   LEFT JOIN socialize_chat_session c ON   IF   ( a.send_user_type = 1, c.id = a.send_user_id, c.id = a.receive_user_id )    left join  socialize_tenant_robot d on  c.ent_id=d.ent_id      WHERE   a.own_type = 2    AND c.ent_id =" + quitl.InterfaceToStr(in.SendId) + "    AND a.own_id =" + quitl.InterfaceToStr(in.NewUserId) + "    AND ( a.type = 4 OR a.type = 5  or a.type=6 or  a.type=7) " + lastStr
+			sqlStr = "SELECT a.messag_id as messageId,  b.*,   IF   ( a.own_id = a.send_user_id, 1, 2 ) AS fool ,   a.send_user_type,   a.type as  itemType,   d.nickname as  robotName,   d.headimage as  robotImg,   c.customer_service_name as  setName   FROM   socialize_message_mailbox a   LEFT JOIN socialize_message b ON a.messag_id = b.id   LEFT JOIN socialize_chat_session c ON   IF   ( a.send_user_type = 1, c.id = a.send_user_id, c.id = a.receive_user_id )    left join  socialize_tenant_robot d on  c.ent_id=d.ent_id    WHERE   a.own_type = 2    AND c.ent_id = " + quitl.InterfaceToStr(in.SendId) + "    AND a.own_id = " + quitl.InterfaceToStr(in.NewUserId) + " +AND a.own_id = " + quitl.InterfaceToStr(in.NewUserId) + "   AND ( a.type = 4 OR a.type = 5 or a.type=6 or  a.type=7) " + lastStr + "    ORDER BY a.create_time desc ,a.id   asc limit 0 ,  " + quitl.InterfaceToStr(in.PageSize)
+			countSql = "SELECT   count(a.id)  FROM   socialize_message_mailbox a   LEFT JOIN socialize_message b ON a.messag_id = b.id   LEFT JOIN socialize_chat_session c ON   IF   ( a.send_user_type = 1, c.id = a.send_user_id, c.id = a.receive_user_id )    left join  socialize_tenant_robot d on  c.ent_id=d.ent_id      WHERE   a.own_type = 2    AND c.ent_id =" + quitl.InterfaceToStr(in.SendId) + "    AND a.own_id =" + quitl.InterfaceToStr(in.NewUserId) + " AND c.user_id =" + quitl.InterfaceToStr(in.NewUserId) + "    AND ( a.type = 4 OR a.type = 5  or a.type=6 or  a.type=7) " + lastStr
 		}
 		break
 	}