goods.go
1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package apis
import (
"net/http"
. "client/icesimba.mall/models"
"github.com/gin-gonic/gin"
)
func QueryGoodsByMallIdApi(c *gin.Context) {
mallId := c.Request.FormValue("mall_id")
gameId := c.Request.FormValue("game_id")
if mallId == "" {
code = "1003"
c.JSON(http.StatusOK, gin.H{
"code": code,
"msg": "参数错误",
})
return
}
mallGoods := MallGoods{}
mallGoods, err := mallGoods.QueryGoodsByMallId(mallId, gameId)
if err != nil {
code = "1000"
c.JSON(http.StatusOK, gin.H{
"code": code,
"msg": err.Error(),
})
return
}
code = "0"
c.JSON(http.StatusOK, gin.H{
"code": code,
"obj": mallGoods,
})
return
}
func InsertOrUpdateGoodsApi(c *gin.Context) {
// gameId := c.Request.FormValue("game_id")
// goodsCode := c.Request.FormValue("goods_code")
// mallCode := c.Request.FormValue("mall_code")
// goodsDesc := c.Request.FormValue("goods_desc")
// goodsName := c.Request.FormValue("goods_name")
// goodsIcon := c.Request.FormValue("goods_icon")
// startTime := c.Request.FormValue("start_time")
// endTime := c.Request.FormValue("end_time")
// priceStr := c.Request.FormValue("price")
// discountStr := c.Request.FormValue("discount")
// if gameId == "" || goodsCode == "" || priceStr == "" ||
// goodsDesc == "" || goodsName == "" || goodsIcon == "" || discountStr == "" {
// c.JSON(400, gin.H{
// "msg": "参数错误",
// })
// }
// price, _ := strconv.ParseFloat(priceStr, 64)
// discount, _ := strconv.ParseFloat(priceStr, 64)
// goodsIn := IOUGoods{
// GameId: gameId,
// GoodsCode: goodsCode,
// GoodsDesc: goodsDesc,
// GoodsName: goodsName,
// GoodsIcon: goodsIcon,
// StartTime: startTime,
// EndTime: endTime,
// Price: price,
// Discount: discount,
// MallCode: mallCode,
// }
// code, err := goodsIn.InsertOrUpdateGoods()
// if err != nil {
// c.JSON(code, gin.H{
// "msg": err.Error(),
// })
// }
// c.JSON(code, gin.H{
// "msg": "成功",
// })
return
}