model.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package model
  2. // pagination.
  3. const (
  4. DefaultPageSize = 10
  5. DefaultPageNum = 1
  6. )
  7. // Pagination Pagination.
  8. type Pagination struct {
  9. PageSize int `form:"page_size"`
  10. PageNum int `form:"page_num"`
  11. }
  12. // TeamParam struct for organization Info.
  13. type TeamParam struct {
  14. Department string `form:"department"`
  15. Business string `form:"business"`
  16. }
  17. // EmptyReq params for request without params
  18. type EmptyReq struct {
  19. }
  20. // EmptyResp resp for response without data
  21. type EmptyResp struct {
  22. }
  23. // Task def
  24. type Task struct {
  25. ID int64 `json:"id,omitempty" gorm:"column:id"`
  26. ProjID int `json:"proj_id,omitempty" gorm:"column:proj_id"`
  27. EventType string `json:"event_type,omitempty" gorm:"column:event_type"`
  28. Author string `json:"author,omitempty" gorm:"author"`
  29. MRID int `json:"mr_id,omitempty" gorm:"column:mr_id"`
  30. URL string `json:"url,omitempty" gorm:"column:url"`
  31. Status int `json:"status,omitempty" gorm:"status"`
  32. TaskDetails string `json:"task_details,omitempty" gorm:"task_details"`
  33. SourceBranch string `json:"source_branch,omitempty" gorm:"source_branch"`
  34. TargetBranch string `json:"target_branch,omitempty" gorm:"target_branch"`
  35. Title string `json:"title,omitempty" gorm:"title"`
  36. }
  37. // TasksReq params for tasks
  38. type TasksReq struct {
  39. ProjID int `form:"proj_id" validate:"required"`
  40. Statuses []int `form:"statuses,split" default:"3,4"` // 3 - running, 4 - waiting, 默认查运行中和等待的任务
  41. }
  42. // TasksResp resp for tasks
  43. type TasksResp struct {
  44. Tasks []*Task `json:"tasks,omitempty"`
  45. }
  46. // User User.
  47. type User struct {
  48. Name string `json:"username" gorm:"column:name"`
  49. EMail string `json:"email" gorm:"column:email"`
  50. }
  51. // RequireVisibleUser def
  52. type RequireVisibleUser struct {
  53. UserName string
  54. NickName string
  55. }
  56. // ContactInfo def
  57. type ContactInfo struct {
  58. ID string `json:"id,omitempty" gorm:"column:id"`
  59. UserName string `json:"english_name" gorm:"column:user_name"`
  60. UserID string `json:"userid" gorm:"column:user_id"`
  61. NickName string `json:"name" gorm:"column:nick_name"`
  62. VisibleSaga bool `json:"visible_saga" gorm:"column:visible_saga"`
  63. }
  64. // AlmostEqual return the compare result with fields
  65. func (contact *ContactInfo) AlmostEqual(other *ContactInfo) bool {
  66. if contact.UserID == other.UserID &&
  67. contact.UserName == other.UserName &&
  68. contact.NickName == other.NickName {
  69. return true
  70. }
  71. return false
  72. }