search.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package http
  2. import (
  3. "fmt"
  4. "go-common/app/admin/main/videoup/model/search"
  5. "go-common/library/ecode"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. )
  9. // searchVideo search video entrance
  10. func searchVideo(c *bm.Context) {
  11. var (
  12. err error
  13. )
  14. p := &search.VideoParams{}
  15. if err = c.Bind(p); err != nil {
  16. c.JSON(nil, ecode.RequestErr)
  17. return
  18. }
  19. if p.Action == "trash" {
  20. authSrc.Permit("VIDEO_TRASH")(c)
  21. } else if p.Action == "list" {
  22. authSrc.Permit("VIDEO_LIST")(c)
  23. }
  24. if c.IsAborted() {
  25. return
  26. }
  27. if p.MonitorList != "" { //如果是监控列表,则去掉其他筛选条件(监控列表没有接搜索)
  28. p = &search.VideoParams{
  29. MonitorList: p.MonitorList,
  30. Pn: p.Pn,
  31. Ps: p.Ps,
  32. }
  33. }
  34. videoData, err := vdaSvc.SearchVideo(c, p)
  35. if err != nil {
  36. c.JSON(nil, err)
  37. return
  38. }
  39. c.JSON(videoData, nil)
  40. }
  41. // searchCopyright search copyright entrance
  42. func searchCopyright(c *bm.Context) {
  43. var (
  44. err error
  45. p struct {
  46. Kw string `form:"text"`
  47. }
  48. )
  49. if err = c.Bind(&p); err != nil {
  50. c.JSON(nil, ecode.RequestErr)
  51. return
  52. }
  53. copyright, err := vdaSvc.SearchCopyright(c, p.Kw)
  54. if err != nil {
  55. log.Error("searchCopyright(%v) error(%v)", p, err)
  56. c.JSONMap(map[string]interface{}{
  57. "message": fmt.Sprintf("版权接口请求失败error(%v)。找谷安-Kwan", err),
  58. }, ecode.RequestErr)
  59. return
  60. }
  61. c.JSON(copyright.Result, nil)
  62. }
  63. func searchArchive(c *bm.Context) {
  64. var (
  65. err error
  66. )
  67. p := &search.ArchiveParams{}
  68. if err = c.Bind(p); err != nil {
  69. c.JSON(nil, ecode.RequestErr)
  70. return
  71. }
  72. archiveData, err := vdaSvc.SearchArchive(c, p)
  73. if c.IsAborted() {
  74. return
  75. }
  76. if err != nil {
  77. log.Error("searchArchive(%v) error(%v)", p, err)
  78. c.JSONMap(map[string]interface{}{
  79. "message": fmt.Sprintf("搜索接口请求失败error(%v)。", err),
  80. }, ecode.RequestErr)
  81. return
  82. }
  83. c.JSON(archiveData, nil)
  84. }