models

package
v0.0.0-...-64798ab Latest Latest
Warning

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

Go to latest
Published: May 29, 2014 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBBS

func AddBBS(bbs *BBS) (rows int64, err error)

func AddKind

func AddKind(kinds *BBSKinds) (rows int64, err error)

func AddRes

func AddRes(res *Response) (rows int64, err error)

func AddUser

func AddUser(u *User) (int64, error)

///////////crud///////////////////// resiter system user

func DelById

func DelById(id int64) (int64, error)

func DeletUserById

func DeletUserById(id int64) (status int64, err error)

delete from users

func FindUserByUserName

func FindUserByUserName(userName string) bool

find user by name

func GetBBSCount

func GetBBSCount() (int64, error)

func GetBBSCountById

func GetBBSCountById(id int64) int64

func GetBBSCountByUser

func GetBBSCountByUser(id int64) (int64, error)

func GetKindsCount

func GetKindsCount() (int64, error)

func GetResCount

func GetResCount(id int64) (count int64)

func GetUserCount

func GetUserCount() int64

func GetUserList

func GetUserList(offset int, page_size int64, sort string) (users []orm.Params, count int64)

query from database of user list

func GetUserResCount

func GetUserResCount(id int64) (count int64)

func Orm

func Orm() orm.Ormer

func ToInt64

func ToInt64(value interface{}) (d int64, err error)

Types

type BBS

type BBS struct {
	BBSId      int64     `orm:"auto;column(id)" form:"-"`
	BBSTitle   string    `orm:"column(bbsTitle)" form:"bbsName"`
	BBSContent string    `orm:"column(bbsContent)" form:"content"`
	BBSKind    *BBSKinds `orm:"rel(fk);column(bbsKind)" form:"-"`
	AddTime    time.Time `orm:"auto_now_add;type(datetime);column(addTime)" form:"-"`
	AddAuthor  *User     `orm:"rel(fk);column(addAuthor)" form:"-"`
}

func BBSList

func BBSList() ([]*BBS, error)

func BBSListOffset

func BBSListOffset(offset int, page_size int64, sort string) ([]*BBS, error)

func GetBBSById

func GetBBSById(id int64) (bbs BBS, err error)

func GetBBSByKind

func GetBBSByKind(kind int64) ([]*BBS, error)

func GetBBSByKindOffset

func GetBBSByKindOffset(kind int64, offset int, page_size int64) ([]*BBS, error)

func GetBBSByUserId

func GetBBSByUserId(id int64) ([]*BBS, error)

func GetBBSByUserIdOffset

func GetBBSByUserIdOffset(id int64, offset int, page_size int64) ([]*BBS, int64, error)

func (*BBS) TableName

func (this *BBS) TableName() string

func (*BBS) Valid

func (this *BBS) Valid(v *validation.Validation)

type BBSKinds

type BBSKinds struct {
	KindId    int64     `orm:"auto;column(id)" form:"-"`
	KindName  string    `orm:"column(kindName)" valid:"MinSize(2);MaxSize(18)" form:"kindName"`
	Kindintro string    `orm:"column(kindintro)" form:"kindIntro"`
	PicPath   string    `orm:"column(picPath)" form="-"`
	AddTime   time.Time `orm:"auto_now_add;type(datetime);column(addTime)" form="-"`
	AddAuthor string    `orm:"column(addAuthor)" form="-"`
}

func GetKindsList

func GetKindsList() ([]*BBSKinds, error)

func GetKindsListOffset

func GetKindsListOffset(offset int, page_size int64) ([]*BBSKinds, error)

func (*BBSKinds) TableName

func (this *BBSKinds) TableName() string

func (BBSKinds) Valid

func (this BBSKinds) Valid(v *validation.Validation)

type Paginator

type Paginator struct {
	Request     *http.Request
	PerPageNums int
	MaxPages    int
	// contains filtered or unexported fields
}

func NewPaginator

func NewPaginator(req *http.Request, per int, nums interface{}) *Paginator

func (*Paginator) HasNext

func (p *Paginator) HasNext() bool

func (*Paginator) HasPages

func (p *Paginator) HasPages() bool

func (*Paginator) HasPrev

func (p *Paginator) HasPrev() bool

func (*Paginator) IsActive

func (p *Paginator) IsActive(page int) bool

func (*Paginator) Nums

func (p *Paginator) Nums() int64

func (*Paginator) Offset

func (p *Paginator) Offset() int

func (*Paginator) Page

func (p *Paginator) Page() int
func (p *Paginator) PageLink(page int) string

func (*Paginator) PageLinkFirst

func (p *Paginator) PageLinkFirst() (link string)

func (*Paginator) PageLinkLast

func (p *Paginator) PageLinkLast() (link string)

func (*Paginator) PageLinkNext

func (p *Paginator) PageLinkNext() (link string)

func (*Paginator) PageLinkPrev

func (p *Paginator) PageLinkPrev() (link string)

func (*Paginator) PageNums

func (p *Paginator) PageNums() int

func (*Paginator) Pages

func (p *Paginator) Pages() []int

func (*Paginator) SetNums

func (p *Paginator) SetNums(nums interface{})

type Response

type Response struct {
	ResId     int64     `orm:"auto;column(id)" form:"-"`
	BBSId     *BBS      `orm:"rel(fk);column(bbsId)" form:"-"`
	Content   string    `orm:"column(content)" form:"content" valid:"Required;MinSize(1)"`
	AddTime   time.Time `orm:"auto_now_add;type(datetime);column(addTime)" form:"-"`
	AddAuthor *User     `orm:"rel(fk);column(addAuthor)" form:"-"`
}

func GetResByBBSId

func GetResByBBSId(id int64) ([]*Response, int64, error)

func GetResByUserId

func GetResByUserId(id int64, offset int, page_size int64) ([]*Response, error)

func (*Response) TableName

func (this *Response) TableName() string

func (Response) Valid

func (this Response) Valid(v *validation.Validation)

type User

type User struct {
	UserId     int64     `orm:"auto;column(id)"`
	UserName   string    `orm:"column(userName)" form:"userName" valid:"Required;MaxSize(20);MinSize(6)`
	Password   string    `orm:"column(password)" form:"password" valid:"Required;MaxSize(20);MinSize(6)"`
	RePassword string    `orm:"-" form:"passRepeat" valid:"Required"`
	Sex        string    `orm:"column(sex)" form:"sex" valid:"Required"`
	Email      string    `orm:"column(email)" form:"email" valid:"Email"`
	RegTime    time.Time `orm:"auto_now_add;type(datetime);column(regTime)"`
	UserType   string    `orm:"column(userType)"`
	PicUrl     string    `orm:"column(picUrl)"`
}

user struct

func FindUserById

func FindUserById(userId int64) (user User)

func ValidateUser

func ValidateUser(userName string, pwd string) (user User)

func (*User) TableName

func (u *User) TableName() string

Implements TableName. return table bame.

Jump to

Keyboard shortcuts

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