/** * @Author: zou.yingbin * @Create : 2021/1/6 10:12 * @Modify : 2021/1/6 10:12 */ package ermcp import ( "github.com/gin-gonic/gin" "mtp2_if/global/app" "mtp2_if/global/e" "mtp2_if/logger" "mtp2_if/models" "net/http" ) // 查询现货合同 type QrySpotContractReq struct { UserId int64 `form:"userId" binding:"required"` //用户ID QueryType int32 `form:"QueryType" binding:"required"` // 查询类型 1-未提交 2-待审核 3-履约中 4-已完成 } // 查询现货合同应答 type QrySpotContractRsp models.ErmcpSpotContractModel // QuerySpotContract 企业风险管理合同查询 // @Summary 查询现货合同(对应现货合同菜单) // @Produce json // @Security ApiKeyAuth // @Param userId query int true "用户ID" // @Param QueryType query int true "查询类型 1-未提交 2-待审核 3-履约中 4-已完成" // @Success 200 {array} QrySpotContractRsp // @Failure 500 {object} app.Response // @Router /Ermcp/QuerySpotContract [get] // @Tags 企业风险管理(app) func QuerySpotContract(c *gin.Context) { appG := app.Gin{C: c} var req QrySpotContractReq if err := c.ShouldBind(&req); err != nil { logger.GetLogger().Errorf("parse query req: %v", err) appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil) return } var m = models.ErmcpSpotContractModel{USERID: req.UserId} if d, err := m.GetData(req.QueryType); err == nil { appG.Response(http.StatusOK, e.SUCCESS, d) } else { appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil) } } // 查询合同请求结构 type QryErmcpReq struct { UserId int64 `form:"userId" binding:"required"` //用户ID ContractType int32 `form:"contracttype" binding:"required"` // 合同类型 QueryType int32 `form:"querytype" binding:"required"` // 查询类型 1-全部 2-待点价 3-履约结算 } // 查询合同应答 type QryErmcpRsp models.ErmcpModel // QueryContract 企业风险管理合同查询 // @Summary 查询合同(采购和销售) // @Produce json // @Security ApiKeyAuth // @Param userId query int true "用户ID" // @Param contracttype query int true "合同类型 1-采购, -1-销售" // @Param querytype query int true "查询类型 1-全部 2-待点价 3-履约结算" // @Success 200 {array} QryErmcpRsp // @Failure 500 {object} app.Response // @Router /Ermcp/QueryContract [get] // @Tags 企业风险管理(app) func QueryContract(c *gin.Context) { appG := app.Gin{C: c} var req QryErmcpReq if err := c.ShouldBind(&req); err != nil { logger.GetLogger().Errorf("parse query req: %v", err) appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil) return } // 参数检查 if req.ContractType != 1 && req.ContractType != -1 { logger.GetLogger().Errorf("ContractType should in(1, -1)") appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil) return } if req.QueryType != 1 && req.QueryType != 2 && req.QueryType != 3 { logger.GetLogger().Errorf("QueryType should in(1, 2, 3)") appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil) return } var m = models.ErmcpModel{UserID: req.UserId} if d, err := m.GetData(req.ContractType, req.QueryType); err == nil { appG.Response(http.StatusOK, e.SUCCESS, d) } else { appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil) } }