models

package
v0.0.0-...-948c845 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2014 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Copyright 2014 Jiang Le

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	UsernameRegex = `^[\p{Han}a-zA-Z0-9]+$`
)

Variables

This section is empty.

Functions

func Follows

func Follows() orm.QuerySeter

func Users

func Users() orm.QuerySeter

Types

type Category

type Category struct {
	Id                  int
	ParentCategory      *Category `orm:"null;rel(fk);on_delete(set_null);index"`
	Depth               int       `orm:"index"`
	Sort                int       `orm:"index"`
	UrlCode             string    `orm:"size(30)";unique`
	Name                string    `orm:"size(50)"`
	Description         string    `orm:"type(text)"`
	Rules               string    `orm:"type(text)"`
	TopicCount          int       `orm:"index"`
	CommentCount        int       `orm:"index"`
	IsReadOnly          bool      `orm:"index"`
	IsModOnly           bool      `orm:"index"`
	IsHidden            bool      `orm:"index"`
	LastReplyUsername   string    `orm:"size(30)"`
	LastReplyComment    *Comment  `orm:"rel(fk)"`
	LastReplyTopicTitle string    `orm:"size(255)"`
	LastReplyAt         time.Time `orm:""`
}

话题分类

func (*Category) Delete

func (m *Category) Delete() error

func (*Category) Insert

func (m *Category) Insert() error

func (*Category) Read

func (m *Category) Read(fields ...string) error

func (*Category) TableEngine

func (m *Category) TableEngine() string

func (*Category) Update

func (m *Category) Update(fields ...string) error

type Comment

type Comment struct {
	Id         int
	Topic      *Topic    `orm:"rel(fk);index"`
	ContentHex string    `orm:"size(24)"`
	Content    *Content  `orm:"-"`
	User       *User     `orm:"rel(fk);index"`
	Username   string    `orm:"size(30)`
	Ip         string    `orm:"size(39)"`
	Created    time.Time `orm:"auto_now_add";index`
	Updated    time.Time `orm:"auto_now"`
}

留言/回帖

func (*Comment) Delete

func (m *Comment) Delete() error

func (*Comment) Insert

func (m *Comment) Insert() error

func (*Comment) Read

func (m *Comment) Read(fields ...string) error

func (*Comment) SyncContent

func (m *Comment) SyncContent() error

func (*Comment) TableEngine

func (m *Comment) TableEngine() string

func (*Comment) Update

func (m *Comment) Update(fields ...string) error

type Content

type Content struct {
	Id        bson.ObjectId `bson:"_id,omitempty"`
	TopicId   int
	CommentId int
	Message   string
}

func (*Content) Delete

func (m *Content) Delete() error

func (*Content) Insert

func (m *Content) Insert() (string, error)

func (*Content) Read

func (m *Content) Read() error

func (*Content) Session

func (m *Content) Session() *mgo.Session

func (*Content) Update

func (m *Content) Update() error

type Follow

type Follow struct {
	Id             int
	User           *User  `orm:"rel(fk)"`
	Username       string `orm:"size(30)`
	FollowUser     *User  `orm:"rel(fk)"`
	FollowUsername string `orm:"size(30)`
	Mutual         bool
	Created        time.Time `orm:"auto_now_add;index"`
}

func (*Follow) Delete

func (m *Follow) Delete() error

func (*Follow) Insert

func (m *Follow) Insert() error

func (*Follow) Read

func (m *Follow) Read(fields ...string) error

func (*Follow) TableEngine

func (m *Follow) TableEngine() string

func (*Follow) TableUnique

func (*Follow) TableUnique() [][]string

func (*Follow) Update

func (m *Follow) Update(fields ...string) error

type Topic

