| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- /**
- * @Author: zou.yingbin
- * @Create : 2021/1/18 9:26
- * @Modify : 2021/1/18 9:26
- */
- package ermcp
- import (
- "mtp2_if/global/app"
- "mtp2_if/global/e"
- "mtp2_if/logger"
- "mtp2_if/models"
- "net/http"
- "github.com/gin-gonic/gin"
- )
- //敞口相关查询
- //实时敞口查询请求
- 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
- // 查询敞口现货明细
- // @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
- // QueryExposureSpot 查询敞口现货头寸
- // @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)
- }
- }
- ////////////////////////////////////////////
- // 敞口/现货头寸/现货明细请求
- type ExposureSpotDetailReq struct {
- AreaUserID int `form:"areaUserId" binding:"required"` //所属机构ID
- WrstandardId int32 `form:"wrstandardId" binding:"required"` // 现货商品ID
- }
- // 敞口/现货头寸/现货明细应答
- type ExposureSpotDetailRsp models.ErmcpAreaSpotDetailModel
- // @Summary 查询敞口现货头寸明细(敞口/现货头寸/现货明细)
- // @Produce json
- // @Security ApiKeyAuth
- // @Param areaUserId query int true "所属机构ID"
- // @Param wrstandardId query int true "现货品种ID"
- // @Success 200 {array} ExposureSpotDetailRsp
- // @Failure 500 {object} app.Response
- // @Router /Ermcp/QueryExposureSpotDetail [get]
- // @Tags 企业风险管理(app)
- func QueryExposureSpotDetail(c *gin.Context) {
- appG := app.GinUtils{Gin: app.Gin{C: c}}
- var req ExposureSpotDetailReq
- appG.DoBindReq(&req)
- m := models.ErmcpAreaSpotDetailModel{UserId: req.AreaUserID, WrstandardId: req.WrstandardId}
- // m必须传指针类型,否则无法进行类型转换
- appG.DoGetData(&m)
- }
- ///////////////////////////////////////////
- // 敞口/历史敞口请求
- type HisExposureReq struct {
- AreaUserID int32 `form:"areaUserId" binding:"required"` //所属机构ID
- LastNum int32 `form:"lastNum" binding:"required"` //查询最近多少条记录
- }
- // 敞口/历史敞口应答
- type HisExposureRsp models.ErmcpHisExposureS
- // QueryUserInfo 查询历史敞口
- // @Summary 查询历史敞口(菜单:敞口/历史敞口)
- // @Produce json
- // @Security ApiKeyAuth
- // @Param areaUserId query int true "所属机构ID"
- // @Param lastNum query int true "每个品种记录数"
- // @Success 200 {array} HisExposureRsp
- // @Failure 500 {object} app.Response
- // @Router /Ermcp/QueryHisExposure [get]
- // @Tags 企业风险管理(app)
- func QueryHisExposure(c *gin.Context) {
- appG := app.Gin{C: c}
- var req HisExposureReq
- if err := c.ShouldBind(&req); err != nil {
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- var m = models.ErmcpHisExposure{AREAUSERID: req.AreaUserID, LastNum: req.LastNum}
- 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 RealtimeExposurePositionReq struct {
- AreaUserId int32 `form:"areaUserId" json:"areaUserId"` // 所属机构ID
- MiddleGoodsId int32 `form:"middleGoodsId" json:"middlegoodsid"` // 套保商品
- }
- // 实时敞口/期货明细 应答
- type RealtimeExposurePositionRsp models.ErmcpExposurePostion
- // @Summary 查询实时敞口期货头寸明细(菜单:实时敞口/期货明细)
- // @Produce json
- // @Security ApiKeyAuth
- // @Param areaUserId query int true "所属机构ID"
- // @Param middleGoodsId query int true "套保商品ID"
- // @Success 200 {array} RealtimeExposurePositionRsp
- // @Failure 500 {object} app.Response
- // @Router /Ermcp/QueryRealtimeExposurePosition [get]
- // @Tags 企业风险管理(app)
- func QueryRealtimeExposurePosition(c *gin.Context) {
- appG := app.GinUtils{Gin: app.Gin{C: c}}
- var req RealtimeExposurePositionReq
- appG.DoBindReq(&req)
- m := models.ErmcpExposurePostion{AREAUSERID: req.AreaUserId, MIDDLEGOODSID: req.MiddleGoodsId}
- appG.DoGetDataEx(&m)
- }
- // 敞口/期货头寸 请求
- type ExposureHedgePositionReq struct {
- AreaUserId int32 `form:"areaUserId" json:"areaUserId"` // 所属机构ID
- }
- // 敞口/期货头寸 应答
- type ExposureHedgePositionRsp models.ErmcpHedgePosition
- // @Summary 查询敞口期货头寸(菜单:敞口/期货头寸)
- // @Produce json
- // @Security ApiKeyAuth
- // @Param areaUserId query int true "所属机构ID"
- // @Success 200 {array} ExposureHedgePositionRsp
- // @Failure 500 {object} app.Response
- // @Router /Ermcp/QueryExposureHedgePosition [get]
- // @Tags 企业风险管理(app)
- func QueryExposureHedgePosition(c *gin.Context) {
- appG := app.Gin{C: c}
- var req ExposureHedgePositionReq
- if err := c.ShouldBind(&req); err != nil {
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- var m = models.ErmcpHedgePosition{RELATEDUSERID: 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 ExposureHedgePosDetailReq struct {
- AreaUserId int32 `form:"areaUserId" json:"areaUserId"` // 所属机构ID
- GoodsId int32 `form:"goodsId" json:"goodsId"` // 套保商品
- }
- // 期货明细应答
- type ExposureHedgePosDetailRsp models.ErmcpHedgePositionDetail
- // QueryExposureHedgePositionDetail 查询敞口期货头寸期货明细
- // @Summary 查询敞口期货头寸期货明细(菜单:敞口/期货头寸/期货明细)
- // @Produce json
- // @Security ApiKeyAuth
- // @Param areaUserId query int true "所属机构ID"
- // @Param goodsId query int true "商品id"
- // @Success 200 {array} ExposureHedgePosDetailRsp
- // @Failure 500 {object} app.Response
- // @Router /Ermcp/QueryExposureHedgePositionDetail [get]
- // @Tags 企业风险管理(app)
- func QueryExposureHedgePositionDetail(c *gin.Context) {
- appG := app.GinUtils{Gin: app.Gin{C: c}}
- var req ExposureHedgePosDetailReq
- appG.DoBindReq(&req)
- m := models.ErmcpHedgePositionDetail{AREAUSERID: req.AreaUserId, HEDGEGOODSID: req.GoodsId}
- appG.DoGetDataEx(&m)
- }
|