qryErmcp.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 QryErmcpReq struct {
  17. ContractType int32 `form:"contracttype" binding:"required"` // 合同类型
  18. QueryType int32 `form:"QueryType" binding:"required"` // 查询类型 1-全部 2-待点价 3-履约结算
  19. }
  20. // 查询合同应答
  21. type QryErmcpRsp models.ErmcpModel
  22. // QueryContract 企业风险管理合同查询
  23. // @Summary 查询合同(采购和销售)
  24. // @Produce json
  25. // @Security ApiKeyAuth
  26. // @Param contracttype query int true "合同类型 1-采购, -1-销售"
  27. // @Param QueryType query int true "查询类型 1-全部 2-待点价 3-履约结算"
  28. // @Success 200 {array} QryErmcpRsp
  29. // @Failure 500 {object} app.Response
  30. // @Router /Ermcp/QueryContract [get]
  31. // @Tags 企业风险管理(app)
  32. func QueryContract(c *gin.Context) {
  33. appG := app.Gin{C: c}
  34. var req QryErmcpReq
  35. if err := c.ShouldBind(&req); err != nil {
  36. logger.GetLogger().Errorf("parse query req: %v", err)
  37. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  38. return
  39. }
  40. // 参数检查
  41. if req.ContractType != 1 && req.ContractType != -1 {
  42. logger.GetLogger().Errorf("ContractType should in(1, -1)")
  43. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  44. return
  45. }
  46. if req.QueryType != 0 && req.QueryType != 1 && req.QueryType != 2 {
  47. logger.GetLogger().Errorf("QueryType should in(0, 1, 2)")
  48. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  49. return
  50. }
  51. var m models.ErmcpModel
  52. if d, err := m.GetData(req.ContractType, req.QueryType); err == nil {
  53. appG.Response(http.StatusOK, e.SUCCESS, d)
  54. } else {
  55. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  56. }
  57. }