/**
* @Author: zou.yingbin
* @Create  : 2021/1/13 11:15
* @Modify  : 2021/1/13 11:15
 */

package ermcp

import (
	"github.com/gin-gonic/gin"
	"mtp2_if/global/app"
	"mtp2_if/global/e"
	"mtp2_if/models"
	"mtp2_if/mtpcache"
	"net/http"
)

//查询现货商品请求
type QryWrStandardReq struct {
	UserId int `form:"userid" binding:"required"` //用户ID
}

//查询现货商品响应
type QryWrStandardRsp models.ErmcpWrstandard

// QueryWrStandard  企业风险管理查询现货商品
// @Summary 查询现货商品
// @Produce json
// @Security ApiKeyAuth
// @Param userid query int true  "所属机构ID"
// @Success 200 {array} QryWrStandardRsp
// @Failure 500 {object} app.Response
// @Router /Ermcp/QueryWrStandard [get]
// @Tags 企业风险管理(app)
func QueryWrStandard(c *gin.Context)  {
	appG := app.Gin{C: c}
	var req QryWrStandardReq
	if err := c.ShouldBind(&req); err != nil{
		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
		return
	}
	m := models.ErmcpWrstandard{AREAUSERID: req.UserId}
	if d, err := m.GetData(); err == nil {
		for i := range d {
			d[i].EnumdicName = mtpcache.GetEnumDicitemName(d[i].UNITID)
		}
		appG.Response(http.StatusOK, e.SUCCESS, d)
	} else {
		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
	}
}
