| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- package ermcp
- import (
- "mtp2_if/global/app"
- "mtp2_if/global/e"
- "mtp2_if/logger"
- "mtp2_if/models"
- "net/http"
- "github.com/gin-gonic/gin"
- )
- // GetErmcpGoodsReq 查询企业风管期货商品信息请求参数
- type GetErmcpGoodsReq struct {
- LastUpdateTime string `form:"lastUpdateTime"`
- USERID int64 `form:"userid"`
- LoginID int64 `form:"loginid"` // 登录账号,传入后会进行有权限的市场过滤结果
- }
- // GetErmcpGoods 查询企业风管期货商品信息
- // @Summary 查询企业风管期货商品信息
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userid query int false "用户id(风管云平台版本传值, 只显示用户下设置了套保关联的品种)"
- // @Param lastUpdateTime query string false "最后修改时间 - 闭区间,格式:yyyy-MM-dd HH:mm:ss"
- // @Success 200 {object} models.ErmcpGoods
- // @Failure 500 {object} app.Response
- // @Router /Ermcp/GetErmcpGoods [get]
- // @Tags 企业风险管理(app)
- func GetErmcpGoods(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req GetErmcpGoodsReq
- if err := appG.C.ShouldBindQuery(&req); err != nil {
- logger.GetLogger().Errorf("GetErmcpGoods failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- // 获取数据
- goodses, err := models.GetErmcpGoodses(req.USERID, req.LastUpdateTime, req.LoginID)
- if err != nil {
- // 查询失败
- logger.GetLogger().Errorf("GetErmcpGoods failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- // 查询成功返回
- //logger.GetLogger().Debugln("GetErmcpGoods successed: %v", goodses)
- appG.Response(http.StatusOK, e.SUCCESS, goodses)
- }
- // GetErmcpGoodsSortByPositionReq 查询企业风管期货主力、次主力商品信息请求参数
- type GetErmcpGoodsSortByPositionReq struct {
- SortIndex string `form:"sortIndex"`
- }
- // GetErmcpGoodsSortByPosition 查询企业风管期货主力、次主力商品信息
- // @Summary 查询企业风管期货主力、次主力商品信息
- // @Produce json
- // @Security ApiKeyAuth
- // @Param sortIndex query string false "主力: 1; 次主力: 2; 主力+次主力:1,2"
- // @Success 200 {object} models.Goodssortbypreposition
- // @Failure 500 {object} app.Response
- // @Router /Ermcp/GetErmcpGoodsSortByPosition [get]
- // @Tags 企业风险管理(app)
- func GetErmcpGoodsSortByPosition(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req GetErmcpGoodsSortByPositionReq
- if err := appG.C.ShouldBindQuery(&req); err != nil {
- logger.GetLogger().Errorf("GetErmcpGoodsSortByPosition failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- // 获取数据
- goodses, err := models.GetGoodsSortByPrePositions(req.SortIndex)
- if err != nil {
- // 查询失败
- logger.GetLogger().Errorf("GetErmcpGoodsSortByPosition failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- // 查询成功返回
- logger.GetLogger().Debugln("GetErmcpGoodsSortByPosition successed: %v", goodses)
- appG.Response(http.StatusOK, e.SUCCESS, goodses)
- }
|