/**
* @Author: zou.yingbin
* @Create  : 2021/1/14 11:43
* @Modify  : 2021/1/14 11:43
 */

package ermcp

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

// 查询变更记录请求
type QryOPLogReq struct {
	RelatedId string `form:"RelatedId" binding:"required"` // 现货合同ID\套保计划
}

// 查询变更记录响应
type QryOPLogRsp models.ErmcpOPLogModel

// QueryChangeLog 查询变更记录
// @Summary 查询变更记录
// @Produce json
// @Security ApiKeyAuth
// @Param RelatedId query string true "合同ID"
// @Success 200 {array} QryOPLogRsp
// @Failure 500 {object} app.Response
// @Router /Ermcp/QueryChangeLog [get]
// @Tags 企业风险管理(app)
func QueryChangeLog(c *gin.Context) {
	appG := app.Gin{C: c}
	var req QryOPLogReq
	if err := c.ShouldBind(&req); err != nil {
		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
		return
	}
	m := models.ErmcpOPLogModel{RELATEDID: req.RelatedId}
	if d, err := m.GetData(); err == nil {
		appG.Response(http.StatusOK, e.SUCCESS, d)
	} else {
		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
	}
}
