123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- package fetdata
- import (
- "html/template"
- "time"
- "golang-fave/engine/utils"
- "golang-fave/engine/wrapper"
- )
- type BlogPost struct {
- wrap *wrapper.Wrapper
- object *utils.MySql_blog_post
- user *User
- category *BlogCategory
- }
- func (this *BlogPost) load() *BlogPost {
- return this
- }
- func (this *BlogPost) Id() int {
- if this == nil {
- return 0
- }
- return this.object.A_id
- }
- func (this *BlogPost) User() *User {
- if this == nil {
- return nil
- }
- if this.user != nil {
- return this.user
- }
- this.user = (&User{wrap: this.wrap}).load()
- this.user.loadById(this.object.A_user)
- return this.user
- }
- func (this *BlogPost) Name() string {
- if this == nil {
- return ""
- }
- return this.object.A_name
- }
- func (this *BlogPost) Alias() string {
- if this == nil {
- return ""
- }
- return this.object.A_alias
- }
- func (this *BlogPost) Category() *BlogCategory {
- if this == nil {
- return nil
- }
- if this.category != nil {
- return this.category
- }
- this.category = (&BlogCategory{wrap: this.wrap}).load(nil)
- this.category.loadById(this.object.A_category)
- return this.category
- }
- func (this *BlogPost) Briefly() template.HTML {
- if this == nil {
- return template.HTML("")
- }
- return template.HTML(this.object.A_briefly)
- }
- func (this *BlogPost) Content() template.HTML {
- if this == nil {
- return template.HTML("")
- }
- return template.HTML(this.object.A_content)
- }
- func (this *BlogPost) DateTimeUnix() int {
- if this == nil {
- return 0
- }
- return this.object.A_datetime
- }
- func (this *BlogPost) DateTimeFormat(format string) string {
- if this == nil {
- return ""
- }
- return time.Unix(int64(this.object.A_datetime), 0).Format(format)
- }
- func (this *BlogPost) Active() bool {
- if this == nil {
- return false
- }
- return this.object.A_active > 0
- }
- func (this *BlogPost) Permalink() string {
- if this == nil {
- return ""
- }
- return "/blog/" + this.object.A_alias + "/"
- }
|