article.go 1.5 KB

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