tree.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. package model
  2. import (
  3. xtime "go-common/library/time"
  4. "time"
  5. )
  6. //App app.
  7. type App struct {
  8. ID int64 `json:"id" gorm:"primary_key"`
  9. Name string `json:"name"`
  10. TreeID int64 `json:"tree_id"`
  11. Env string `json:"env"`
  12. Zone string `json:"zone"`
  13. Token string `json:"token"`
  14. Status int8 `json:"status"`
  15. Ctime xtime.Time `json:"ctime"`
  16. Mtime xtime.Time `json:"mtime"`
  17. }
  18. // TableName app
  19. func (App) TableName() string {
  20. return "app"
  21. }
  22. // Node node.
  23. type Node struct {
  24. Name string `json:"name"`
  25. Path string `json:"path"`
  26. TreeID int64 `json:"tree_id"`
  27. }
  28. // TreeNode TreeNode.
  29. type TreeNode struct {
  30. Alias string `json:"alias"`
  31. CreatedAt string `json:"created_at"`
  32. Name string `json:"name"`
  33. Path string `json:"path"`
  34. Tags interface{} `json:"tags"`
  35. Type int `json:"type"`
  36. }
  37. // Res res.
  38. type Res struct {
  39. Count int `json:"count"`
  40. Data []*TreeNode `json:"data"`
  41. Page int `json:"page"`
  42. Results int `json:"results"`
  43. }
  44. // AppPager app pager
  45. type AppPager struct {
  46. Total int64 `json:"total"`
  47. Pn int64 `json:"pn"`
  48. Ps int64 `json:"ps"`
  49. Items []*App `json:"items"`
  50. }
  51. // Resp tree resp
  52. type Resp struct {
  53. Data map[string]*Tree `json:"data"`
  54. }
  55. // Tree node.
  56. type Tree struct {
  57. Name string `json:"name"`
  58. Type int `json:"type"`
  59. Path string `json:"path"`
  60. Tags *TreeTag `json:"tags"`
  61. Children map[string]*Tree `json:"children"`
  62. }
  63. //TreeTag tree tag.
  64. type TreeTag struct {
  65. Ops string `json:"ops"`
  66. Rds string `json:"rds"`
  67. }
  68. //Env env.
  69. type Env struct {
  70. Name string `json:"name"`
  71. NikeName string `json:"nike_name"`
  72. Token string `json:"token"`
  73. }
  74. //RoleNode roleNode .
  75. type RoleNode struct {
  76. ID int64 `json:"id"`
  77. Name string `json:"name"`
  78. Path string `json:"path"`
  79. Type int8 `json:"type"`
  80. Role int8 `json:"role"`
  81. }
  82. //UpdateTokenReq ...
  83. type UpdateTokenReq struct {
  84. AppName string `form:"app_name" validate:"required"`
  85. Env string `form:"env" validate:"required"`
  86. Zone string `form:"zone" validate:"required"`
  87. TreeID int64 `form:"tree_id" validate:"required"`
  88. }
  89. //CreateReq ...
  90. type CreateReq struct {
  91. AppName string `form:"app_name" validate:"required"`
  92. TreeID int64 `form:"tree_id" validate:"required"`
  93. }
  94. //AppListReq ...
  95. type AppListReq struct {
  96. AppName string `form:"app_name"`
  97. Bu string `form:"bu"`
  98. Team string `form:"team"`
  99. Pn int64 `form:"pn" default:"1" validate:"min=1"`
  100. Ps int64 `form:"ps" default:"20" validate:"min=1"`
  101. Status int8 `form:"status"`
  102. }
  103. //EnvsByTeamReq ...
  104. type EnvsByTeamReq struct {
  105. AppName string `form:"app_name"`
  106. Zone string `form:"zone"`
  107. Team string `form:"team"`
  108. }
  109. //EnvsReq ...
  110. type EnvsReq struct {
  111. AppName string `form:"app_name" validate:"required"`
  112. TreeID int64 `form:"tree_id" validate:"required"`
  113. Zone string `form:"zone" validate:"required"`
  114. }
  115. //NodeTreeReq ...
  116. type NodeTreeReq struct {
  117. Node string `form:"node"`
  118. Team string `form:"team"`
  119. }
  120. //ZoneCopyReq ...
  121. type ZoneCopyReq struct {
  122. AppName string `form:"app_name" validate:"required"`
  123. From string `form:"from_zone" validate:"required"`
  124. To string `form:"to_zone" validate:"required"`
  125. TreeID int64 `form:"tree_id" validate:"required"`
  126. }
  127. //CasterEnvsReq ...
  128. type CasterEnvsReq struct {
  129. TreeID int64 `form:"tree_id" validate:"required"`
  130. Zone string `form:"zone" validate:"required"`
  131. Auth string `form:"auth" validate:"required"`
  132. }
  133. //CacheData ...
  134. type CacheData struct {
  135. Data map[int64]*RoleNode `json:"data"`
  136. CTime time.Time `json:"ctime"`
  137. }
  138. //AppStatusReq ...
  139. type AppStatusReq struct {
  140. TreeID int64 `form:"tree_id" validate:"required"`
  141. Status int8 `form:"status" default:"1"`
  142. }