jct-slip-search-page.go-- 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package controllers_join
  2. import (
  3. "encoding/json"
  4. "net/http"
  5. "kkscrap-go/locals"
  6. models_themes "kkscrap-go/models/themes"
  7. models_join "kkscrap-go/models/join"
  8. "github.com/dabory/abango-rest"
  9. "github.com/labstack/echo"
  10. )
  11. type SlipSearchPageReq struct {
  12. QueryVars locals.QueryVars
  13. SlipSearchVars locals.SlipSearchVars
  14. SlipSearchFields locals.SlipSearchFields
  15. PageVars locals.PageVars
  16. }
  17. func SlipSearchPage(c echo.Context) error {
  18. v := c.Get("receiver").(SlipSearchPageReq)
  19. y := c.Get("abango").(abango.Controller)
  20. slip := v.QueryVars.QueryName
  21. if slip == "eyetest" {
  22. vRet := &struct {
  23. models_themes.EyetestSearchPageRet
  24. }{}
  25. vRet.QueryVars = v.QueryVars
  26. vRet.SlipSearchVars = v.SlipSearchVars
  27. vRet.SlipSearchFields = v.SlipSearchFields
  28. vRet.PageVars = v.PageVars
  29. // fmt.Println(y.Gtb.UserId)
  30. if err := vRet.GetEyetestSearchPage(&y); err != nil {
  31. return c.String(607, err.Error())
  32. }
  33. ret, _ := json.Marshal(vRet)
  34. return c.JSONBlob(http.StatusOK, ret)
  35. } else {
  36. vRet := &struct {
  37. models_join.SlipSearchPageRet
  38. }{}
  39. vRet.QueryVars = v.QueryVars
  40. vRet.SlipSearchVars = v.SlipSearchVars
  41. vRet.SlipSearchFields = v.SlipSearchFields
  42. vRet.PageVars = v.PageVars
  43. // fmt.Println(y.Gtb.UserId)
  44. if err := vRet.GetSlipSearchPage(&y); err != nil {
  45. return c.String(607, err.Error())
  46. }
  47. ret, _ := json.Marshal(vRet)
  48. return c.JSONBlob(http.StatusOK, ret)
  49. // return c.String(709, e.LogStr("234adfq3fae", "QueryName Not Found in SlipSearchBook Controller for '"+slip+"'"))
  50. }
  51. }