qryGoods.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package ermcp
  2. import (
  3. "mtp2_if/global/app"
  4. "mtp2_if/global/e"
  5. "mtp2_if/logger"
  6. "mtp2_if/models"
  7. "net/http"
  8. "github.com/gin-gonic/gin"
  9. )
  10. // GetErmcpGoodsReq 查询企业风管期货商品信息请求参数
  11. type GetErmcpGoodsReq struct {
  12. LastUpdateTime string `form:"lastUpdateTime"`
  13. USERID int64 `form:"userid"`
  14. LoginID int64 `form:"loginid"` // 登录账号,传入后会进行有权限的市场过滤结果
  15. }
  16. // GetErmcpGoods 查询企业风管期货商品信息
  17. // @Summary 查询企业风管期货商品信息
  18. // @Produce json
  19. // @Security ApiKeyAuth
  20. // @Param userid query int false "用户id(风管云平台版本传值, 只显示用户下设置了套保关联的品种)"
  21. // @Param lastUpdateTime query string false "最后修改时间 - 闭区间,格式:yyyy-MM-dd HH:mm:ss"
  22. // @Param loginid query int false "登录账号,传入后会进行有权限的市场过滤结果"
  23. // @Success 200 {object} models.ErmcpGoods
  24. // @Failure 500 {object} app.Response
  25. // @Router /Ermcp/GetErmcpGoods [get]
  26. // @Tags 企业风险管理(app)
  27. func GetErmcpGoods(c *gin.Context) {
  28. appG := app.Gin{C: c}
  29. // 获取请求参数
  30. var req GetErmcpGoodsReq
  31. if err := appG.C.ShouldBindQuery(&req); err != nil {
  32. logger.GetLogger().Errorf("GetErmcpGoods failed: %s", err.Error())
  33. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  34. return
  35. }
  36. // 获取数据
  37. goodses, err := models.GetErmcpGoodses(req.USERID, req.LastUpdateTime, req.LoginID)
  38. if err != nil {
  39. // 查询失败
  40. logger.GetLogger().Errorf("GetErmcpGoods failed: %s", err.Error())
  41. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  42. return
  43. }
  44. // 查询成功返回
  45. //logger.GetLogger().Debugln("GetErmcpGoods successed: %v", goodses)
  46. appG.Response(http.StatusOK, e.SUCCESS, goodses)
  47. }
  48. // GetErmcpGoodsSortByPositionReq 查询企业风管期货主力、次主力商品信息请求参数
  49. type GetErmcpGoodsSortByPositionReq struct {
  50. SortIndex string `form:"sortIndex"`
  51. }
  52. // GetErmcpGoodsSortByPosition 查询企业风管期货主力、次主力商品信息
  53. // @Summary 查询企业风管期货主力、次主力商品信息
  54. // @Produce json
  55. // @Security ApiKeyAuth
  56. // @Param sortIndex query string false "主力: 1; 次主力: 2; 主力+次主力:1,2"
  57. // @Success 200 {object} models.Goodssortbypreposition
  58. // @Failure 500 {object} app.Response
  59. // @Router /Ermcp/GetErmcpGoodsSortByPosition [get]
  60. // @Tags 企业风险管理(app)
  61. func GetErmcpGoodsSortByPosition(c *gin.Context) {
  62. appG := app.Gin{C: c}
  63. // 获取请求参数
  64. var req GetErmcpGoodsSortByPositionReq
  65. if err := appG.C.ShouldBindQuery(&req); err != nil {
  66. logger.GetLogger().Errorf("GetErmcpGoodsSortByPosition failed: %s", err.Error())
  67. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  68. return
  69. }
  70. // 获取数据
  71. goodses, err := models.GetGoodsSortByPrePositions(req.SortIndex)
  72. if err != nil {
  73. // 查询失败
  74. logger.GetLogger().Errorf("GetErmcpGoodsSortByPosition failed: %s", err.Error())
  75. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  76. return
  77. }
  78. // 查询成功返回
  79. logger.GetLogger().Debugln("GetErmcpGoodsSortByPosition successed:", goodses)
  80. appG.Response(http.StatusOK, e.SUCCESS, goodses)
  81. }