qryGoods.go 2.8 KB

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