/** * @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 QryErmcpReq struct { 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 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 != 0 && req.QueryType != 1 && req.QueryType != 2 { logger.GetLogger().Errorf("QueryType should in(0, 1, 2)") appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil) return } var m models.ErmcpModel 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) } }