tapd.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package model
  2. import "go-common/library/ecode"
  3. // Pagination Pagination.
  4. type Pagination struct {
  5. PageSize int `form:"page_size" json:"page_size"`
  6. PageNum int `form:"page_num" json:"page_num"`
  7. }
  8. // Verify verify the value of pageNum and pageSize.
  9. func (p *Pagination) Verify() error {
  10. if p.PageNum < 0 {
  11. return ecode.MerlinIllegalPageNumErr
  12. } else if p.PageNum == 0 {
  13. p.PageNum = DefaultPageNum
  14. }
  15. if p.PageSize < 0 {
  16. return ecode.MerlinIllegalPageSizeErr
  17. } else if p.PageSize == 0 {
  18. p.PageSize = DefaultPageSize
  19. }
  20. return nil
  21. }
  22. // HookURLUpdateReq Hook URL Update Req.
  23. type HookURLUpdateReq struct {
  24. ID int64 `json:"id"`
  25. URL string `json:"url"`
  26. WorkspaceID int `json:"workspace_id"`
  27. Status int `json:"status"`
  28. Events []string `json:"events"`
  29. }
  30. // QueryHookURLReq Query Hook URL Req
  31. type QueryHookURLReq struct {
  32. Pagination
  33. HookURLUpdateReq
  34. UpdateBy string `json:"update_by"`
  35. }
  36. // QueryHookURLRep Query Hook URL Rep.
  37. type QueryHookURLRep struct {
  38. Pagination
  39. Total int64 `json:"total"`
  40. HookUrls []*HookUrl `json:"hook_urls"`
  41. }
  42. // EventRequest Event Request.
  43. type EventRequest struct {
  44. Event Event `json:"event"`
  45. WorkspaceID string `json:"workspace_id"`
  46. EventID string `json:"id"`
  47. Created string `json:"created"`
  48. Secret string `json:"secret"`
  49. }
  50. // EventCallBackRequest Event CallBack Request.
  51. type EventCallBackRequest struct {
  52. Code int `json:"code"`
  53. Data interface{} `json:"data"`
  54. }
  55. // QueryEventLogReq Query Event Log Req
  56. type QueryEventLogReq struct {
  57. Pagination
  58. Event Event `json:"event"`
  59. WorkspaceID int `json:"workspace_id"`
  60. EventID int `json:"id"`
  61. }
  62. // QueryEventLogRep Query Event Log Rep.
  63. type QueryEventLogRep struct {
  64. Pagination
  65. Total int64 `json:"total"`
  66. EventLogs []*EventLog `json:"event_logs"`
  67. }