コード例 #1
0
        public ContentResult listschool(SchoolQueryRequest request)
        {
            var data = _schoolService.List(request);
            var res  = new ResultDto <SchoolResponse>
            {
                page    = request.PageIndex,
                total   = request.Total,
                records = request.Records,
                rows    = data
            };

            return(Content(res.Serialize()));
        }
コード例 #2
0
        //学校列表
        public List <SchoolResponse> List(SchoolQueryRequest request)
        {
            List <SchoolResponse> list = new List <SchoolResponse>();

            try
            {
                StringBuilder join = new StringBuilder();
                if (request.EnglishName.IsNotEmpty())
                {
                    request.EnglishName = $"%{request.EnglishName}%";
                    join.Append(" and englishname like @EnglishName");
                }
                if (request.ChinessName.IsNotEmpty())
                {
                    request.ChinessName = $"%{request.ChinessName}%";
                    join.Append(" and chinessname like @ChinessName");
                }
                if (request.ProvinceId.HasValue && request.ProvinceId > 0)
                {
                    join.Append(" and provinceId = @ProvinceId");
                }
                if (request.CityId.HasValue && request.CityId > 0)
                {
                    join.Append(" and cityId = @CityId");
                }
                var sql = $@"select a.*,b.name as ProvinceName,c.name as CityName from t_sys_school a 
                            left join t_sys_province b on a.provinceId=b.id
                            left join t_sys_city c on a.cityId=c.id
                            where isdelete=0 {join.ToString()} order by a.createtime desc ";

                int totalCount = 0;
                list            = _dbContext.Page <SchoolResponse>(sql, out totalCount, request.PageIndex, request.PageSize, request);
                request.Records = totalCount;
            }
            catch (Exception ex)
            {
                LogUtils.LogError("SchoolService.List", ex);
            }
            return(list);
        }