article.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package models
  2. import (
  3. "database/sql"
  4. "time"
  5. )
  6. type Language uint8
  7. const (
  8. LangRu Language = 1
  9. LangEn Language = 2
  10. )
  11. type ArticlePreview struct {
  12. ID uint64 `db:"id"`
  13. URL string `db:"url"`
  14. Title string `db:"title"`
  15. Image sql.NullString `db:"image"`
  16. PreviewText sql.NullString `db:"preview_text"`
  17. PublishTime time.Time `db:"publish_time"`
  18. }
  19. type Article struct {
  20. ID uint64 `db:"id"`
  21. URL string `db:"url"`
  22. Title string `db:"title"`
  23. Image sql.NullString `db:"image"`
  24. Text string `db:"text"`
  25. PreviewText sql.NullString `db:"preview_text"`
  26. PublishTime time.Time `db:"publish_time"`
  27. MetaKeywords sql.NullString `db:"meta_keywords"`
  28. MetaDescription sql.NullString `db:"meta_desc"`
  29. IsActive bool `db:"is_active"`
  30. Language Language `db:"language"`
  31. }
  32. type ArticleForm struct {
  33. ID uint64
  34. Title string `form:"title" validate:"required,max=255"`
  35. Image string `form:"image" validate:"uri,max=255"`
  36. URL string `form:"url" validate:"required,max=255"`
  37. Text string `form:"text" validate:"required"`
  38. PreviewText string `form:"preview_text" validate:"max=255"`
  39. MetaKeywords string `form:"meta_keywords" validate:"max=255"`
  40. MetaDescription string `form:"meta_description" validate:"max=255"`
  41. IsActive bool `form:"is_active"`
  42. PublishTime string `form:"publish_time" validate:"required"`
  43. Tags []string `form:"tag"`
  44. ActiveTags map[uint64]bool
  45. }