同步操作将从 xiezunjin/DocHub 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package AdminControllersimport ("strings""github.com/TruthHun/DocHub/helper/conv""github.com/TruthHun/DocHub/models""github.com/astaxie/beego/orm")type CrawlController struct {BaseController}//采集管理func (this *CrawlController) Get() {Type := this.GetString("type", "gitbook") //默认是gitbookp, _ := this.GetInt("p", 1) //页码listRows := 20 //每页显示记录数//分类var cates []models.Categorymodels.O.QueryTable(models.TableCategory).OrderBy("Sort", "Title").All(&cates)//标题关键字Title := this.GetString("title")Topic := this.GetString("topic")var (TotalRows int64 = 0 //默认总记录数data []orm.Params)switch Type {case "gitbook":cond := orm.NewCondition().And("Id__gt", 0)if len(Title) > 0 {cond = cond.And("Title__contains", Title)}if len(Topic) > 0 {cond = cond.And("Topics__icontains", Topic)}data, _, _ = models.GetList("gitbook", p, listRows, cond, "PublishPdf", "PublishEpub", "PublishMobi", "-Stars")TotalRows = models.Count(models.TableGitbook, cond)}this.Data["IsCrawl"] = truethis.Data["CatesJson"], _ = conv.InterfaceToJson(cates)this.Data["Cates"] = catesthis.Data["Data"] = datathis.Data["Type"] = Typethis.Data["topic"] = Topicthis.Data["title"] = Titlethis.Data["TotalRows"] = TotalRowsthis.TplName = "index.html"}//Gitbook发布func (this *CrawlController) PublishGitbook() {if models.GlobalGitbookPublishing {this.ResponseJson(0, "存在正在发布的GitBook")}Chanel, _ := this.GetInt("Chanel") //频道Parent, _ := this.GetInt("Parent") //父类Children, _ := this.GetInt("Children") //子类Uid, _ := this.GetInt("Uid") //发布人idIds := this.GetString("Ids") //文档idif Chanel*Parent*Children*Uid == 0 || len(Ids) == 0 {this.ResponseJson(0, "所有选项均为必填项")}//标记为正在发布models.GlobalGitbookPublishing = true//查询电子书IdsArr := strings.Split(Ids, ",")//执行发布操作go models.ModelGitbook.PublishBooks(Chanel, Parent, Children, Uid, IdsArr)this.ResponseJson(1, "GitBook发布操作提交成功,程序自会执行发布操作")}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。