|
|
@@ -14,22 +14,57 @@ import (
|
|
|
"mtp2_if/logger"
|
|
|
"mtp2_if/models"
|
|
|
"net/http"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
)
|
|
|
|
|
|
+type GetTouristGoodsReq struct {
|
|
|
+ TradeModes string `form:"trademodes"` // 交易模式筛选, 逗号隔开, 默认为 52,97,99
|
|
|
+ MarketIds string `form:"marketids"` // 市场ID筛选, 逗号隔开
|
|
|
+}
|
|
|
+
|
|
|
// GetTouristGoods 获取水贝亿爵游客商品列表
|
|
|
// @Summary 获取水贝亿爵游客商品列表
|
|
|
// @Produce json
|
|
|
-// @Success 200 {array} models.TouristGoods
|
|
|
-// @Failure 500 {object} app.Response
|
|
|
+// @Param trademodes query string false "交易模式筛选, 逗号隔开, 默认为 52,97,99"
|
|
|
+// @Param marketids query string false "市场ID筛选, 逗号隔开"
|
|
|
+// @Success 200 {array} models.TouristGoods
|
|
|
+// @Failure 500 {object} app.Response
|
|
|
// @Router /sbyj/GetTouristGoods [get]
|
|
|
// @Tags 水贝亿爵
|
|
|
func GetTouristGoods(c *gin.Context) {
|
|
|
appG := app.Gin{C: c}
|
|
|
|
|
|
+ // 获取请求参数
|
|
|
+ var req GetTouristGoodsReq
|
|
|
+ if err := appG.C.ShouldBindQuery(&req); err != nil {
|
|
|
+ logger.GetLogger().Errorf("GetTouristGoods failed: %s", err.Error())
|
|
|
+ appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
// 获取数据
|
|
|
- goodses, err := models.GetTouristGoods([]int{52, 97, 99})
|
|
|
+ var tradeModes []int
|
|
|
+ if req.TradeModes != "" {
|
|
|
+ arr := strings.Split(req.TradeModes, ",")
|
|
|
+ for _, item := range arr {
|
|
|
+ a, _ := strconv.Atoi(item)
|
|
|
+ tradeModes = append(tradeModes, a)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tradeModes = []int{52, 97, 99}
|
|
|
+ }
|
|
|
+ marketIds := make([]int, 0)
|
|
|
+ if req.MarketIds != "" {
|
|
|
+ arr := strings.Split(req.MarketIds, ",")
|
|
|
+ for _, item := range arr {
|
|
|
+ a, _ := strconv.Atoi(item)
|
|
|
+ marketIds = append(marketIds, a)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ goodses, err := models.GetTouristGoods(tradeModes, marketIds)
|
|
|
if err != nil {
|
|
|
// 查询失败
|
|
|
logger.GetLogger().Errorf("GetTouristGoods failed: %s", err.Error())
|