index.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package fetdata
  2. import (
  3. "html/template"
  4. "time"
  5. "golang-fave/utils"
  6. )
  7. type Page struct {
  8. object *utils.MySql_page
  9. }
  10. func (this *Page) Id() int {
  11. if this == nil {
  12. return 0
  13. }
  14. return this.object.A_id
  15. }
  16. func (this *Page) User() int {
  17. if this == nil {
  18. return 0
  19. }
  20. return this.object.A_user
  21. }
  22. func (this *Page) Name() string {
  23. if this == nil {
  24. return ""
  25. }
  26. return this.object.A_name
  27. }
  28. func (this *Page) Alias() string {
  29. if this == nil {
  30. return ""
  31. }
  32. return this.object.A_alias
  33. }
  34. func (this *Page) Content() template.HTML {
  35. if this == nil {
  36. return template.HTML("")
  37. }
  38. return template.HTML(this.object.A_content)
  39. }
  40. func (this *Page) MetaTitle() string {
  41. if this == nil {
  42. return ""
  43. }
  44. return this.object.A_meta_title
  45. }
  46. func (this *Page) MetaKeywords() string {
  47. if this == nil {
  48. return ""
  49. }
  50. return this.object.A_meta_keywords
  51. }
  52. func (this *Page) MetaDescription() string {
  53. if this == nil {
  54. return ""
  55. }
  56. return this.object.A_meta_description
  57. }
  58. func (this *Page) DateTimeUnix() int {
  59. if this == nil {
  60. return 0
  61. }
  62. return this.object.A_datetime
  63. }
  64. func (this *Page) DateTimeFormat(format string) string {
  65. if this == nil {
  66. return ""
  67. }
  68. return time.Unix(int64(this.object.A_datetime), 0).Format(format)
  69. }
  70. func (this *Page) Active() bool {
  71. if this == nil {
  72. return false
  73. }
  74. return this.object.A_active > 0
  75. }