|
|
@@ -22,34 +22,34 @@ func (Goods) TableName() string {
|
|
|
return "GOODS"
|
|
|
}
|
|
|
|
|
|
-// GoodsQueryReq 商品查询请求
|
|
|
-type GoodsQueryReq struct {
|
|
|
+// QueryReq 商品查询请求
|
|
|
+type QueryReq struct {
|
|
|
Token string `json:"token" binding:"required"`
|
|
|
GoodsID int `json:"goodsid" binding:"required"`
|
|
|
}
|
|
|
|
|
|
-// GoodsQueryRsp 商品查询结果
|
|
|
-type GoodsQueryRsp struct {
|
|
|
+// QueryRsp 商品查询结果
|
|
|
+type QueryRsp struct {
|
|
|
GoodsID int `json:"goodsid" binding:"required"`
|
|
|
GoodsCode string `json:"goodscode" binding:"required"`
|
|
|
GoodsName string `json:"goodsname" binding:"required"`
|
|
|
MarketID int `json:"marketid" binding:"required"`
|
|
|
}
|
|
|
|
|
|
-// GoodsQueryAllReq 所有商品查询请求
|
|
|
-type GoodsQueryAllReq struct {
|
|
|
+// QueryAllReq 所有商品查询请求
|
|
|
+type QueryAllReq struct {
|
|
|
Token string `json:"token" binding:"required"`
|
|
|
//MarketID int `json:"marketid" binding:"required"`
|
|
|
}
|
|
|
|
|
|
-// GoodsQueryAllRsp 所有商品查询结果
|
|
|
-type GoodsQueryAllRsp struct {
|
|
|
+// QueryAllRsp 所有商品查询结果
|
|
|
+type QueryAllRsp struct {
|
|
|
Goodss []Goods `json:"goodss"`
|
|
|
}
|
|
|
|
|
|
-// GetGoodsInfo 商品信息查询
|
|
|
+// QueryGoods 商品信息查询
|
|
|
func QueryGoods(c *gin.Context) {
|
|
|
- var goods GoodsQueryReq
|
|
|
+ var goods QueryReq
|
|
|
err := c.ShouldBind(&goods)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
|
|
@@ -70,7 +70,7 @@ func QueryGoods(c *gin.Context) {
|
|
|
goodsname := results[0]["GOODSNAME"]
|
|
|
marketid, _ := strconv.Atoi(results[0]["MARKETID"])
|
|
|
|
|
|
- ret := GoodsQueryRsp{
|
|
|
+ ret := QueryRsp{
|
|
|
GoodsID: goods.GoodsID,
|
|
|
GoodsCode: goodscode,
|
|
|
GoodsName: goodsname,
|
|
|
@@ -81,7 +81,7 @@ func QueryGoods(c *gin.Context) {
|
|
|
|
|
|
// GetGoods 商品信息查询
|
|
|
func GetGoods(c *gin.Context) {
|
|
|
- var goods GoodsQueryReq
|
|
|
+ var goods QueryReq
|
|
|
err := c.ShouldBind(&goods)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
|
|
@@ -101,7 +101,7 @@ func GetGoods(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- ret := GoodsQueryRsp{
|
|
|
+ ret := QueryRsp{
|
|
|
GoodsID: goods.GoodsID,
|
|
|
GoodsCode: goodsinfo.Goodscode,
|
|
|
GoodsName: goodsinfo.Goodsname,
|
|
|
@@ -112,7 +112,7 @@ func GetGoods(c *gin.Context) {
|
|
|
|
|
|
// GetAllGoods 所有商品信息查询
|
|
|
func GetAllGoods(c *gin.Context) {
|
|
|
- var goods GoodsQueryAllReq
|
|
|
+ var goods QueryAllReq
|
|
|
err := c.ShouldBind(&goods)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
|
|
@@ -127,7 +127,7 @@ func GetAllGoods(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- ret := GoodsQueryAllRsp{
|
|
|
+ ret := QueryAllRsp{
|
|
|
Goodss: goodss,
|
|
|
}
|
|
|
c.SecureJSON(http.StatusOK, ret)
|