contract.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "eta/eta_data_push/models"
  5. "eta/eta_data_push/services"
  6. "strconv"
  7. )
  8. // 合约
  9. type ContractController struct {
  10. BaseAuthController
  11. }
  12. // @Title 获取合约接口
  13. // @Description 获取合约接口
  14. // @Success 200 {object} models.ContractListReq
  15. // @router /list [post]
  16. func (this *ContractController) ContractList() {
  17. br := new(models.BaseResponse).Init()
  18. defer func() {
  19. this.Data["json"] = br
  20. this.ServeJSON()
  21. }()
  22. var req models.ContractListReq
  23. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  24. if err != nil {
  25. br.Msg = "参数解析异常!"
  26. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  27. return
  28. }
  29. if req.Source <= 0 {
  30. br.Msg = "渠道编码错误!"
  31. br.ErrMsg = "渠道编码错误,Source:" + strconv.Itoa(req.Source)
  32. return
  33. }
  34. list, err := services.GetContractList(req.Source)
  35. if err != nil {
  36. br.Msg = "获取数据失败!"
  37. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  38. return
  39. }
  40. br.Ret = 200
  41. br.Success = true
  42. br.Msg = "获取成功"
  43. br.Data = list
  44. }