package goods import ( "applet/app/admin/md" svc "applet/app/admin/svc/category" "applet/app/admin/svc/goods" "applet/app/e" "github.com/gin-gonic/gin" ) // 商品列表接口 func GetMallGoodsList(c *gin.Context) { var args md.MallGoodsListReq args.Title = c.Query("title") args.Name = c.Query("name") args.CategoryId = c.Query("category_id") args.SaleState = c.Query("sale_state") args.PageId = c.Query("page") args.PageSize = c.Query("limit") args.SkuCode = c.Query("sku_code") tree, err := svc.GetAllCategory(c) data, total, err := goods.GetMallGoodsList(c, &args) if err != nil { e.OutErr(c, e.ERR_NO_DATA, err) return } var returnData = map[string]interface{}{ "total": total, "cateList": tree, // "dataList": data, //-1审核拒绝 0审核中 1销售中 2已售罄 3放入仓库 4下架 "stateList": []map[string]interface{}{ {"name": "全部", "value": 99}, {"name": "销售中", "value": 1}, {"name": "已下架", "value": 2}, }, } if data == nil { returnData["dataList"] = []string{} } else { returnData["dataList"] = data } e.OutSuc(c, returnData, nil) return } func CheckSkuCode(c *gin.Context) { skuCode := c.Query("sku_code") goodsId := c.DefaultQuery("goods_id", "0") isHas, err := goods.CheckSkuCode(c, skuCode, goodsId) if err != nil { e.OutErr(c, e.ERR, err) return } var result = true if isHas { result = false e.OutSuc(c, map[string]interface{}{ "result": result, "msg": "該sku編碼已存在,請保持唯一性", }, nil) return } e.OutSuc(c, map[string]interface{}{ "result": result, "msg": "success", }, nil) return }