qryGoods.go 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. // @Success 200 {object} models.ErmcpGoods
  23. // @Failure 500 {object} app.Response
  24. // @Router /Ermcp/GetErmcpGoods [get]
  25. // @Tags 企业风险管理(app)
  26. func GetErmcpGoods(c *gin.Context) {
  27. appG := app.Gin{C: c}
  28. // 获取请求参数
  29. var req GetErmcpGoodsReq
  30. if err := appG.C.ShouldBindQuery(&req); err != nil {
  31. logger.GetLogger().Errorf("GetErmcpGoods failed: %s", err.Error())
  32. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  33. return
  34. }
  35. // 获取数据
  36. goodses, err := models.GetErmcpGoodses(req.USERID, req.LastUpdateTime, req.LoginID)
  37. if err != nil {
  38. // 查询失败
  39. logger.GetLogger().Errorf("GetErmcpGoods failed: %s", err.Error())
  40. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  41. return
  42. }
  43. // 查询成功返回
  44. //logger.GetLogger().Debugln("GetErmcpGoods successed: %v", goodses)
  45. appG.Response(http.StatusOK, e.SUCCESS, goodses)
  46. }
  47. // GetErmcpGoodsSortByPositionReq 查询企业风管期货主力、次主力商品信息请求参数
  48. type GetErmcpGoodsSortByPositionReq struct {
  49. SortIndex string `form:"sortIndex"`
  50. }
  51. // GetErmcpGoodsSortByPosition 查询企业风管期货主力、次主力商品信息
  52. // @Summary 查询企业风管期货主力、次主力商品信息
  53. // @Produce json
  54. // @Security ApiKeyAuth
  55. // @Param sortIndex query string false "主力: 1; 次主力: 2; 主力+次主力:1,2"
  56. // @Success 200 {object} models.Goodssortbypreposition
  57. // @Failure 500 {object} app.Response
  58. // @Router /Ermcp/GetErmcpGoodsSortByPosition [get]
  59. // @Tags 企业风险管理(app)
  60. func GetErmcpGoodsSortByPosition(c *gin.Context) {
  61. appG := app.Gin{C: c}
  62. // 获取请求参数
  63. var req GetErmcpGoodsSortByPositionReq
  64. if err := appG.C.ShouldBindQuery(&req); err != nil {
  65. logger.GetLogger().Errorf("GetErmcpGoodsSortByPosition failed: %s", err.Error())
  66. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  67. return
  68. }
  69. // 获取数据
  70. goodses, err := models.GetGoodsSortByPrePositions(req.SortIndex)
  71. if err != nil {
  72. // 查询失败
  73. logger.GetLogger().Errorf("GetErmcpGoodsSortByPosition failed: %s", err.Error())
  74. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  75. return
  76. }
  77. // 查询成功返回
  78. logger.GetLogger().Debugln("GetErmcpGoodsSortByPosition successed: %v", goodses)
  79. appG.Response(http.StatusOK, e.SUCCESS, goodses)
  80. }