123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- package controllers_join
- import (
- "encoding/json"
- "kkscrap-go/locals"
- models_join "kkscrap-go/models/join"
- "net/http"
- "strings"
- "github.com/dabory/abango-rest"
- e "github.com/dabory/abango-rest/etc"
- "github.com/labstack/echo"
- )
- type SimpleJoinPageReq struct {
- QueryVars locals.QueryVars
- PageVars locals.PageVars
- Page []models_join.CartItemJoin
- }
- func SimpleJoinPage(c echo.Context) error {
- v := c.Get("receiver").(SimpleJoinPageReq)
- y := c.Get("abango").(abango.Controller)
- vCom := &struct {
- models_join.SimplePageRet
- }{}
- vCom.QueryVars = v.QueryVars
- vCom.PageVars = v.PageVars
- code := v.QueryVars.QueryName
- if strings.Contains(code, "select-option/") {
- vRet := &struct {
- models_join.SimpleSelectOptionPageRet
- }{}
- vRet.QueryVars = vCom.QueryVars
- vRet.PageVars = vCom.PageVars
- if err := vRet.GetPage(&y); err == nil {
- ret, _ := json.Marshal(vRet)
- return c.JSONBlob(http.StatusOK, ret)
- } else {
- return c.String(607, e.LogStr("453dfaw3rad", "Issue in QueryName: "+v.QueryVars.QueryName))
- }
- }
- var ms locals.MapStore
- if code == "cart-item" {
- vRet := &struct {
- models_join.CartItemPageRet
- }{}
- if err := vCom.SimpleJoinPage(&y, &ms); err != nil {
- return c.String(607, err.Error())
- }
- vRet.Page = ms.Get("page").(models_join.CartItemPage).Page
- vRet.QueryVars = vCom.QueryVars
- vRet.PageVars = vCom.PageVars
- ret, _ := json.Marshal(vRet)
- return c.JSONBlob(http.StatusOK, ret)
- } else if code == "sorder-item-total" {
- vRet := &struct {
- models_join.SorderItemTotalPageRet
- }{}
- if err := vCom.SimpleJoinPage(&y, &ms); err != nil {
- return c.String(607, err.Error())
- }
- vRet.Page = ms.Get("page").(models_join.SorderItemTotalPage).Page
- vRet.QueryVars = vCom.QueryVars
- vRet.PageVars = vCom.PageVars
- ret, _ := json.Marshal(vRet)
- return c.JSONBlob(http.StatusOK, ret)
- } else if code == "post-member-user" {
- vRet := &struct {
- models_join.PostMemberUserPageRet
- }{}
- if err := vCom.SimpleJoinPage(&y, &ms); err != nil {
- return c.String(607, err.Error())
- }
- vRet.Page = ms.Get("page").(models_join.PostMemberUserPage).Page
- vRet.QueryVars = vCom.QueryVars
- vRet.PageVars = vCom.PageVars
- ret, _ := json.Marshal(vRet)
- return c.JSONBlob(http.StatusOK, ret)
- ///// Crypto ////
- } else if code == "my-net-group-wallet" {
- vRet := &struct {
- models_join.MyNetGroupWalletPageRet
- }{}
- if err := vCom.SimpleJoinPage(&y, &ms); err != nil {
- return c.String(607, err.Error())
- }
- vRet.Page = ms.Get("page").(models_join.MyNetGroupWalletPage).Page
- vRet.QueryVars = vCom.QueryVars
- vRet.PageVars = vCom.PageVars
- ret, _ := json.Marshal(vRet)
- return c.JSONBlob(http.StatusOK, ret)
- } else if code == "my-wallet-token" {
- vRet := &struct {
- models_join.MyWalletTokenPageRet
- }{}
- if err := vCom.SimpleJoinPage(&y, &ms); err != nil {
- return c.String(607, err.Error())
- }
- vRet.Page = ms.Get("page").(models_join.MyWalletTokenPage).Page
- vRet.QueryVars = vCom.QueryVars
- vRet.PageVars = vCom.PageVars
- ret, _ := json.Marshal(vRet)
- return c.JSONBlob(http.StatusOK, ret)
- } else if code == "my-wallet-token-not" {
- vRet := &struct {
- models_join.MyWalletTokenNotPageRet
- }{}
- if err := vCom.SimpleJoinPage(&y, &ms); err != nil {
- return c.String(607, err.Error())
- }
- vRet.Page = ms.Get("page").(models_join.MyWalletTokenNotPage).Page
- vRet.QueryVars = vCom.QueryVars
- vRet.PageVars = vCom.PageVars
- ret, _ := json.Marshal(vRet)
- return c.JSONBlob(http.StatusOK, ret)
- } else {
- return c.String(709, e.LogStr("453dfaw3rad", "QueryName Not Found in JoinPage Controller for '"+v.QueryVars.QueryName+"'"))
- }
- }
|