|
@@ -1061,7 +1061,86 @@ func QueryHsbyMarkets(c *gin.Context) {
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, markets)
|
|
appG.Response(http.StatusOK, e.SUCCESS, markets)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// QueryHsbyMarketGoodsesReq 查询特卖商品列表(三级商城)列表请求参数
|
|
|
|
|
|
|
+// QueryHsbyVisitorMarketGoodsesReq 查询游客特卖商品列表(三级商城)请求参数
|
|
|
|
|
+type QueryHsbyVisitorMarketGoodsesReq struct {
|
|
|
|
|
+ app.PageInfo
|
|
|
|
|
+ MarketIDs string `form:"marketIDs" binding:"required"`
|
|
|
|
|
+ CategoryID int `form:"categoryID"`
|
|
|
|
|
+ GoodsIDs string `form:"goodsIDs"`
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// QueryHsbyVisitorMarketGoodses 查询游客特卖商品列表(三级商城)
|
|
|
|
|
+// @Summary 查询游客特卖商品列表(三级商城)
|
|
|
|
|
+// @Description 说明:使用于未登录状态查询商城商品列表,登录后请使用QueryHsbyMarketGoodses接口进行查询。
|
|
|
|
|
+// @Produce json
|
|
|
|
|
+// @Security ApiKeyAuth
|
|
|
|
|
+// @Param page query int false "页码"
|
|
|
|
|
+// @Param pagesize query int false "每页条数"
|
|
|
|
|
+// @Param marketIDs query string true "市场ID列表,格式:1,2,3"
|
|
|
|
|
+// @Param categoryID query int false "类别ID"
|
|
|
|
|
+// @Param goodsIDs query string false "商品ID列表,格式:1,2,3。主要用于商品搜索。"
|
|
|
|
|
+// @Success 200 {object} models.HsbyMarketGoods
|
|
|
|
|
+// @Failure 500 {object} app.Response
|
|
|
|
|
+// @Router /HSBY/QueryHsbyVisitorMarketGoodses [get]
|
|
|
|
|
+// @Tags 定制【海商报业】
|
|
|
|
|
+func QueryHsbyVisitorMarketGoodses(c *gin.Context) {
|
|
|
|
|
+ appG := app.Gin{C: c}
|
|
|
|
|
+
|
|
|
|
|
+ // 获取请求参数
|
|
|
|
|
+ var req QueryHsbyVisitorMarketGoodsesReq
|
|
|
|
|
+ if err := appG.C.ShouldBindQuery(&req); err != nil {
|
|
|
|
|
+ logger.GetLogger().Errorf("QueryHsbyVisitorMarketGoodses failed: %s", err.Error())
|
|
|
|
|
+ appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取数据
|
|
|
|
|
+ goodses, err := models.GetHsbyMarketGoodsesByVisitor(req.MarketIDs, req.CategoryID, req.GoodsIDs)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ // 查询失败
|
|
|
|
|
+ logger.GetLogger().Errorf("QueryHsbyVisitorMarketGoodses failed: %s", err.Error())
|
|
|
|
|
+ appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 排序
|
|
|
|
|
+ sort.Slice(goodses, func(i int, j int) bool {
|
|
|
|
|
+ return goodses[i].Hotindex > goodses[j].Hotindex
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // 分页
|
|
|
|
|
+ total := len(goodses)
|
|
|
|
|
+ if req.PageSize > 0 {
|
|
|
|
|
+ rstByPage := make([]models.HsbyMarketGoods, 0)
|
|
|
|
|
+ // 开始上标
|
|
|
|
|
+ start := req.Page * req.PageSize
|
|
|
|
|
+ // 结束下标
|
|
|
|
|
+ end := start + req.PageSize
|
|
|
|
|
+
|
|
|
|
|
+ if start <= len(goodses) {
|
|
|
|
|
+ // 判断结束下标是否越界
|
|
|
|
|
+ if end > len(goodses) {
|
|
|
|
|
+ end = len(goodses)
|
|
|
|
|
+ }
|
|
|
|
|
+ rstByPage = goodses[start:end]
|
|
|
|
|
+ } else {
|
|
|
|
|
+ rstByPage = goodses[0:0]
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ goodses = rstByPage
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询成功返回
|
|
|
|
|
+ if req.PageSize > 0 {
|
|
|
|
|
+ logger.GetLogger().Debugln("QueryHsbyVisitorMarketGoodses successed: %v", goodses)
|
|
|
|
|
+ appG.ResponseByPage(http.StatusOK, e.SUCCESS, goodses, app.PageInfo{Page: req.Page, PageSize: req.PageSize, Total: total})
|
|
|
|
|
+ } else {
|
|
|
|
|
+ logger.GetLogger().Debugln("QueryHsbyVisitorMarketGoodses successed: %v", goodses)
|
|
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, goodses)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// QueryHsbyMarketGoodsesReq 查询特卖商品列表(三级商城)请求参数
|
|
|
type QueryHsbyMarketGoodsesReq struct {
|
|
type QueryHsbyMarketGoodsesReq struct {
|
|
|
app.PageInfo
|
|
app.PageInfo
|
|
|
MarketIDs string `form:"marketIDs" binding:"required"`
|
|
MarketIDs string `form:"marketIDs" binding:"required"`
|