|
|
@@ -23,6 +23,17 @@ type GoodsQueryRsp struct {
|
|
|
MarketID int `json:"marketid" binding:"required"`
|
|
|
}
|
|
|
|
|
|
+type Goodstest struct {
|
|
|
+ Goodsid int `json:"goodsid" xorm:"'GOODSID'"`
|
|
|
+ Goodscode string `json:"goodscode" xorm:"'GOODSCODE'"`
|
|
|
+ Goodsname string `json:"goodsname" xorm:"'GOODSNAME'"`
|
|
|
+ Marketid int `json:"marketid" xorm:"'MARKETID'"`
|
|
|
+}
|
|
|
+
|
|
|
+func (Goodstest) TableName() string {
|
|
|
+ return "GOODSTEST"
|
|
|
+}
|
|
|
+
|
|
|
// GetGoodsInfo 商品信息查询
|
|
|
func QueryGoods(c *gin.Context) {
|
|
|
var goods GoodsQueryReq
|
|
|
@@ -52,12 +63,39 @@ func QueryGoods(c *gin.Context) {
|
|
|
GoodsName: goodsname,
|
|
|
MarketID: marketid,
|
|
|
}
|
|
|
- /*
|
|
|
- c.JSON(http.StatusOK, gin.H{
|
|
|
- "token": goods.Token,
|
|
|
- "goodsid": goods.GoodsID,
|
|
|
- "ret": ret,
|
|
|
- })
|
|
|
- */
|
|
|
+ c.SecureJSON(http.StatusOK, ret)
|
|
|
+}
|
|
|
+
|
|
|
+func GetGoods(c *gin.Context) {
|
|
|
+ var goods GoodsQueryReq
|
|
|
+ err := c.ShouldBind(&goods)
|
|
|
+ if err != nil {
|
|
|
+ c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
|
|
+ }
|
|
|
+
|
|
|
+ engine := db.GetEngine()
|
|
|
+
|
|
|
+ goodsinfo := new(Goodstest)
|
|
|
+ has, err := engine.Where("goodsid=?", goods.GoodsID).Get(goodsinfo)
|
|
|
+ if err != nil {
|
|
|
+ c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if !has {
|
|
|
+ c.JSON(http.StatusBadRequest, gin.H{"error": "not find"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ goodscode := goodsinfo.Goodscode
|
|
|
+ goodsname := goodsinfo.Goodsname
|
|
|
+ marketid := goodsinfo.Marketid
|
|
|
+
|
|
|
+ ret := GoodsQueryRsp{
|
|
|
+ GoodsID: goods.GoodsID,
|
|
|
+ GoodsCode: goodscode,
|
|
|
+ GoodsName: goodsname,
|
|
|
+ MarketID: marketid,
|
|
|
+ }
|
|
|
c.SecureJSON(http.StatusOK, ret)
|
|
|
}
|