public async Task <IActionResult> GetDoctorTopicAsync([FromBody] GetDoctorTopicRequestDto request) { var doctorBiz = new DoctorBiz(); var response = await doctorBiz.GetDoctorTopicAsync(request); foreach (var item in response.CurrentPage) { if (item.SponsorGuid != request.DoctorGuid) { item.Consultants = item.SponsorName; } else if (item.ReceiverGuid != request.DoctorGuid) { item.Consultants = item.ReceiverName; } item.LastMessage = (await doctorBiz.GetTopicLastMessageAsync(item.TopicGuid)); } return(Success(response)); }
/// <summary> /// 获取消息对话列表 /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <GetDoctorTopicResponseDto> GetDoctorTopicAsync(GetDoctorTopicRequestDto request) { //TopicModel var whereSql = "1=1 and enable=1"; if (!string.IsNullOrWhiteSpace(request.DoctorGuid)) { whereSql = $"{whereSql} and( receiver_guid=@DoctorGuid or sponsor_guid=@DoctorGuid )"; } if (request.BeginDate != null) { request.BeginDate = request.BeginDate?.Date; whereSql = $"{whereSql} AND creation_date > @BeginDate"; } if (request.EndDate != null) { request.EndDate = request.EndDate?.AddDays(1).Date; whereSql = $"{whereSql} AND creation_date < @EndDate"; } var orderbySql = "creation_date desc"; string sql = $@" SELECT * FROM( SELECT a.*, b.user_name AS receiver_name, c.user_name AS sponsor_name FROM t_utility_topic a LEFT JOIN t_utility_user b ON a.receiver_guid = b.user_guid LEFT JOIN t_utility_user c ON a.sponsor_guid = c.user_guid )__T WHERE {whereSql} ORDER BY {orderbySql} "; return(await MySqlHelper.QueryByPageAsync <GetDoctorTopicRequestDto, GetDoctorTopicResponseDto, GetDoctorTopicItemDto>(sql, request)); }