dm_search.go 673 B

12345678910111213141516171819202122232425262728293031323334
  1. package http
  2. import (
  3. "go-common/app/service/main/search/model"
  4. "go-common/library/ecode"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. func dmSearch(c *bm.Context) {
  9. var (
  10. err error
  11. sp = &model.DmSearchParams{
  12. Bsp: &model.BasicSearchParams{},
  13. }
  14. res *model.SearchResult
  15. )
  16. if err = c.Bind(sp); err != nil {
  17. c.JSON(nil, ecode.RequestErr)
  18. return
  19. }
  20. if err = c.Bind(sp.Bsp); err != nil {
  21. c.JSON(nil, ecode.RequestErr)
  22. return
  23. }
  24. sp.Bsp.Source = []string{"id"}
  25. res, err = svr.DmSearch(c, sp)
  26. if err != nil {
  27. log.Error("srv.DmSearch(%v) error(%v)", sp, err)
  28. c.JSON(nil, ecode.ServerErr)
  29. return
  30. }
  31. c.JSON(res, err)
  32. }