|
|
@@ -2,6 +2,9 @@ package goods
|
|
|
|
|
|
import (
|
|
|
"net/http"
|
|
|
+ "strconv"
|
|
|
+
|
|
|
+ "mtp2_if/db"
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
)
|
|
|
@@ -28,11 +31,26 @@ func QueryGoods(c *gin.Context) {
|
|
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
|
|
}
|
|
|
|
|
|
+ sql := "select goodscode, goodsname, marketid from goods where goodsid = ?"
|
|
|
+ engine := db.GetEngine()
|
|
|
+ results, err := engine.QueryString(sql, goods.GoodsID)
|
|
|
+ if err != nil {
|
|
|
+ c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(results) == 0 {
|
|
|
+ c.JSON(http.StatusBadRequest, gin.H{"error": "cont find"})
|
|
|
+ }
|
|
|
+
|
|
|
+ goodscode := results[0]["GOODSCODE"]
|
|
|
+ goodsname := results[0]["GOODSNAME"]
|
|
|
+ marketid, _ := strconv.Atoi(results[0]["MARKETID"])
|
|
|
+
|
|
|
ret := GoodsQueryRsp{
|
|
|
- GoodsID: 1,
|
|
|
- GoodsCode: "Ag100",
|
|
|
- GoodsName: "银100",
|
|
|
- MarketID: 10104,
|
|
|
+ GoodsID: goods.GoodsID,
|
|
|
+ GoodsCode: goodscode,
|
|
|
+ GoodsName: goodsname,
|
|
|
+ MarketID: marketid,
|
|
|
}
|
|
|
/*
|
|
|
c.JSON(http.StatusOK, gin.H{
|