/// <summary> /// 获取医生列表 /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <GetDoctorListResponseDto> GetDoctorListAsync(GetDoctorListRequestDto request) { var sqlWhere = $@"AND ENABLE = 1 and `status`='approved' and enable=1"; if (request.Gender != null) { sqlWhere = $"{sqlWhere} AND gender = '{(request.Gender.Value == 0 ? "F" : "M")}'"; } if (request.IsExpert != null) { sqlWhere = $"{sqlWhere} AND IsExpert = {(request.IsExpert.Value ? "'1'" : "'0'")}"; } var sqlOrderBy = "creation_date desc"; switch (request.Sort) { case GetDoctorListRequestDto.SortMenu.Score: sqlOrderBy = "score desc"; break; case GetDoctorListRequestDto.SortMenu.Experience: sqlOrderBy = "work_age desc"; break; default: sqlOrderBy = "creation_date desc"; break; } var sql = $@" SELECT * FROM( SELECT A.*, E.config_name, ifnull(E.extension_field,'0') as IsExpert, E.extension_field, F.gender, F.user_name AS DoctorName, (SELECT AVG( D.score ) FROM t_consumer_comment D WHERE D.target_guid = A.doctor_guid GROUP BY D.target_guid ) AS score, CONCAT( G.base_path, G.relative_path ) AS Picture, CONCAT( H.base_path, H.relative_path ) AS HospitalPicture FROM t_doctor A LEFT JOIN t_doctor_hospital B ON A.hospital_guid = B.hospital_guid LEFT JOIN t_doctor_office C ON C.office_guid = A.office_guid LEFT JOIN t_manager_dictionary E ON E.dic_guid = A.title_guid LEFT JOIN t_utility_user F ON F.user_guid = A.doctor_guid LEFT JOIN t_utility_accessory G ON G.accessory_guid = A.portrait_guid LEFT JOIN t_utility_accessory H ON H.accessory_guid = A.portrait_guid )T WHERE 1 = 1 {sqlWhere} ORDER BY {sqlOrderBy}" ; return(await MySqlHelper.QueryByPageAsync <GetDoctorListRequestDto, GetDoctorListResponseDto, GetDoctorListItemDto>(sql, request)); }
public async Task <IActionResult> GetDoctorListAsync([FromBody] GetDoctorListRequestDto request) { var response = await new DoctorBiz().GetDoctorListAsync(request); return(Success(response)); }