예제 #1
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "a";

            var column = await _columnService.GetByNum(Num);

            if (column != null)
            {
                if (Target.IsNotEmpty())
                {
                    output.Attributes.SetAttribute("target", Target);
                }

                output.Attributes.SetAttribute("href", $"/list/{(UrlNum.IsEmpty() ? column.Num : UrlNum)}");
                output.Attributes.SetAttribute("title", Title.IsEmpty() ? column.SeoTitle : Title);

                context.Items["Name"] = column.Name;

                TagHelperContent content = await output.GetChildContentAsync();

                if (content.IsEmptyOrWhiteSpace)
                {
                    output.Content.SetContent(column.Name);
                }
            }
        }
예제 #2
0
        public async Task <HandleResult> GetEdit([FromBody] JObject form)
        {
            var itemNum   = form["itemNum"].ToStr();
            var columnNum = form["columnNum"].ToStr();

            if (columnNum.IsEmpty())
            {
                return(HandleResult.Error("无效数据"));
            }

            var column = await _columnService.GetByNum(columnNum);

            if (column == null)
            {
                return(HandleResult.Error("无效数据"));
            }

            var model = await _modelTableService.GetByNum(column.ModelNum);

            if (model == null)
            {
                return(HandleResult.Error("栏目未绑定模型"));
            }

            ContentData editValue = null;

            if (column.IsSingle)
            {
                editValue = await _service.GetFirstByColumnNum(model.SqlTableName, column.Num);
            }
            else
            {
                if (itemNum.IsEmpty())
                {
                    return(HandleResult.Error("无效数据"));
                }
                editValue = await _service.GetByItem(model.SqlTableName, itemNum);
            }

            return(new HandleResult
            {
                IsSuccess = true,
                Data = editValue.ToDictionary()
            });
        }
예제 #3
0
        public async Task <HandleResult> GetSeo([FromBody] JObject form)
        {
            string num = form["num"].ToStr();

            if (num.IsEmpty())
            {
                return(HandleResult.Error("无效数据"));
            }

            var column = await _service.GetByNum(num);

            if (column == null)
            {
                return(HandleResult.Error("无效数据"));
            }

            return(HandleResult.Success(new
            {
                column.SeoTitle,
                column.SeoKeyword,
                column.SeoDesc
            }));
        }
예제 #4
0
        public async Task <IActionResult> Tag(string num, string tag, int current = 1)
        {
            if (num.IsEmpty() || tag.IsEmpty())
            {
                return(Error404());
            }

            var site = _siteService.GetCurrentSite();

            if (site == null)
            {
                return(Error404());
            }

            var column = await _columnService.GetByNum(num);

            if (column == null || column.SiteNum != site.Num)
            {
                return(Error404());
            }

            var model = column.ModelNum.IsEmpty() ? null : await _modelTableService.GetByNum(column.ModelNum);

            string folderName = site.IsMobileSite ? site.MobileSiteFolder : site.SiteFolder;

            string templatePath = $"Views/Content/{folderName}/{column.ListTemplatePath}";

            if (!System.IO.File.Exists(Path.GetFullPath(templatePath)))
            {
                return(Error404());
            }

            int size = 15;

            switch (column.Num)
            {
            case "9a32d00252853c5e":
                size = 3;
                break;
            }

            var req = new SqlServerPageRequest
            {
                Current = current,
                Size    = size,
                Queries = new List <IQuery>
                {
                    new DefaultQuery(column.Num, new DefaultQuerySql("columnNum")),
                    new DefaultQuery(false, new DefaultQuerySql("IsDel")),
                    new DefaultQuery($"&|&|&{tag}&|&|&", new DefaultQuerySql("CONCAT('&|&|&', Tag, '&|&|&')", QuerySymbol.Like))
                }
            };

            var seo = new ContentSeo(column);

            if (model != null)
            {
                var rep = await _contentService.Page(model.SqlTableName, req);

                ViewData.Model = new ContentList
                {
                    Column     = column,
                    ModelTable = model,
                    Site       = site,
                    Data       = rep.Data.Select(temp => new ContentData(temp)),
                    PageConfig = new PageConfig
                    {
                        Current     = req.Current,
                        Size        = req.Size,
                        Total       = rep.Total,
                        UrlTemplate = "/tag/" + column.Num + "/" + tag + "/{p}"
                    }
                };
            }

            ViewBag.Seo  = seo;
            ViewBag.Site = site;
            ViewBag.Tag  = tag;
            return(View($"~/{templatePath}"));
        }
예제 #5
0
파일: ContentService.cs 프로젝트: ntzw/cms
        public async Task <HandleResult> Edit(JObject form, string accountNum)
        {
            var itemNum   = form["num"].ToStr();
            var columnNum = form["columnNum"].ToStr();

            if (columnNum.IsEmpty())
            {
                return(HandleResult.Error("无效的提交数据"));
            }

            var column = await _columnService.GetByNum(columnNum);

            if (column == null)
            {
                return(HandleResult.Error("无效的提交数据"));
            }

            var model = await _modelTableService.GetByNum(column.ModelNum);

            if (model == null)
            {
                return(HandleResult.Error("栏目未绑定模型"));
            }

            ContentData oldData = null;

            if (column.IsSingle)
            {
                oldData = await GetFirstByColumnNum(model.SqlTableName, column.Num);
            }
            else if (itemNum.IsNotEmpty())
            {
                oldData = await GetByItem(model.SqlTableName, itemNum);
            }

            var id = oldData?.Id ?? 0;

            var contentEdit = new DynamicTableSqlHelper(model.SqlTableName);

            contentEdit.SetData(await _columnFieldService.GetByColumnNum(columnNum), form);
            contentEdit.AddFieldAndValue("SeoTitle", form["seoTitle"].ToStr());
            contentEdit.AddFieldAndValue("SeoKeyword", form["seoKeyword"].ToStr());
            contentEdit.AddFieldAndValue("SeoDesc", form["seoDesc"].ToStr());
            contentEdit.AddFieldAndValue("CategoryNum", form["categoryNum"].ToStr());
            contentEdit.AddFieldAndValue("IsTop", form["isTop"].ToBoolean());

            if (id > 0)
            {
                contentEdit.AddFieldAndValue("UpdateAccountNum", accountNum);
                contentEdit.AddFieldAndValue("UpdateDate", DateTime.Now);
            }
            else
            {
                contentEdit.AddFieldAndValue("Num", RandomHelper.CreateNum());
                contentEdit.AddFieldAndValue("CreateDate", DateTime.Now);
                contentEdit.AddFieldAndValue("UpdateDate", DateTime.Now);
                contentEdit.AddFieldAndValue("CreateAccountNum", accountNum);
                contentEdit.AddFieldAndValue("UpdateAccountNum", accountNum);
                contentEdit.AddFieldAndValue("IsDel", false);
                contentEdit.AddFieldAndValue("Status", 0);
                contentEdit.AddFieldAndValue("SiteNum", column.SiteNum);
                contentEdit.AddFieldAndValue("ColumnNum", columnNum);
            }

            return(id > 0 ? await Update(contentEdit, id) : await Add(contentEdit));
        }