| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- 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"`
- }
- // GetErmcpGoods 查询企业风管期货商品信息
- // @Summary 查询企业风管期货商品信息
- // @Produce json
- // @Security ApiKeyAuth
- // @Param lastUpdateTime query string false "最后修改时间 - 闭区间,格式:yyyy-MM-dd HH:mm:ss"
- // @Success 200 {object} models.Goods
- // @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.LastUpdateTime)
- 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)
- }
|