|
@@ -5,7 +5,9 @@ import (
|
|
|
// "strings"
|
|
// "strings"
|
|
|
|
|
|
|
|
"fohow.com/apps/models/live_model"
|
|
"fohow.com/apps/models/live_model"
|
|
|
|
|
+ "github.com/astaxie/beego"
|
|
|
"github.com/astaxie/beego/context"
|
|
"github.com/astaxie/beego/context"
|
|
|
|
|
+ "time"
|
|
|
|
|
|
|
|
// "api.com/apps/models/zt_model"
|
|
// "api.com/apps/models/zt_model"
|
|
|
|
|
|
|
@@ -14,8 +16,8 @@ import (
|
|
|
|
|
|
|
|
var (
|
|
var (
|
|
|
//以下Action无需登录校验,exceptCheckUserLoginAction = []string{"*"} *代表全部不需要
|
|
//以下Action无需登录校验,exceptCheckUserLoginAction = []string{"*"} *代表全部不需要
|
|
|
- exceptCheckUserLoginAction = []string{"GetCurrentLiveShow"}
|
|
|
|
|
- exceptCheckWxUserLoginAction = []string{"GetCurrentLiveShow"}
|
|
|
|
|
|
|
+ exceptCheckUserLoginAction = []string{"*"}
|
|
|
|
|
+ exceptCheckWxUserLoginAction = []string{"*"}
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
type LiveController struct {
|
|
type LiveController struct {
|
|
@@ -28,9 +30,48 @@ func (self *LiveController) Init(ctx *context.Context, controllerName, actionNam
|
|
|
self.ExceptCheckWxUserLoginAction = exceptCheckWxUserLoginAction
|
|
self.ExceptCheckWxUserLoginAction = exceptCheckWxUserLoginAction
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//根据广告位id,获取广告图
|
|
|
|
|
|
|
+//获取直播列表
|
|
|
func (self *LiveController) GetCurrentLiveShow() {
|
|
func (self *LiveController) GetCurrentLiveShow() {
|
|
|
live := live_model.GetCurrentShowLive(true)
|
|
live := live_model.GetCurrentShowLive(true)
|
|
|
self.Data["json"] = live
|
|
self.Data["json"] = live
|
|
|
self.ServeJSON()
|
|
self.ServeJSON()
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+//获取推介直播列表
|
|
|
|
|
+func (self *LiveController) Latest() {
|
|
|
|
|
+ recommend, _ := self.GetInt64("rd", 0)
|
|
|
|
|
+ page, _ := self.GetInt64("page")
|
|
|
|
|
+ perPage, _ := self.GetInt64("per_page")
|
|
|
|
|
+ cache, _ := self.GetBool("cache", false)
|
|
|
|
|
+ ptype := self.GetString("ptype")
|
|
|
|
|
+
|
|
|
|
|
+ if page <= 0 {
|
|
|
|
|
+ page = 1
|
|
|
|
|
+ }
|
|
|
|
|
+ if perPage <= 0 || perPage > 100 {
|
|
|
|
|
+ perPage = 20
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ type Ret struct {
|
|
|
|
|
+ List []*live_model.LiveBroad `json:"list"`
|
|
|
|
|
+ ListCount int64 `json:"list_count"`
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ lives := live_model.GetLatest(page, perPage, recommend, cache)
|
|
|
|
|
+ count := live_model.GetLatestCount(recommend, ptype, cache)
|
|
|
|
|
+ timeNowUnix := time.Now().Unix() - int64(8*60*60)
|
|
|
|
|
+ for _, live := range lives {
|
|
|
|
|
+ beego.BeeLogger.Warn("live_timeNowUnix: %d", timeNowUnix)
|
|
|
|
|
+ beego.BeeLogger.Warn("live-BeginDate.Unix: %d", live.BeginDate.Unix())
|
|
|
|
|
+ if live.BeginDate.Unix() < timeNowUnix {
|
|
|
|
|
+ live.State = "尚未开播"
|
|
|
|
|
+ } else if live.BeginDate.Unix() >= timeNowUnix && live.EndDate.Unix() > timeNowUnix {
|
|
|
|
|
+ live.State = "正在直播"
|
|
|
|
|
+ } else {
|
|
|
|
|
+ live.State = "直播结束"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ self.Data["json"] = &Ret{List: lives, ListCount: count}
|
|
|
|
|
+ self.ServeJSON()
|
|
|
|
|
+}
|