public async Task <IEnumerable <GetOfficeTreeItemDto> > GetOfficeListAsync(GetOfficeListRequestDto request) { using (var conn = MySqlHelper.GetConnection()) { var hospitalGuid = conn.QueryFirstOrDefault <string>("SELECT hospital_guid FROM t_doctor_hospital LIMIT 1"); var whereSql = $"where 1=1 "; if (!string.IsNullOrWhiteSpace(request.Name)) { whereSql = $"{whereSql} and (office_name=@Name or parentName=@Name)"; } var sql = $@" SELECT * FROM ( SELECT a.office_name, a.sort, a.ENABLE, a.Picture_Guid, b.office_name AS parentName FROM t_doctor_office a LEFT JOIN t_doctor_office b ON a.parent_office_guid = b.office_guid Where a.hospital_guid='{hospitalGuid}' ORDER BY a.sort DESC,a.creation_date DESC )___T {whereSql} "; var result = await conn.QueryAsync <GetOfficeTreeItemDto>(sql, new { request.Name }); return(result); } }
public async Task <IEnumerable <GetOfficeListItemDto> > GetOfficeListAsync(GetOfficeListRequestDto request) { var whereSql = "where 1=1"; if (!string.IsNullOrWhiteSpace(request.Name)) { whereSql = $"{whereSql} and (office_name=@Name or parentName=@Name)"; } var sql = $@" SELECT * FROM ( SELECT DISTINCT a.office_name, a.sort, a.ENABLE, b.office_name AS parentName FROM t_doctor_office a LEFT JOIN t_doctor_office b ON a.parent_office_guid = b.office_guid )___T {whereSql} ORDER BY sort DESC"; using (var conn = MySqlHelper.GetConnection()) { var result = await conn.QueryAsync <GetOfficeListItemDto>(sql, new { request.Name }); return(result); } }
public async Task <IActionResult> GetOfficeListAsync([FromBody] GetOfficeListRequestDto request) { OfficeBiz officeBiz = new OfficeBiz(); var officeModels = await officeBiz.GetOfficeListAsync(request); var response = officeModels.GetTree(null, a => a.ParentName, a => a.OfficeName, a => new GetOfficeTreeItemDto { OfficeName = a.OfficeName, ParentName = a.ParentName, Enable = a.Enable, Sort = a.Sort, PictureGuid = a.PictureGuid, }); return(Success(response)); }