예제 #1
0
        public async Task <IActionResult> GetHistoryMessageListStartByTopMsgAsync([FromQuery] GetHistoryMessageListStartByTopMsgRequestDto requestDto)
        {
            var biz   = new MessageBiz();
            var model = await biz.GetAsync(requestDto.TopMsgId);

            if (model != null)
            {
                requestDto.TopMsgDate = model?.CreationDate;
            }
            var result = await biz.GetHistoryMessageListStartByTopMsgAsync(requestDto);

            return(Success(result));
        }
예제 #2
0
        /// <summary>
        /// 通过顶部消息Id获取历史消息记录
        /// </summary>
        /// <param name="requestDto"></param>
        /// <returns></returns>
        public async Task <List <GetHistoryMessageListStartByTopMsgResponseDto> > GetHistoryMessageListStartByTopMsgAsync(GetHistoryMessageListStartByTopMsgRequestDto requestDto)
        {
            var sqlWhere = string.Empty;

            if (!string.IsNullOrWhiteSpace(requestDto.TopMsgId))
            {
                sqlWhere = "and a.creation_date<@TopMsgDate";
            }
            using (var conn = MySqlHelper.GetConnection())
            {
                var sql    = $@"SELECT
                                a.msg_guid,
	                            a.from_guid,
	                            a.to_guid,
	                            a.context,
	                            a.creation_date,
                                a.is_html
                            FROM
	                            t_utility_message a
	                            INNER JOIN t_utility_topic topic ON a.topic_guid = topic.topic_guid 
                            WHERE
	                            topic.about_type = 'Doctor' 
	                            AND a.`enable` = 1 
	                            AND topic.`enable` = 1 
	                            {sqlWhere}
	                            AND (
	                            ( topic.sponsor_guid = @UserId1 AND topic.receiver_guid = @UserId2 ) 
	                            OR ( topic.sponsor_guid = @UserId2 AND topic.receiver_guid = @UserId1 ) 
	                            ) 
                            ORDER BY
	                            a.creation_date DESC
	                            limit @PageSize"    ;
                var result = await conn.QueryAsync <GetHistoryMessageListStartByTopMsgResponseDto>(sql, requestDto);

                return(result?.ToList());
            }
        }