qryHedgePlan.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * @Author: zou.yingbin
  3. * @Create : 2021/1/7 17:58
  4. * @Modify : 2021/1/7 17:58
  5. */
  6. package ermcp
  7. import (
  8. "github.com/gin-gonic/gin"
  9. "mtp2_if/global/app"
  10. "mtp2_if/global/e"
  11. "mtp2_if/logger"
  12. "mtp2_if/models"
  13. "net/http"
  14. )
  15. // 查套保计划请求
  16. type QryHedgePlanReq struct {
  17. UserId int64 `form:"userId" binding:"required"` //用户ID
  18. HedgePlanStatus string `form:"HedgePlanStatus" binding:"required"` // 套保计划状态(允许多个,逗号隔开)
  19. }
  20. // 查套保计划应答
  21. type QryHedgePlanRsp models.ErmcpHedgePlan
  22. // QueryHedgePlan 查询套保计划
  23. // @Summary 查询套保计划
  24. // @Produce json
  25. // @Security ApiKeyAuth
  26. // @Param userId query int true "用户ID"
  27. // @Param HedgePlanStatus query string true "套保计划状态(允许多个,逗号隔开) - 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回"
  28. // @Success 200 {array} QryHedgePlanRsp
  29. // @Failure 500 {object} app.Response
  30. // @Router /Ermcp/QueryHedgePlan [get]
  31. // @Tags 企业风险管理(app)
  32. func QueryHedgePlan(c *gin.Context) {
  33. appG := app.Gin{C: c}
  34. req := QryHedgePlanReq{}
  35. if err := c.ShouldBind(&req); err != nil {
  36. logger.GetLogger().Errorf("query hedgeplanReq,%v", err)
  37. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  38. return
  39. }
  40. var m = models.ErmcpHedgePlan{Areauserid: req.UserId}
  41. if d, err := m.GetData(req.HedgePlanStatus); err == nil {
  42. appG.Response(http.StatusOK, e.SUCCESS, d)
  43. } else {
  44. logger.GetLogger().Errorf("query fail, %v", err)
  45. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  46. }
  47. }