jct-simple-join-page.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. package controllers_join
  2. import (
  3. "encoding/json"
  4. "kkscrap-go/locals"
  5. models_join "kkscrap-go/models/join"
  6. "net/http"
  7. "strings"
  8. "github.com/dabory/abango-rest"
  9. e "github.com/dabory/abango-rest/etc"
  10. "github.com/labstack/echo"
  11. )
  12. type SimpleJoinPageReq struct {
  13. QueryVars locals.QueryVars
  14. PageVars locals.PageVars
  15. Page []models_join.CartItemJoin
  16. }
  17. func SimpleJoinPage(c echo.Context) error {
  18. v := c.Get("receiver").(SimpleJoinPageReq)
  19. y := c.Get("abango").(abango.Controller)
  20. vCom := &struct {
  21. models_join.SimplePageRet
  22. }{}
  23. vCom.QueryVars = v.QueryVars
  24. vCom.PageVars = v.PageVars
  25. code := v.QueryVars.QueryName
  26. if strings.Contains(code, "select-option/") {
  27. vRet := &struct {
  28. models_join.SimpleSelectOptionPageRet
  29. }{}
  30. vRet.QueryVars = vCom.QueryVars
  31. vRet.PageVars = vCom.PageVars
  32. if err := vRet.GetPage(&y); err == nil {
  33. ret, _ := json.Marshal(vRet)
  34. return c.JSONBlob(http.StatusOK, ret)
  35. } else {
  36. return c.String(607, e.LogStr("453dfaw3rad", "Issue in QueryName: "+v.QueryVars.QueryName))
  37. }
  38. }
  39. var ms locals.MapStore
  40. if code == "cart-item" {
  41. vRet := &struct {
  42. models_join.CartItemPageRet
  43. }{}
  44. if err := vCom.SimpleJoinPage(&y, &ms); err != nil {
  45. return c.String(607, err.Error())
  46. }
  47. vRet.Page = ms.Get("page").(models_join.CartItemPage).Page
  48. vRet.QueryVars = vCom.QueryVars
  49. vRet.PageVars = vCom.PageVars
  50. ret, _ := json.Marshal(vRet)
  51. return c.JSONBlob(http.StatusOK, ret)
  52. } else if code == "sorder-item-total" {
  53. vRet := &struct {
  54. models_join.SorderItemTotalPageRet
  55. }{}
  56. if err := vCom.SimpleJoinPage(&y, &ms); err != nil {
  57. return c.String(607, err.Error())
  58. }
  59. vRet.Page = ms.Get("page").(models_join.SorderItemTotalPage).Page
  60. vRet.QueryVars = vCom.QueryVars
  61. vRet.PageVars = vCom.PageVars
  62. ret, _ := json.Marshal(vRet)
  63. return c.JSONBlob(http.StatusOK, ret)
  64. } else if code == "post-member-user" {
  65. vRet := &struct {
  66. models_join.PostMemberUserPageRet
  67. }{}
  68. if err := vCom.SimpleJoinPage(&y, &ms); err != nil {
  69. return c.String(607, err.Error())
  70. }
  71. vRet.Page = ms.Get("page").(models_join.PostMemberUserPage).Page
  72. vRet.QueryVars = vCom.QueryVars
  73. vRet.PageVars = vCom.PageVars
  74. ret, _ := json.Marshal(vRet)
  75. return c.JSONBlob(http.StatusOK, ret)
  76. ///// Crypto ////
  77. } else if code == "my-net-group-wallet" {
  78. vRet := &struct {
  79. models_join.MyNetGroupWalletPageRet
  80. }{}
  81. if err := vCom.SimpleJoinPage(&y, &ms); err != nil {
  82. return c.String(607, err.Error())
  83. }
  84. vRet.Page = ms.Get("page").(models_join.MyNetGroupWalletPage).Page
  85. vRet.QueryVars = vCom.QueryVars
  86. vRet.PageVars = vCom.PageVars
  87. ret, _ := json.Marshal(vRet)
  88. return c.JSONBlob(http.StatusOK, ret)
  89. } else if code == "my-wallet-token" {
  90. vRet := &struct {
  91. models_join.MyWalletTokenPageRet
  92. }{}
  93. if err := vCom.SimpleJoinPage(&y, &ms); err != nil {
  94. return c.String(607, err.Error())
  95. }
  96. vRet.Page = ms.Get("page").(models_join.MyWalletTokenPage).Page
  97. vRet.QueryVars = vCom.QueryVars
  98. vRet.PageVars = vCom.PageVars
  99. ret, _ := json.Marshal(vRet)
  100. return c.JSONBlob(http.StatusOK, ret)
  101. } else if code == "my-wallet-token-not" {
  102. vRet := &struct {
  103. models_join.MyWalletTokenNotPageRet
  104. }{}
  105. if err := vCom.SimpleJoinPage(&y, &ms); err != nil {
  106. return c.String(607, err.Error())
  107. }
  108. vRet.Page = ms.Get("page").(models_join.MyWalletTokenNotPage).Page
  109. vRet.QueryVars = vCom.QueryVars
  110. vRet.PageVars = vCom.PageVars
  111. ret, _ := json.Marshal(vRet)
  112. return c.JSONBlob(http.StatusOK, ret)
  113. } else {
  114. return c.String(709, e.LogStr("453dfaw3rad", "QueryName Not Found in JoinPage Controller for '"+v.QueryVars.QueryName+"'"))
  115. }
  116. }