Beispiel #1
0
        public async Task <IActionResult> GetHealthManagers([FromQuery]
                                                            GetHealthManagerListRequestDto request)
        {
            var managerBiz = new HealthManagerBiz();

            var response = await managerBiz.GetHealthManagers(request);

            return(Success(response));
        }
Beispiel #2
0
        /// <summary>
        /// 查询健康管理师分页列表
        /// </summary>
        /// <param name="requestDto"></param>
        /// <returns></returns>
        public async Task <GetHealthManagerListResponseDto> GetHealthManagers(GetHealthManagerListRequestDto requestDto)
        {
            var sql = @"select 
                            m.manager_guid,
							m.user_name,
							m.gender,m.phone,
                            concat(p.base_path, p.relative_path) as portrait_img,
							m.creation_date as registration_time,
							m.`enable`,
							IFNULL(
                                (
                                SELECT count(t.health_manager_guid) 
                                FROM t_consumer as t 
                                WHERE t.health_manager_guid is NOT NULL AND t.health_manager_guid = m.manager_guid
                                ),0) 
                        as `count`
                        from t_health_manager as m
                        left join t_utility_accessory AS p on m.portrait_guid = p.accessory_guid
                        where 1 = 1";

            if (!string.IsNullOrEmpty(requestDto.KeyWord))
            {
                sql = $"{sql} and (m.user_name like '%{requestDto.KeyWord}%' or m.phone like '%{requestDto.KeyWord}%')";
            }

            if (requestDto.RegistrationTime.HasValue && requestDto.EndTime.HasValue)
            {
                requestDto.EndTime = requestDto.EndTime.Value.AddDays(1);

                sql = $"{sql} and m.creation_date >= @RegistrationTime and m.creation_date < @EndTime";
            }

            sql = $"{sql} order by m.creation_date desc";

            return(await MySqlHelper.QueryByPageAsync <GetHealthManagerListRequestDto, GetHealthManagerListResponseDto, GetHealthManagerItem>(sql, requestDto));
        }