egg.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. package egg
  2. import (
  3. "go-common/app/admin/main/feed/model/common"
  4. "go-common/library/time"
  5. )
  6. var (
  7. //NotDelete egg not deleted
  8. NotDelete uint8
  9. //Delete egg deleted
  10. Delete uint8 = 1
  11. //Publish egg publish
  12. Publish uint8 = 1
  13. //NotPublish egg not publish
  14. NotPublish uint8
  15. //Business log businessID
  16. Business = 201
  17. )
  18. //Obj add egg object
  19. type Obj struct {
  20. Query []string `json:"query" form:"query,split" validate:"required"`
  21. Stime time.Time `json:"stime" form:"stime"`
  22. Etime time.Time `json:"etime" form:"etime"`
  23. ShowCount int `json:"show_count" form:"show_count" validate:"required"`
  24. Plat string `json:"plat" form:"plat" validate:"required"`
  25. }
  26. //ObjUpdate add egg object
  27. type ObjUpdate struct {
  28. ID uint `form:"id" validate:"required"`
  29. Query []string `json:"query" form:"query,split" validate:"required"`
  30. Stime time.Time `json:"stime" form:"stime"`
  31. Etime time.Time `json:"etime" form:"etime"`
  32. ShowCount int `json:"show_count" form:"show_count" validate:"required"`
  33. Plat string `json:"plat" form:"plat" validate:"required"`
  34. }
  35. //Plat egg plat
  36. type Plat struct {
  37. EggID uint `json:"egg_id"`
  38. Plat uint8 `json:"plat"`
  39. Conditions string `json:"conditions"`
  40. Build string `json:"build"`
  41. URL string `json:"url"`
  42. Md5 string `json:"md5"`
  43. Size uint `json:"size"`
  44. Deleted uint8 `json:"deleted"`
  45. }
  46. //Query egg query
  47. type Query struct {
  48. EggID uint
  49. Word string
  50. STime time.Time
  51. ETime time.Time
  52. Deleted uint8
  53. }
  54. //Egg egg
  55. type Egg struct {
  56. ID uint
  57. Stime time.Time
  58. Etime time.Time
  59. ShowCount int
  60. UID int64 `gorm:"column:uid"`
  61. Publish uint8
  62. Person string
  63. Delete uint8
  64. }
  65. //IndexParam Index egg index param
  66. type IndexParam struct {
  67. ID string `json:"id" form:"id"` // ID
  68. Stime string `json:"stime" form:"stime"` // 开始时间
  69. Etime string `json:"etime" form:"etime"` // 结束时间
  70. Person string `json:"person" form:"person"` // 创建人
  71. Word string `json:"word" form:"word"` // 关键词
  72. Ps int `json:"ps" form:"ps" default:"20"` // 分页大小
  73. Pn int `json:"pn" form:"pn" default:"1"` // 第几个分页
  74. }
  75. //Index egg index
  76. type Index struct {
  77. ID uint `json:"id"`
  78. Words string `json:"words"`
  79. Stime time.Time `json:"stime"`
  80. Etime time.Time `json:"etime"`
  81. Plat []Plat `json:"plat"`
  82. ShowCount int `json:"show_count"`
  83. Publish uint8 `json:"publish"`
  84. Person string `json:"person"`
  85. }
  86. //IndexPager return values
  87. type IndexPager struct {
  88. Item []*Index `json:"item"`
  89. Page common.Page `json:"page"`
  90. }
  91. //SearchEgg for searching
  92. type SearchEgg struct {
  93. ID uint `json:"id"`
  94. Words []string `json:"query_list"`
  95. Stime time.Time `json:"stime"`
  96. Etime time.Time `json:"etime"`
  97. Plat map[uint8]Plat `json:"plat"`
  98. //Plat []Plat `json:"plat"`
  99. ShowCount int `json:"show_count"`
  100. Publish uint8 `json:"publish"`
  101. }
  102. //SearchEggWeb for searching
  103. type SearchEggWeb struct {
  104. ID uint `json:"id"`
  105. Words []string `json:"query_list"`
  106. Stime time.Time `json:"stime"`
  107. Etime time.Time `json:"etime"`
  108. Plat map[uint8][]Plat `json:"plat"`
  109. //Plat []Plat `json:"plat"`
  110. ShowCount int `json:"show_count"`
  111. Publish uint8 `json:"publish"`
  112. }
  113. // TableName Egg
  114. func (a SearchEggWeb) TableName() string {
  115. return "egg"
  116. }
  117. // TableName Egg
  118. func (a Egg) TableName() string {
  119. return "egg"
  120. }
  121. // TableName Egg plat
  122. func (a Plat) TableName() string {
  123. return "egg_plat"
  124. }
  125. // TableName Egg query
  126. func (a Query) TableName() string {
  127. return "egg_query"
  128. }
  129. // TableName Egg
  130. func (a Index) TableName() string {
  131. return "egg"
  132. }
  133. // TableName Egg
  134. func (a SearchEgg) TableName() string {
  135. return "egg"
  136. }