123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- package http
- import (
- "time"
- "go-common/app/interface/main/esports/model"
- arcmdl "go-common/app/service/main/archive/api"
- "go-common/library/ecode"
- bm "go-common/library/net/http/blademaster"
- )
- func filterMatch(c *bm.Context) {
- p := new(model.ParamFilter)
- if err := c.Bind(p); err != nil {
- return
- }
- if p.Stime != "" {
- if _, err := time.Parse("2006-01-02", p.Stime); err != nil {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- }
- c.JSON(eSvc.FilterMatch(c, p))
- }
- func listContest(c *bm.Context) {
- var (
- mid int64
- err error
- total int
- list []*model.Contest
- )
- if midStr, ok := c.Get("mid"); ok {
- mid = midStr.(int64)
- }
- p := new(model.ParamContest)
- if err = c.Bind(p); err != nil {
- return
- }
- if p.Stime != "" {
- if _, err = time.Parse("2006-01-02", p.Stime); err != nil {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- }
- if p.Etime != "" {
- if _, err = time.Parse("2006-01-02", p.Etime); err != nil {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- }
- if list, total, err = eSvc.ListContest(c, mid, p); err != nil {
- c.JSON(nil, err)
- return
- }
- data := make(map[string]interface{}, 2)
- page := map[string]int{
- "num": p.Pn,
- "size": p.Ps,
- "total": total,
- }
- data["page"] = page
- data["list"] = list
- c.JSON(data, nil)
- }
- func appContest(c *bm.Context) {
- var (
- mid int64
- err error
- total int
- list []*model.Contest
- )
- if midStr, ok := c.Get("mid"); ok {
- mid = midStr.(int64)
- }
- p := new(model.ParamContest)
- if err = c.Bind(p); err != nil {
- return
- }
- if p.Stime != "" {
- if _, err = time.Parse("2006-01-02", p.Stime); err != nil {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- p.Etime = p.Stime
- }
- if list, total, err = eSvc.ListContest(c, mid, p); err != nil {
- c.JSON(nil, err)
- return
- }
- data := make(map[string]interface{}, 2)
- page := map[string]int{
- "num": p.Pn,
- "size": p.Ps,
- "total": total,
- }
- data["page"] = page
- data["list"] = list
- c.JSON(data, nil)
- }
- func calendar(c *bm.Context) {
- var err error
- p := new(model.ParamFilter)
- if err = c.Bind(p); err != nil {
- return
- }
- if _, err = time.Parse("2006-01-02", p.Stime); err != nil {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- if _, err = time.Parse("2006-01-02", p.Etime); err != nil {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- c.JSON(eSvc.Calendar(c, p))
- }
- func filterVideo(c *bm.Context) {
- p := new(model.ParamFilter)
- if err := c.Bind(p); err != nil {
- return
- }
- c.JSON(eSvc.FilterVideo(c, p))
- }
- func listVideo(c *bm.Context) {
- var (
- err error
- total int
- list []*arcmdl.Arc
- )
- p := new(model.ParamVideo)
- if err = c.Bind(p); err != nil {
- return
- }
- if list, total, err = eSvc.ListVideo(c, p); err != nil {
- c.JSON(nil, err)
- return
- }
- data := make(map[string]interface{}, 2)
- page := map[string]int{
- "num": p.Pn,
- "size": p.Ps,
- "total": total,
- }
- data["page"] = page
- data["list"] = list
- c.JSON(data, nil)
- }
- func actVideos(c *bm.Context) {
- var (
- err error
- )
- param := new(struct {
- MmID int64 `form:"mm_id" validate:"gt=0"`
- })
- if err = c.Bind(param); err != nil {
- return
- }
- c.JSON(eSvc.ActModules(c, param.MmID))
- }
- func active(c *bm.Context) {
- var (
- err error
- )
- param := new(struct {
- Aid int64 `form:"aid" validate:"gt=0"`
- })
- if err = c.Bind(param); err != nil {
- return
- }
- c.JSON(eSvc.ActPage(c, param.Aid))
- }
- func actPoints(c *bm.Context) {
- var (
- mid int64
- err error
- total int
- list []*model.Contest
- )
- if midStr, ok := c.Get("mid"); ok {
- mid = midStr.(int64)
- }
- p := new(model.ParamActPoint)
- if err = c.Bind(p); err != nil {
- return
- }
- if list, total, err = eSvc.ActPoints(c, mid, p); err != nil {
- c.JSON(nil, err)
- return
- }
- data := make(map[string]interface{}, 2)
- page := map[string]int{
- "num": p.Pn,
- "size": p.Ps,
- "total": total,
- }
- data["page"] = page
- data["list"] = list
- c.JSON(data, nil)
- }
- func actKnockout(c *bm.Context) {
- var (
- err error
- )
- param := new(struct {
- MdID int64 `form:"md_id" validate:"gt=0"`
- })
- if err = c.Bind(param); err != nil {
- return
- }
- c.JSON(eSvc.ActKnockout(c, param.MdID))
- }
- func actTop(c *bm.Context) {
- var (
- mid int64
- err error
- total int
- list []*model.Contest
- )
- if midStr, ok := c.Get("mid"); ok {
- mid = midStr.(int64)
- }
- p := new(model.ParamActTop)
- if err = c.Bind(p); err != nil {
- return
- }
- if p.Stime != "" {
- if _, err = time.Parse("2006-01-02", p.Stime); err != nil {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- }
- if p.Etime != "" {
- if _, err = time.Parse("2006-01-02", p.Etime); err != nil {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- }
- if list, total, err = eSvc.ActTop(c, mid, p); err != nil {
- c.JSON(nil, err)
- return
- }
- data := make(map[string]interface{}, 2)
- page := map[string]int{
- "num": p.Pn,
- "size": p.Ps,
- "total": total,
- }
- data["page"] = page
- data["list"] = list
- c.JSON(data, nil)
- }
- func search(c *bm.Context) {
- var (
- mid int64
- buvid string
- err error
- )
- p := new(model.ParamSearch)
- if err = c.Bind(p); err != nil {
- return
- }
- if ck, err := c.Request.Cookie("buvid3"); err == nil {
- buvid = ck.Value
- }
- if midInter, ok := c.Get("mid"); ok {
- mid = midInter.(int64)
- }
- c.JSON(eSvc.Search(c, mid, p, buvid))
- }
- func season(c *bm.Context) {
- var (
- err error
- total int
- list []*model.Season
- )
- p := new(model.ParamSeason)
- if err = c.Bind(p); err != nil {
- return
- }
- if list, total, err = eSvc.Season(c, p); err != nil {
- c.JSON(nil, err)
- return
- }
- data := make(map[string]interface{}, 2)
- page := map[string]int{
- "num": p.Pn,
- "size": p.Ps,
- "total": total,
- }
- data["page"] = page
- data["list"] = list
- c.JSON(data, nil)
- }
- func appSeason(c *bm.Context) {
- var (
- err error
- total int
- list []*model.Season
- )
- p := new(model.ParamSeason)
- if err = c.Bind(p); err != nil {
- return
- }
- if list, total, err = eSvc.AppSeason(c, p); err != nil {
- c.JSON(nil, err)
- return
- }
- data := make(map[string]interface{}, 2)
- page := map[string]int{
- "num": p.Pn,
- "size": p.Ps,
- "total": total,
- }
- data["page"] = page
- data["list"] = list
- c.JSON(data, nil)
- }
- func contest(c *bm.Context) {
- var (
- mid int64
- err error
- )
- if midStr, ok := c.Get("mid"); ok {
- mid = midStr.(int64)
- }
- param := new(struct {
- Cid int64 `form:"cid" validate:"gt=0"`
- })
- if err = c.Bind(param); err != nil {
- return
- }
- c.JSON(eSvc.Contest(c, mid, param.Cid))
- }
- func recent(c *bm.Context) {
- var (
- mid int64
- err error
- )
- if midStr, ok := c.Get("mid"); ok {
- mid = midStr.(int64)
- }
- param := &model.ParamCDRecent{}
- if err = c.Bind(param); err != nil {
- return
- }
- c.JSON(eSvc.Recent(c, mid, param))
- }
|