add_ver.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. package model
  2. import "go-common/library/time"
  3. // Limit def
  4. type Limit struct {
  5. MobiApp []string // white list
  6. Device []string // black list
  7. Plat []string // white list
  8. Build *Build // build range
  9. TimeRange *TimeRange // time range
  10. Sysver *Build // system version
  11. Scale []string
  12. Arch []string
  13. Level []string
  14. IsWifi int // only wifi download
  15. }
  16. // Build def
  17. type Build struct {
  18. LT int `json:"lt"` // less than
  19. GT int `json:"gt"` // great than
  20. LE int `json:"le"` // less than or equal
  21. GE int `json:"ge"` // great than or equal
  22. }
  23. // TimeRange def
  24. type TimeRange struct {
  25. Stime time.Time `json:"stime"`
  26. Etime time.Time `json:"etime"`
  27. }
  28. // ResourceLimit def
  29. type ResourceLimit struct {
  30. ID int64
  31. ConfigID int64
  32. Column string
  33. Condition string
  34. Value string
  35. IsDeleted int8
  36. Mtime time.Time
  37. Ctime time.Time
  38. }
  39. // ResourceConfig def
  40. type ResourceConfig struct {
  41. ID int64
  42. ResourceID int64 `gorm:"column:resource_id"`
  43. Stime time.Time
  44. Etime time.Time
  45. Valid int8
  46. IsDeleted int8 `gorm:"column:is_deleted"`
  47. Mtime time.Time
  48. Ctime time.Time
  49. DefaultPackage int8 `gorm:"column:default_package"`
  50. IsWifi int `gorm:"column:is_wifi"`
  51. }
  52. //FileInfo : the uploaded file information
  53. type FileInfo struct {
  54. Name string `json:"name"`
  55. Size int64 `json:"size"`
  56. Type string `json:"type"`
  57. Md5 string `json:"md5"`
  58. URL string `json:"url"`
  59. }
  60. // ResourceFile represents the table structure
  61. type ResourceFile struct {
  62. ID int `json:"id"`
  63. Name string `json:"name"`
  64. Type string `json:"type"`
  65. Md5 string `json:"md5"`
  66. Size int `json:"size"`
  67. URL string `json:"url"`
  68. ResourceID int `json:"resource_id"`
  69. Ctime time.Time `json:"ctime"`
  70. Mtime time.Time `json:"mtime"`
  71. FileType int8 `json:"file_type"`
  72. FromVer int64 `json:"from_ver"`
  73. IsDeleted int8 `json:"is_deleted"`
  74. }
  75. // Resource reprensents the resource table
  76. type Resource struct {
  77. ID int64 `json:"id" params:"id"`
  78. Name string `json:"name" params:"name"`
  79. Version int64 `json:"version" params:"version"`
  80. PoolID int64 `json:"pool_id" params:"pool_id"`
  81. Ctime time.Time `json:"ctime" params:"ctime"`
  82. Mtime time.Time `json:"mtime" params:"mtime"`
  83. }
  84. // ResourcePool reprensents the resource_pool table
  85. type ResourcePool struct {
  86. ID int64 `json:"id" params:"id"`
  87. Name string `json:"name" params:"name"`
  88. Ctime time.Time `json:"ctime" params:"ctime"`
  89. Mtime time.Time `json:"mtime" params:"mtime"`
  90. }
  91. // Department reprensents the resource_department table
  92. type Department struct {
  93. ID int64 `json:"id" params:"id"`
  94. Name string `json:"name" params:"name"`
  95. Ctime time.Time `json:"ctime" params:"ctime"`
  96. Mtime time.Time `json:"mtime" params:"mtime"`
  97. Desc string `json:"desc" params:"desc"`
  98. IsDeleted uint8 `json:"is_deleted" params:"is_deleted"`
  99. }
  100. // ResponseNas represents the NAS response struct
  101. type ResponseNas struct {
  102. Code int `json:"code"`
  103. Data string `json:"data"`
  104. Message string `json:"message"`
  105. }
  106. // RequestVer is the struct of the request to upload an new version's package
  107. type RequestVer struct {
  108. Department string `form:"department" validate:"required"`
  109. DefaultPackage int `form:"default_package" validate:"min=0,max=1"`
  110. ResName string `form:"res_name" validate:"required"`
  111. ModName string `form:"mod_name" validate:"required"`
  112. MobiAPP []string `form:"mobi_app,split"`
  113. Plat []string `form:"plat,split"`
  114. Device []string `form:"device,split"`
  115. BuildRange string `form:"build_range"`
  116. TimeRange string `form:"time_range"`
  117. Sysver string `form:"sysver"`
  118. Arch []int `form:"arch,split" validate:"dive,min=1,max=3"`
  119. Level int `form:"level" validate:"min=0,max=3"`
  120. Scale []int `form:"scale,split" validate:"dive,min=1,max=3"`
  121. IsWifi int `form:"is_wifi" validate:"max=1"`
  122. }
  123. // RespAdd is the structure for add ver return
  124. type RespAdd struct {
  125. ResID int `json:"res_id"`
  126. Version int `json:"version"`
  127. }
  128. // TableName gives the table name of the model
  129. func (*Resource) TableName() string {
  130. return "resource"
  131. }
  132. // TableName gives the table name of the model
  133. func (*ResourcePool) TableName() string {
  134. return "resource_pool"
  135. }
  136. // TableName gives the table name of the model
  137. func (*ResourceFile) TableName() string {
  138. return "resource_file"
  139. }
  140. // TableName gives the table name of the model
  141. func (*ResourceLimit) TableName() string {
  142. return "resource_limit"
  143. }
  144. // TableName gives the table name of the model
  145. func (*ResourceConfig) TableName() string {
  146. return "resource_config"
  147. }
  148. // TableName gives the table name of the model
  149. func (*Department) TableName() string {
  150. return "resource_department"
  151. }