type Topic struct {
	Id                int
	Title             string    `orm:"size(255)"`
	ContentHex        string    `orm:"size(24)"` //mongodb对象编号
	Content           *Content  `orm:"-"`
	User              *User     `orm:"rel(fk);index"`
	Username          string    `orm:"size(30)`
	Category          *Category `orm:"rel(fk);index"`
	PvCount           int       `orm:"index"`
	CommentCount      int       `orm:"index"`
	BookmarkCount     int       `orm:"index"`
	IsExcellent       bool      `orm:"index"`
	IsClosed          bool      `orm:""`
	LastReplyUsername string    `orm:"size(30)`
	LastReplyAt       time.Time `orm:""`
	Created           time.Time `orm:"auto_now_add"`
	Updated           time.Time `orm:"auto_now"`
	Ip                string    `orm:"size(39)"`
}

话题/帖子

func (*Topic) Delete

func (m *Topic) Delete() error

func (*Topic) Insert

func (m *Topic) Insert() error

func (*Topic) Read

func (m *Topic) Read(fields ...string) error

func (*Topic) TableEngine

func (m *Topic) TableEngine() string

func (*Topic) Update

func (m *Topic) Update(fields ...string) error

type User

type User struct {
	Id              int
	Username        string `orm:"size(30);unique"`
	Nickname        string `orm:"size(30)"`
	Password        string `orm:"size(128)"`
	Url             string `orm:"size(100)"`
	Company         string `orm:"size(30)"`
	Location        string `orm:"size(30)"`
	Email           string `orm:"size(80);unique"`
	Avatar          string `orm:"size(32)"`
	Info            string ``
	Weibo           string `orm:"size(30)"`
	WeChat          string `orm:"size(20)"`
	Qq              string `orm:"size(20)"`
	PublicEmail     bool   ``
	Followers       int    ``
	Following       int    ``
	FavTopics       int    ``
	Topics          int
	Comments        int
	Reputation      int
	Credits         int
	ExcellentTopics int
	IsAdmin         bool      `orm:"index"`
	IsActive        bool      `orm:"index"`
	IsBanned        bool      `orm:"index"`
	Salt            string    `orm:"size(6)"`
	Created         time.Time `orm:"auto_now_add;index"`
	Updated         time.Time `orm:"auto_now"`
}

func (*User) AvatarUrl

func (m *User) AvatarUrl() (url string)

func (*User) ConsumeActivateCode

func (m *User) ConsumeActivateCode(code string) error

使用激活码

func (*User) Delete

func (m *User) Delete() error

func (*User) Follow

func (u *User) Follow(who *User) (err error)

func (*User) FollowerUsers

func (m *User) FollowerUsers() orm.QuerySeter

func (*User) FollowingUsers

func (m *User) FollowingUsers() orm.QuerySeter

func (*User) GenerateActivateCode

func (m *User) GenerateActivateCode() (code string, err error)

func (*User) Insert

func (m *User) Insert() error

func (*User) LargeAvatarUrl

func (m *User) LargeAvatarUrl() (url string)

func (*User) LatestComments

func (m *User) LatestComments(count int) []*Comment

func (*User) LatestTopics

func (m *User) LatestTopics(count int) []*Topic

func (*User) Read

func (m *User) Read(fields ...string) error

func (*User) SetPassword

func (m *User) SetPassword(password string) error

func (*User) TableEngine

func (u *User) TableEngine() string

func (*User) TestActivateCode

func (m *User) TestActivateCode(code string) bool

测试激活码 测试完后不会删除

func (*User) UnFollow

func (u *User) UnFollow(who *User) (err error)

func (*User) Update

func (m *User) Update(fields ...string) error

func (*User) ValidUsername

func (m *User) ValidUsername() (err error)

func (*User) ValidateAndSetAvatar

func (m *User) ValidateAndSetAvatar(avatarFile io.Reader, filename string) error

func (*User) ValidateUrl

func (m *User) ValidateUrl() (err error)

func (*User) VerifyActivateCode

func (m *User) VerifyActivateCode(code string) bool

验证激活码 如果验证通过User对象会变成激活码对应的User

func (*User) VerifyPassword

func (m *User) VerifyPassword(password string) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL