others.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package http
  2. import (
  3. "go-common/app/interface/main/tv/model"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. // get splash
  8. func transcode(c *bm.Context) {
  9. v := new(model.ReqTransode)
  10. err := c.Bind(v)
  11. if err != nil {
  12. return
  13. }
  14. c.JSON(nil, auditSvc.Transcode(v))
  15. }
  16. // get splash
  17. func hotword(c *bm.Context) {
  18. hotword := gobSvc.Hotword
  19. if hotword == nil {
  20. c.JSON(nil, ecode.ServiceUnavailable)
  21. return
  22. }
  23. c.JSON(hotword, nil)
  24. }
  25. // get splash
  26. func splash(c *bm.Context) {
  27. v := new(struct {
  28. Channel string `form:"channel" validate:"required"`
  29. })
  30. err := c.Bind(v)
  31. if err != nil {
  32. return
  33. }
  34. c.JSON(gobSvc.PickSph(v.Channel))
  35. }
  36. func favorites(c *bm.Context) {
  37. v := new(model.FormFav)
  38. err := c.Bind(v)
  39. if err != nil {
  40. return
  41. }
  42. if v.AccessKey != "" {
  43. if mid, ok := c.Get("mid"); ok { // if not logged in, not request follow
  44. c.JSON(favSvc.Favorites(c, v.ToReq(mid.(int64))))
  45. return
  46. }
  47. }
  48. c.JSON(nil, ecode.NoLogin)
  49. }
  50. func favAct(c *bm.Context) {
  51. v := new(model.FormFavAct)
  52. err := c.Bind(v)
  53. if err != nil {
  54. return
  55. }
  56. if v.AccessKey != "" {
  57. if mid, ok := c.Get("mid"); ok { // if not logged in, not request follow
  58. c.JSON(nil, favSvc.FavAct(c, v.ToReq(mid.(int64))))
  59. return
  60. }
  61. }
  62. c.JSON(nil, ecode.NoLogin)
  63. }
  64. func applyPGC(c *bm.Context) {
  65. v := new(model.ReqApply)
  66. err := c.Bind(v)
  67. if err != nil {
  68. return
  69. }
  70. c.JSON(nil, auditSvc.ApplyPGC(c, v))
  71. }
  72. func labels(c *bm.Context) {
  73. v := new(struct {
  74. CatType int `form:"cat_type" validate:"required,min=1,max=2"`
  75. Category int `form:"category" validate:"required"`
  76. })
  77. if err := c.Bind(v); err != nil {
  78. return
  79. }
  80. c.JSON(gobSvc.Labels(c, v.CatType, v.Category))
  81. }
  82. func region(c *bm.Context) {
  83. var (
  84. err error
  85. res []*model.Region
  86. m = make(map[string]interface{})
  87. )
  88. if res, err = tvSvc.Regions(c); err != nil {
  89. return
  90. }
  91. m["mtime"] = tvSvc.MaxTime
  92. m["data"] = res
  93. c.JSONMap(m, nil)
  94. }