/** * @Author: zou.yingbin * @Create : 2021/1/18 9:26 * @Modify : 2021/1/18 9:26 */ 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 RealtimeExposureReq struct { AreaUserID uint32 `form:"AreaUserID" binding:"required"` //所属机构ID } //实时敞口查询应答 type RealtimeExposureRsp models.ErmcpRealExposureModel // QueryUserInfo 查询实时敞口 // @Summary 查询实时敞口 // @Produce json // @Security ApiKeyAuth // @Param AreaUserID query int true "所属机构ID" // @Success 200 {array} RealtimeExposureRsp // @Failure 500 {object} app.Response // @Router /Ermcp/QueryRealtimeExposure [get] // @Tags 企业风险管理(app) func QueryRealtimeExposure(c *gin.Context) { appG := app.Gin{C: c} var req RealtimeExposureReq if err := c.ShouldBind(&req); err != nil { logger.GetLogger().Errorf("QueryRealtimeExposure fail, %v", err) appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil) return } m := models.ErmcpRealExposureModel{AreaUserID: req.AreaUserID} if d, err := m.GetData(); err == nil { appG.Response(http.StatusOK, e.SUCCESS, d) } else { appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil) } } /***********************敞口明细*************************/ //敞口现货明细请求 type ExposureDetailReq struct { AreaUserId uint32 `form:"areaUserId" json:"areaUserId"` // 所属机构ID MiddleGoodsId int32 `form:"middleGoodsId" json:"middlegoodsid"` // 套保商品 } //敞口现货明细响应 type ExposureDetailRsp models.ErmcpExposureDetailModel // QueryUserInfo 查询敞口现货明细 // @Summary 查询敞口现货明细 // @Produce json // @Security ApiKeyAuth // @Param areaUserId query int true "所属机构ID" // @Param middleGoodsId query int true "套保商品" // @Success 200 {array} ExposureDetailRsp // @Failure 500 {object} app.Response // @Router /Ermcp/QueryExposureDetail [get] // @Tags 企业风险管理(app) func QueryExposureDetail(c *gin.Context) { appG := app.Gin{C: c} var req ExposureDetailReq if err := c.ShouldBind(&req); err != nil{ appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil) return } var m = models.ErmcpExposureDetailModel{Areauserid: req.AreaUserId, MiddlegoodsId: req.MiddleGoodsId} if d, err := m.GetData(); err == nil{ appG.Response(http.StatusOK, e.SUCCESS, d) }else { appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil) } } ////////////////////////////////////////////// // 敞口/现货头寸请求 type ExposureSpotReq struct { AreaUserID int32 `form:"areaUserId" binding:"required"` //所属机构ID } // 敞口/现货头寸应答 type ExposureSpotRsp models.AreaSpotModel // QueryUserInfo 查询敞口现货头寸 // @Summary 查询敞口现货头寸(敞口/现货头寸) // @Produce json // @Security ApiKeyAuth // @Param areaUserId query int true "所属机构ID" // @Success 200 {array} ExposureSpotRsp // @Failure 500 {object} app.Response // @Router /Ermcp/QueryExposureSpot [get] // @Tags 企业风险管理(app) func QueryExposureSpot(c *gin.Context) { appG := app.Gin{C: c} var req ExposureSpotReq if err := c.ShouldBind(&req); err != nil{ appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil) return } var m = models.AreaSpotModel{AREAUSERID: req.AreaUserID} if d, err := m.GetData(); err == nil{ appG.Response(http.StatusOK, e.SUCCESS, d) }else{ appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil) } }