예제 #1
0
        /// <summary>
        /// 帖吧管理时查询帖吧分页集合
        /// </summary>
        /// <param name="tenantTypeId">租户类型Id</param>
        /// <param name="query">帖吧查询条件</param>
        /// <param name="pageSize">每页多少条数据</param>
        /// <param name="pageIndex">页码</param>
        /// <returns>帖吧分页集合</returns>
        public PagingDataSet <BarSection> Gets(string tenantTypeId, BarSectionQuery query, int pageSize, int pageIndex)
        {
            var sql = Sql.Builder;

            sql.Select("spb_BarSections.*")
            .From("spb_BarSections");

            if (query.CategoryId != null && query.CategoryId.Value > 0)
            {
                CategoryService        categoryService = new CategoryService();
                IEnumerable <Category> categories      = categoryService.GetDescendants(query.CategoryId.Value);
                List <long>            categoryIds     = new List <long> {
                    query.CategoryId.Value
                };
                if (categories != null && categories.Count() > 0)
                {
                    categoryIds.AddRange(categories.Select(n => n.CategoryId));
                }
                sql.InnerJoin("tn_ItemsInCategories")
                .On("spb_BarSections.SectionId = tn_ItemsInCategories.ItemId")
                .Where("tn_ItemsInCategories.CategoryId in(@categoryIds)", new { categoryIds = categoryIds });
            }

            sql.Where("TenantTypeId = @0", tenantTypeId);

            if (query.UserId != null && query.UserId.Value > 0)
            {
                sql.Where("UserId = @0", query.UserId);
            }

            if (query.AuditStatus != null)
            {
                sql.Where("AuditStatus = @0", query.AuditStatus);
            }

            if (query.IsEnabled != null)
            {
                sql.Where("IsEnabled = @0", query.IsEnabled.Value);
            }



            //todo:libsh,by zhengw:等宝声加上工具方法后,重新调整此处
            if (!string.IsNullOrEmpty(query.NameKeyword))
            {
                sql.Where("Name like @0", StringUtility.StripSQLInjection(query.NameKeyword) + "%");
            }


            sql.OrderBy("DisplayOrder,SectionId desc");

            return(GetPagingEntities(pageSize, pageIndex, sql));
        }
예제 #2
0
 /// <summary>
 /// 帖吧管理时查询帖吧分页集合
 /// </summary>
 /// <param name="tenantTypeId">租户类型Id</param>
 /// <param name="query">帖吧查询条件</param>
 /// <param name="pageSize">每页多少条数据</param>
 /// <param name="pageIndex">页码</param>
 /// <returns>帖吧分页集合</returns>
 public PagingDataSet <BarSection> Gets(string tenantTypeId, BarSectionQuery query, int pageSize, int pageIndex)
 {
     //缓存周期:对象集合,需要维护即时性
     //使用用户选择器设置query.UserId参数
     return(barSectionRepository.Gets(tenantTypeId, query, pageSize, pageIndex));
 }