app.go 4.0 KB

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