广告管理
()
| 867 | |
| 868 | // 广告管理 |
| 869 | func (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 | // 更行书籍书籍的排序 |
| 910 | func (this *ManagerController) UpdateBookSort() { |
nothing calls this directly
no test coverage detected