archive.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package model
  2. import (
  3. "fmt"
  4. "strings"
  5. )
  6. const _arcBatchAddSQL = "INSERT INTO es_archives(`aid`) VALUES %s"
  7. // Arc .
  8. type Arc struct {
  9. ID int64 `json:"id"`
  10. Aid int64 `json:"aid"`
  11. IsDeleted int `json:"is_deleted"`
  12. }
  13. // ArcAddParam .
  14. type ArcAddParam struct {
  15. Aids []int64 `form:"aids,split" validate:"dive,gt=1"`
  16. Gids []int64 `form:"gids,split"`
  17. MatchIDs []int64 `form:"match_ids,split"`
  18. TeamIDs []int64 `form:"team_ids,split"`
  19. TagIDs []int64 `form:"tag_ids,split"`
  20. Years []int64 `form:"years,split"`
  21. }
  22. // ArcImportParam .
  23. type ArcImportParam struct {
  24. Aid int64 `form:"aid" validate:"min=1"`
  25. Gids []int64 `form:"gids,split"`
  26. MatchIDs []int64 `form:"match_ids,split"`
  27. TeamIDs []int64 `form:"team_ids,split"`
  28. TagIDs []int64 `form:"tag_ids,split"`
  29. Years []int64 `form:"years,split"`
  30. }
  31. // ArcListParam .
  32. type ArcListParam struct {
  33. Title string `form:"title"`
  34. Aid int64 `form:"aid"`
  35. TypeID int64 `form:"type_id"`
  36. Copyright int `form:"copyright"`
  37. State string `form:"state"`
  38. Pn int `form:"pn"`
  39. Ps int `form:"ps"`
  40. }
  41. // SearchArc .
  42. type SearchArc struct {
  43. Aid int64 `json:"aid"`
  44. TypeID int64 `json:"typeid"`
  45. Title string `json:"title"`
  46. State int64 `json:"state"`
  47. Mid int64 `json:"mid"`
  48. Gid []int64 `json:"gid"`
  49. Tags []int64 `json:"tags"`
  50. Matchs []int64 `json:"matchs"`
  51. Teams []int64 `json:"teams"`
  52. Year []int64 `json:"year"`
  53. }
  54. // ArcResult .
  55. type ArcResult struct {
  56. Aid int64 `json:"aid"`
  57. TypeID int64 `json:"type_id"`
  58. Title string `json:"title"`
  59. State int64 `json:"state"`
  60. Mid int64 `json:"mid"`
  61. Uname string `json:"uname"`
  62. Games []*Game `json:"games"`
  63. Tags []*Tag `json:"tags"`
  64. Matchs []*Match `json:"matchs"`
  65. Teams []*Team `json:"teams"`
  66. Years []int64 `json:"years"`
  67. }
  68. // ArcRelation .
  69. type ArcRelation struct {
  70. AddGids []*GIDMap
  71. UpAddGids []int64
  72. UpDelGids []int64
  73. AddMatchs []*MatchMap
  74. UpAddMatchs []int64
  75. UpDelMatchs []int64
  76. AddTags []*TagMap
  77. UpAddTags []int64
  78. UpDelTags []int64
  79. AddTeams []*TeamMap
  80. UpAddTeams []int64
  81. UpDelTeams []int64
  82. AddYears []*YearMap
  83. UpAddYears []int64
  84. UpDelYears []int64
  85. }
  86. // TableName .
  87. func (a Arc) TableName() string {
  88. return "es_archives"
  89. }
  90. // ArcBatchAddSQL .
  91. func ArcBatchAddSQL(aids []int64) string {
  92. if len(aids) == 0 {
  93. return ""
  94. }
  95. var rowStrings []string
  96. for _, aid := range aids {
  97. rowStrings = append(rowStrings, fmt.Sprintf("(%d)", aid))
  98. }
  99. return fmt.Sprintf(_arcBatchAddSQL, strings.Join(rowStrings, ","))
  100. }