diff --git a/server/marketserver/api/v1/shopcart/shopcart.go b/server/marketserver/api/v1/shopcart/shopcart.go index f402831a..ae04beb3 100644 --- a/server/marketserver/api/v1/shopcart/shopcart.go +++ b/server/marketserver/api/v1/shopcart/shopcart.go @@ -1,6 +1,8 @@ package shopcart import ( + "f5" + "main/constant" "github.com/gin-gonic/gin" ) @@ -9,6 +11,27 @@ type ShopCartApi struct { } func (this *ShopCartApi) List(c *gin.Context) { + rspObj := &struct { + ErrCode int32 `json:"errcode"` + ErrMsg string `json:"errmsg"` + Data []interface{} `json:"data"` + }{} + openId := c.MustGet("open_id").(string) + f5.GetGoStyleDb().OrmSelectOne( + constant.BCNFT_DB, + "t_shopcart", + [][]string{ + {"open_id", openId}, + }, + func (err error, ds* f5.DataSet) { + if err != nil { + rspObj.ErrCode = 500 + rspObj.ErrMsg = "server internal error" + c.JSON(200, rspObj) + return + } + c.JSON(200, rspObj) + }) } func (this *ShopCartApi) Add(c *gin.Context) { diff --git a/server/marketserver/common/types.go b/server/marketserver/common/types.go index bdf9ea6c..e8bb7b87 100644 --- a/server/marketserver/common/types.go +++ b/server/marketserver/common/types.go @@ -61,6 +61,14 @@ type StreamPagination struct { Remaining int32 `json:"remaining"` } +type ShopCart struct { + CurrIdx uint32 `json:"curr_idx"` + Goolds map[string] struct { + SortIdx uint32 `json:"sort_idx"` + CreateTime uint32 `json:"createtime"` + } `json:"goods"` +} + type NftCache interface { GetRawData() string GetJsonData() interface{} diff --git a/server/marketserver/middleware/jwtauth.go b/server/marketserver/middleware/jwtauth.go new file mode 100644 index 00000000..8203eb1e --- /dev/null +++ b/server/marketserver/middleware/jwtauth.go @@ -0,0 +1,10 @@ +package middleware + +import ( + "github.com/gin-gonic/gin" +) + +func JwtAuth(c *gin.Context) { + //tokenHeader := c.Request.Header.Get("Authorization") + c.Next() +} diff --git a/server/marketserver/router/shopcart/shopcart.go b/server/marketserver/router/shopcart/shopcart.go index 704459d6..82c44593 100644 --- a/server/marketserver/router/shopcart/shopcart.go +++ b/server/marketserver/router/shopcart/shopcart.go @@ -9,7 +9,7 @@ type ShopCartRouter struct{} func (this *ShopCartRouter) InitRouter() { api := v1.ApiGroupApp.ShopCartApiGroup - f5.GetApp().GetGinEngine().GET("/shopcart/list", api.ShopCartApi.List) + f5.GetApp().GetGinEngine().GET("/api/shopcart/list", api.ShopCartApi.List) f5.GetApp().GetGinEngine().POST("/api/shopcart/add", api.ShopCartApi.Add) f5.GetApp().GetGinEngine().POST("/api/shopcart/del", api.ShopCartApi.Del) f5.GetApp().GetGinEngine().POST("/api/shopcart/clear", api.ShopCartApi.Clear)