archive.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. package academy
  2. const (
  3. //StateRemove 移除状态
  4. StateRemove = -1
  5. //StateNormal 正常状态
  6. StateNormal = 0
  7. //BusinessForArchvie 稿件
  8. BusinessForArchvie = 1
  9. //BusinessForArticle 专栏
  10. BusinessForArticle = 2
  11. //LogClientAcademy 日志服务类型
  12. LogClientAcademy = 181
  13. //DefaultState check search archive state
  14. DefaultState = 2018
  15. )
  16. //TableName get table name
  17. func (a *Archive) TableName() string {
  18. return "academy_archive"
  19. }
  20. //Archive for academy achive & article.
  21. type Archive struct {
  22. ID int64 `gorm:"column:id"`
  23. OID int64 `gorm:"column:oid"`
  24. Title string `gorm:"column:title"`
  25. State int8 `gorm:"column:state"`
  26. Business int8 `gorm:"column:business"`
  27. CTime string `gorm:"column:ctime"`
  28. MTime string `gorm:"column:mtime"`
  29. Comment string `gorm:"column:comment"`
  30. Hot int64 `gorm:"column:hot"`
  31. }
  32. //TableName get table name
  33. func (at *ArchiveTag) TableName() string {
  34. return "academy_archive_tag"
  35. }
  36. //ArchiveTag for academy achive & tag relation .
  37. type ArchiveTag struct {
  38. ID int64 `gorm:"column:id"`
  39. OID int64 `gorm:"column:oid"`
  40. TID int64 `gorm:"column:tid"`
  41. State int8 `gorm:"column:state"`
  42. Business int8 `gorm:"column:business"`
  43. CTime string `gorm:"column:ctime"`
  44. MTime string `gorm:"column:mtime"`
  45. }
  46. //ArchiveOrigin for archive list.
  47. type ArchiveOrigin struct {
  48. OID int64
  49. TIDs []int64
  50. Comment string
  51. Business int8
  52. }
  53. //ArchiveCount get archive count by tid.
  54. type ArchiveCount struct {
  55. TID int64 `gorm:"column:tid"`
  56. Count int `gorm:"column:count"` //当前tag关联的稿件量
  57. }
  58. //ArchiveMeta for archive meta.
  59. type ArchiveMeta struct {
  60. OID int64 `json:"oid"`
  61. State int32 `json:"state"`
  62. Forbid int8 `json:"forbid"`
  63. Cover string `json:"cover"`
  64. Type string `json:"type"`
  65. Title string `json:"title"`
  66. UName string `json:"uname"`
  67. Comment string `json:"comment"`
  68. CTime int64 `json:"ctime"`
  69. MTime int64 `json:"mtime"`
  70. Tags map[int][]*TagMeta `json:"tags"`
  71. Hot int64 `json:"hot"`
  72. }
  73. //ArchiveTags for archive tag relation.
  74. type ArchiveTags struct {
  75. ID int64 `gorm:"column:id"`
  76. TID int64 `gorm:"column:tid"`
  77. OID int64 `gorm:"column:oid"`
  78. Type int8 `gorm:"column:type"`
  79. Business int8 `gorm:"column:business"`
  80. }
  81. //Archives for archive list
  82. type Archives struct {
  83. Pager *Pager `json:"pager"`
  84. Items []*ArchiveMeta `json:"items"`
  85. }
  86. // Pager Pager def.
  87. type Pager struct {
  88. Num int `json:"num"`
  89. Size int `json:"size"`
  90. Total int `json:"total"`
  91. }
  92. // LogParam for manager.
  93. type LogParam struct {
  94. UID int64 `json:"uid"`
  95. UName string `json:"uname"`
  96. Action string `json:"action"`
  97. TID int64 `json:"tid"`
  98. OIDs string `json:"oids"`
  99. OName string `json:"oname"`
  100. OState int8 `json:"ostate"`
  101. }
  102. // EsParam for es param.
  103. type EsParam struct {
  104. OID int64
  105. Business int8
  106. Keyword string
  107. Uname string
  108. TID []int64
  109. Copyright int
  110. State int
  111. Pn int
  112. Ps int
  113. IP string
  114. TidsMap map[int][]int64
  115. }
  116. // EsPage for es page.
  117. type EsPage struct {
  118. Num int `json:"num"`
  119. Size int `json:"size"`
  120. Total int `json:"total"`
  121. }
  122. // EsArc for search archive.
  123. type EsArc struct {
  124. OID int64 `json:"oid"`
  125. TID []int64 `json:"tid"`
  126. }
  127. // SearchResult archive list from search.
  128. type SearchResult struct {
  129. Page *EsPage `json:"page"`
  130. Result []*EsArc `json:"result"`
  131. }