model.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package model
  2. // Document id and content
  3. type Document struct {
  4. ID uint64 `json:"id"`
  5. Content string `json:"content"`
  6. }
  7. // RiotSearchReq search request params
  8. type RiotSearchReq struct {
  9. IDs []uint64 `form:"ids,split"`
  10. Keyword string `form:"keyword" validate:"required"`
  11. Pn int `form:"pn" validate:"min=1"`
  12. Ps int `form:"ps" validate:"min=0"`
  13. }
  14. // IDsResp resp of ids
  15. type IDsResp struct {
  16. IDs []uint64 `json:"ids"`
  17. Tokens []string `json:"tokens"`
  18. Page *Page `json:"page"`
  19. }
  20. // DocumentsResp resp of documents
  21. type DocumentsResp struct {
  22. Documents []Document `json:"ducuments"`
  23. Tokens []string `json:"tokens"`
  24. Page *Page `json:"page"`
  25. }
  26. // Page Pager
  27. type Page struct {
  28. PageNum int `json:"pn"`
  29. PageSize int `json:"ps"`
  30. Total int `json:"total"`
  31. }
  32. // **********************
  33. // * Model for archives *
  34. // **********************
  35. // ArchiveMessage databus message
  36. type ArchiveMessage struct {
  37. Action string `json:"action"`
  38. Table string `json:"table"`
  39. New *ArchiveMeta `json:"new"`
  40. Old *ArchiveMeta `json:"old"`
  41. }
  42. // ArchiveMeta Archive Metadata
  43. type ArchiveMeta struct {
  44. AID uint64 `json:"aid"`
  45. Title string `json:"title"`
  46. State int `json:"state"`
  47. }
  48. // States archive states
  49. type States struct {
  50. LegalStates map[int]bool
  51. }
  52. // PubStates publish states
  53. var PubStates = &States{
  54. LegalStates: map[int]bool{
  55. -40: true,
  56. 0: true,
  57. 10000: true,
  58. 1: true,
  59. 1001: true,
  60. 15000: true,
  61. 20000: true,
  62. 30000: true,
  63. },
  64. }
  65. // Legal return leagal
  66. func (l *States) Legal(state int) bool {
  67. if _, ok := l.LegalStates[state]; ok {
  68. return true
  69. }
  70. return false
  71. }