qryErmcp.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /**
  2. * @Author: zou.yingbin
  3. * @Create : 2021/1/6 10:12
  4. * @Modify : 2021/1/6 10:12
  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 QrySpotContractReq struct {
  17. UserId int64 `form:"userId" binding:"required"` //用户ID
  18. QueryType int32 `form:"QueryType" binding:"required"` // 查询类型 1-未提交 2-待审核 3-履约中 4-已完成
  19. }
  20. // 查询现货合同应答
  21. type QrySpotContractRsp models.ErmcpSpotContractModel
  22. // QuerySpotContract 企业风险管理合同查询
  23. func QuerySpotContract(c *gin.Context) {
  24. appG := app.Gin{C: c}
  25. var req QrySpotContractReq
  26. if err := c.ShouldBind(&req); err != nil {
  27. logger.GetLogger().Errorf("parse query req: %v", err)
  28. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  29. return
  30. }
  31. var m = models.ErmcpSpotContractModel{USERID: req.UserId}
  32. if d, err := m.GetData(req.QueryType); err == nil {
  33. appG.Response(http.StatusOK, e.SUCCESS, d)
  34. } else {
  35. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  36. }
  37. }
  38. // 查询合同请求结构
  39. type QryErmcpReq struct {
  40. UserId int64 `form:"userId" binding:"required"` //用户ID
  41. ContractType int32 `form:"contracttype" binding:"required"` // 合同类型
  42. QueryType int32 `form:"querytype" binding:"required"` // 查询类型 1-全部 2-待点价 3-履约结算
  43. ContractId string `form:"contractid"` // 合同id(SpotContractId)
  44. }
  45. // 查询合同应答
  46. type QryErmcpRsp models.ErmcpModel
  47. // QueryContract 企业风险管理合同查询
  48. func QueryContract(c *gin.Context) {
  49. appG := app.Gin{C: c}
  50. var req QryErmcpReq
  51. if err := c.ShouldBind(&req); err != nil {
  52. logger.GetLogger().Errorf("parse query req: %v", err)
  53. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  54. return
  55. }
  56. // 参数检查
  57. if req.ContractType != 1 && req.ContractType != -1 {
  58. logger.GetLogger().Errorf("ContractType should in(1, -1)")
  59. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  60. return
  61. }
  62. if req.QueryType != 1 && req.QueryType != 2 && req.QueryType != 3 {
  63. logger.GetLogger().Errorf("QueryType should in(1, 2, 3)")
  64. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  65. return
  66. }
  67. var m = models.ErmcpModel{UserID: req.UserId, SpotContractId: req.ContractId}
  68. if d, err := m.GetData(req.ContractType, req.QueryType); err == nil {
  69. appG.Response(http.StatusOK, e.SUCCESS, d)
  70. } else {
  71. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  72. }
  73. }
  74. // QueryTradeConfigTMP
  75. // @Summary 查询交易模板配置
  76. // @Produce json
  77. // @Security ApiKeyAuth
  78. // @Param areauserid query int false "所属机构id"
  79. // @Success 200 {array} models.ErmcpTradeConfigTMP
  80. // @Failure 500 {object} app.Response
  81. // @Router /Ermcp/QueryTradeConfigTMP [get]
  82. // @Tags 企业风险管理(app)
  83. func QueryTradeConfigTMP(c *gin.Context) {
  84. a := app.GinUtils{Gin: app.Gin{C: c}}
  85. req := struct {
  86. Areauserid int64 `form:"areauserid"` // 机构id
  87. }{}
  88. a.DoBindReq(&req)
  89. // 现在表里id都为1, 改为固定查arearuserid=1的
  90. req.Areauserid = 1
  91. m := models.ErmcpTradeConfigTMP{AREAUSERID: req.Areauserid}
  92. a.DoGetDataI(&m)
  93. }