project.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package model
  2. import "go-common/library/ecode"
  3. // ProjectInfo def
  4. type ProjectInfo struct {
  5. ProjectID int `json:"project_id" gorm:"column:project_id"`
  6. Name string `json:"name" gorm:"column:name"`
  7. Description string `json:"description" gorm:"column:description"`
  8. WebURL string `json:"web_url" gorm:"column:web_url"`
  9. Repo string `json:"repo" gorm:"column:repo"`
  10. DefaultBranch string `json:"default_branch" gorm:"column:default_branch"`
  11. Owner string `json:"owner" gorm:"column:owner"`
  12. SpaceName string `json:"namespace_name" gorm:"column:namespace_name"`
  13. SpaceKind string `json:"namespace_kind" gorm:"column:namespace_kind"`
  14. Saga bool `json:"saga" gorm:"column:saga"`
  15. Runner bool `json:"runner" gorm:"column:runner"`
  16. Department string `json:"department" gorm:"column:department"`
  17. Business string `json:"business" gorm:"column:business"`
  18. Language string `json:"language" gorm:"column:language"`
  19. }
  20. // ProjectInfoRequest Project Info Request.
  21. type ProjectInfoRequest struct {
  22. Pagination
  23. TeamParam
  24. Username string `form:"username"`
  25. Name string `form:"name"`
  26. }
  27. // ProjectInfoResp ...
  28. type ProjectInfoResp struct {
  29. Total int `json:"total"`
  30. Saga int `json:"saga"`
  31. Runner int `json:"runner"`
  32. SagaScale int `json:"saga_scale"`
  33. RunnerScale int `json:"runner_scale"`
  34. PageNum int `json:"page_num"`
  35. PageSize int `json:"page_size"`
  36. ProjectInfo []*MyProjectInfo `json:"ProjectInfo"`
  37. }
  38. // FavoriteProjectsResp resp for favorite projects
  39. type FavoriteProjectsResp struct {
  40. Total int `json:"total"`
  41. Pagination
  42. Projects []*MyProjectInfo `json:"projects,omitempty"`
  43. }
  44. // ProjectFavorite def
  45. type ProjectFavorite struct {
  46. ID int64 `json:"id,omitempty" gorm:"column:id"`
  47. UserName string `json:"user_name,omitempty" gorm:"column:user_name"`
  48. ProjID int `json:"proj_id,omitempty" gorm:"column:proj_id"`
  49. }
  50. // EditFavoriteReq params for edit favorite
  51. type EditFavoriteReq struct {
  52. ProjID int `json:"proj_id" validate:"required"`
  53. Star bool `json:"star"`
  54. }
  55. // MyProjectInfo mask as star
  56. type MyProjectInfo struct {
  57. *ProjectInfo
  58. Star bool `json:"is_star"`
  59. }
  60. // ProjectsInfoResp resp for query projects with start mark
  61. type ProjectsInfoResp struct {
  62. Projects []*MyProjectInfo `json:"projects"`
  63. }
  64. // Verify verify the value of pageNum and pageSize.
  65. func (p *Pagination) Verify() error {
  66. if p.PageNum < 0 {
  67. return ecode.MerlinIllegalPageNumErr
  68. } else if p.PageNum == 0 {
  69. p.PageNum = DefaultPageNum
  70. }
  71. if p.PageSize < 0 {
  72. return ecode.MerlinIllegalPageSizeErr
  73. } else if p.PageSize == 0 {
  74. p.PageSize = DefaultPageSize
  75. }
  76. return nil
  77. }