package wr

import (
	"mtp2_if/global/app"
	"mtp2_if/global/e"
	"mtp2_if/logger"
	"mtp2_if/models"
	"net/http"

	"github.com/gin-gonic/gin"
)

// 仓单服务

// GetWRCategoryInfo 获取现货分类信息
// @Summary 获取现货分类信息
// @Produce json
// @Success 200 {object} models.WRCategoryTree
// @Failure 500 {object} app.Response
// @Router /WR/GetWRCategoryInfo [get]
// @Tags 仓单服务
func GetWRCategoryInfo(c *gin.Context) {
	appG := app.Gin{C: c}

	categories, err := models.CreateCategoryTree(0)
	if err != nil {
		// 查询失败
		logger.GetLogger().Errorf("GetWRCategoryInfo failed: %s", err.Error())
		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
		return
	}

	// 查询成功返回
	logger.GetLogger().Debugln("GetWRCategoryInfo successed: %v", categories)
	appG.Response(http.StatusOK, e.SUCCESS, categories)
}
