qryGoods.go 3.0 KB

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