Beispiel #1
0
        private List <DbParameter> ListFilter(NewsListParam param, StringBuilder strSql, bool bNewsContent = false)
        {
            strSql.Append(@"SELECT  a.Id,
                                    a.BaseModifyTime,
                                    a.BaseModifierId,
                                    a.NewsTitle,
                                    a.ThumbImage,
                                    a.NewsTag,
                                    a.NewsAuthor,
                                    a.NewsSort,
                                    a.NewsDate,
                                    a.NewsType,
                                    a.ProvinceId,
                                    a.CityId,
                                    a.CountyId,
                                    a.ViewTimes");
            if (bNewsContent)
            {
                strSql.Append(",a.NewsContent");
            }
            strSql.Append(@"         FROM    SysNews a
                            WHERE   1 = 1");
            var parameter = new List <DbParameter>();

            if (param != null)
            {
                if (!string.IsNullOrEmpty(param.NewsTitle))
                {
                    strSql.Append(" AND a.NewsTitle like @NewsTitle");
                    parameter.Add(DbParameterExtension.CreateDbParameter("@NewsTitle", '%' + param.NewsTitle + '%'));
                }
                if (param.NewsType > 0)
                {
                    strSql.Append(" AND a.NewsType = @NewsType");
                    parameter.Add(DbParameterExtension.CreateDbParameter("@NewsType", param.NewsType));
                }
                if (!string.IsNullOrEmpty(param.NewsTag))
                {
                    strSql.Append(" AND a.NewsTag like @NewsTag");
                    parameter.Add(DbParameterExtension.CreateDbParameter("@NewsTag", '%' + param.NewsTag + '%'));
                }
                if (param.ProvinceId > 0)
                {
                    strSql.Append(" AND a.ProvinceId = @ProvinceId");
                    parameter.Add(DbParameterExtension.CreateDbParameter("@ProvinceId", param.ProvinceId));
                }
                if (param.CityId > 0)
                {
                    strSql.Append(" AND a.CityId = @CityId");
                    parameter.Add(DbParameterExtension.CreateDbParameter("@CityId", param.CityId));
                }
                if (param.CountyId > 0)
                {
                    strSql.Append(" AND a.CountId = @CountId");
                    parameter.Add(DbParameterExtension.CreateDbParameter("@CountyId", param.CountyId));
                }
            }
            return(parameter);
        }
Beispiel #2
0
        private List <DbParameter> ListFilter(NewsListParam param, StringBuilder strSql, bool bNewsContent = false)
        {
            strSql.Append(@"SELECT  a.id as Id,
                                    a.base_modify_time as BaseModifyTime,
                                    a.base_modifier_id as BaseModifierId,
                                    a.news_title as NewsTitle,
                                    a.thumb_image as ThumbImage,
                                    a.news_tag as NewsTag,
                                    a.news_author as NewsAuthor,
                                    a.news_sort as NewsSort,
                                    a.news_date as NewsDate,
                                    a.news_type as NewsType,
                                    a.province_id as ProvinceId,
                                    a.city_id as CityId,
                                    a.county_id as CountyId,
                                    a.view_times as ViewTimes");
            if (bNewsContent)
            {
                strSql.Append(",a.news_content as NewsContent");
            }
            strSql.Append(@"         FROM    sys_news a
                            WHERE   1 = 1");
            var parameter = new List <DbParameter>();

            if (param != null)
            {
                if (!string.IsNullOrEmpty(param.NewsTitle))
                {
                    strSql.Append(" AND a.news_title like @NewsTitle");
                    parameter.Add(DbParameterExtension.CreateDbParameter("@NewsTitle", '%' + param.NewsTitle + '%'));
                }
                if (param.NewsType > 0)
                {
                    strSql.Append(" AND a.news_type = @NewsType");
                    parameter.Add(DbParameterExtension.CreateDbParameter("@NewsType", param.NewsType));
                }
                if (!string.IsNullOrEmpty(param.NewsTag))
                {
                    strSql.Append(" AND a.news_tag like @NewsTag");
                    parameter.Add(DbParameterExtension.CreateDbParameter("@NewsTag", '%' + param.NewsTag + '%'));
                }
                if (param.ProvinceId > 0)
                {
                    strSql.Append(" AND a.province_id = @ProvinceId");
                    parameter.Add(DbParameterExtension.CreateDbParameter("@ProvinceId", param.ProvinceId));
                }
                if (param.CityId > 0)
                {
                    strSql.Append(" AND a.city_id = @CityId");
                    parameter.Add(DbParameterExtension.CreateDbParameter("@CityId", param.CityId));
                }
                if (param.CountyId > 0)
                {
                    strSql.Append(" AND a.county_id = @CountyId");
                    parameter.Add(DbParameterExtension.CreateDbParameter("@CountyId", param.CountyId));
                }
            }
            return(parameter);
        }
Beispiel #3
0
        public async Task <List <NewsEntity> > GetPageContentList(NewsListParam param, Pagination pagination)
        {
            var strSql = new StringBuilder();
            List <DbParameter> filter = ListFilter(param, strSql, true);
            var list = await this.BaseRepository().FindList <NewsEntity>(strSql.ToString(), filter.ToArray(), pagination);

            return(list.ToList());
        }
Beispiel #4
0
        public async Task <TData <List <NewsEntity> > > GetPageContentList(NewsListParam param, Pagination pagination)
        {
            TData <List <NewsEntity> > obj = new TData <List <NewsEntity> >();

            obj.Result = await newsService.GetPageContentList(param, pagination);

            obj.TotalCount = pagination.TotalCount;
            obj.Tag        = 1;
            return(obj);
        }
Beispiel #5
0
        public async Task <TData <List <NewsEntity> > > GetList(NewsListParam param)
        {
            TData <List <NewsEntity> > obj = new TData <List <NewsEntity> >();

            areaBLL.SetAreaParam(param);
            obj.Result = await newsService.GetList(param);

            obj.TotalCount = obj.Result.Count;
            obj.Tag        = 1;
            return(obj);
        }
Beispiel #6
0
        public async Task <TData <List <NewsEntity> > > GetPageList(NewsListParam param, Pagination pagination)
        {
            TData <List <NewsEntity> > obj = new TData <List <NewsEntity> >();

            areaBLL.SetAreaParam(param);
            obj.Data = await newsService.GetPageList(param, pagination);

            obj.Total = pagination.TotalCount;
            obj.Tag   = 1;
            return(obj);
        }
Beispiel #7
0
        public async Task <IActionResult> GetPageListJson(NewsListParam param, Pagination pagination)
        {
            TData <List <NewsEntity> > obj = await newsBLL.GetPageList(param, pagination);

            return(Json(obj));
        }
Beispiel #8
0
        public async Task <TData <List <NewsEntity> > > GetPageContentList([FromQuery] NewsListParam param, [FromQuery] Pagination pagination)
        {
            TData <List <NewsEntity> > obj = await newsBLL.GetPageContentList(param, pagination);

            return(obj);
        }