goods.go 1.95 KB
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
}