MCPcopy Index your code
hub / github.com/TruthHun/BookStack / Ads

Method Ads

controllers/ManagerController.go:869–907  ·  view source on GitHub ↗

广告管理

()

Source from the content-addressed store, hash-verified

867
868// 广告管理
869func (this *ManagerController) Ads() {
870 if this.Ctx.Request.Method == http.MethodPost {
871 pid, _ := this.GetInt("pid")
872 if pid <= 0 {
873 this.JsonResult(1, "请选择广告位")
874 }
875 ads := &models.AdsCont{
876 Title: this.GetString("title"),
877 Code: this.GetString("code"),
878 Status: true,
879 Pid: pid,
880 }
881 start, err := dateparse.ParseAny(this.GetString("start"))
882 if err != nil {
883 start = time.Now()
884 }
885 end, err := dateparse.ParseAny(this.GetString("end"))
886 if err != nil {
887 end = time.Now().Add(24 * time.Hour * 730)
888 }
889 ads.Start = int(start.Unix())
890 ads.End = int(end.Unix())
891 _, err = orm.NewOrm().Insert(ads)
892 if err != nil {
893 this.JsonResult(1, err.Error())
894 }
895 go models.UpdateAdsCache()
896 this.JsonResult(0, "新增广告成功")
897 } else {
898 layout := "2006-01-02"
899 this.Data["Mobile"] = this.GetString("mobile", "0")
900 this.Data["Positions"] = models.NewAdsCont().GetPositions()
901 this.Data["Lists"] = models.NewAdsCont().Lists(this.GetString("mobile", "0") == "1")
902 this.Data["IsAds"] = true
903 this.Data["Now"] = time.Now().Format(layout)
904 this.Data["Next"] = time.Now().Add(time.Hour * 24 * 730).Format(layout)
905 this.TplName = "manager/ads.html"
906 }
907}
908
909// 更行书籍书籍的排序
910func (this *ManagerController) UpdateBookSort() {

Callers

nothing calls this directly

Calls 7

UpdateAdsCacheFunction · 0.92
NewAdsContFunction · 0.92
JsonResultMethod · 0.80
GetPositionsMethod · 0.80
AddMethod · 0.45
InsertMethod · 0.45
ListsMethod · 0.45

Tested by

no test coverage detected