/**
* @Author: zou.yingbin
* @Create  : 2021/1/7 10:54
* @Modify  : 2021/1/7 10:54
 */

package ermcp

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

// 查询客户资料请求
type QryUserInfoReq struct {
	MemberUserID int   `form:"MemberUserID" binding:"required"` // 所属机构用户ID
	QueryType    int32 `form:"queryType" binding:"required"`    // 查询类型(1:未提交 2:待审核 3:正常 4:停用)
}

// 查询客户资料应答
type QryUserInfoRsp models.ErmcpUserModel

// QueryUserInfo 查询客户资料
// @Summary 查询客户资料
// @Produce json
// @Security ApiKeyAuth
// @Param MemberUserID query int true "所属机构用户ID"
// @Param queryType query int true "查询类型(1:未提交 2:待审核 3:正常 4:停用)"
// @Success 200 {array} QryUserInfoRsp
// @Failure 500 {object} app.Response
// @Router /Ermcp/QueryUserInfo [get]
// @Tags 企业风险管理(app)
func QueryUserInfo(c *gin.Context) {
	appG := app.Gin{C: c}
	var req QryUserInfoReq
	if err := c.ShouldBind(&req); err != nil {
		logger.GetLogger().Errorf("parse query req: %v", err)
		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
		return
	}

	var m = models.ErmcpUserModel{MEMBERUSERID: req.MemberUserID}
	if d, err := m.GetData(req.QueryType); err == nil {
		appG.Response(http.StatusOK, e.SUCCESS, d)
	} else {
		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
	}
}
