model

package
v0.0.0-...-c5e6d41 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2014 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Engine *xorm.Engine
)

Functions

func AddAnswer

func AddAnswer(qid int64, uid int64, ctype int64, content string, author string, author_signature string, email string, website string) (int64, error)

func AddCategory

func AddCategory(title string, content string) (int64, error)

func AddImage

func AddImage(path string, pid int64, ctype int64, uid int64) (int64, error)

func AddNode

func AddNode(title string, content string, cid int64, uid int64) (int64, error)

func AddReply

func AddReply(tid int64, uid int64, ctype int64, content string, author string, author_signature string, email string, website string) (int64, error)

func AddTimeline

func AddTimeline(title string, content string, cid int64, nid int64, uid int64, author string, author_signature string) (int64, error)

func AddTopic

func AddTopic(title string, content string, cid int64, nid int64, uid int64) (int64, error)

func AddUser

func AddUser(email string, username string, nickname string, realname string, password string, role int64) (int64, error)

func AtLinksPostImagesOnTopic

func AtLinksPostImagesOnTopic(content string) (int64, string, error)

最终发布到topic

func ConDb

func ConDb() (*xorm.Engine, error)

func CreatTables

func CreatTables() error

func DelAnswer

func DelAnswer(aid int64, uid int64, role int64) error

func DelImageByLocation

func DelImageByLocation(location string) error

func DelImageByMid

func DelImageByMid(mid int64) error

func DelQuestion

func DelQuestion(id int64, uid int64, role int64) error

func DelReply

func DelReply(rid int64) error

func DelReplysByPid

func DelReplysByPid(pid int64) error

func DelTimeline

func DelTimeline(lid int64) error

func DelTopic

func DelTopic(id int64, uid int64, role int64) error

func GetAScoresByPid

func GetAScoresByPid(pid int64) int64

func GetAllReply

func GetAllReply() (allr *[]Reply)

func GetAnswersByPid

func GetAnswersByPid(id int64, ctype int64, offset int, limit int, path string) *[]Reply

func GetCategoryCountByPid

func GetCategoryCountByPid(pid int64) int64

func GetImagesByCtype

func GetImagesByCtype(ctype int64) (*[]Image, error)

func GetImagesByCtypeWidthCid

func GetImagesByCtypeWidthCid(ctype int64, cid int64) (*[]Image, error)

func GetImagesByCtypeWidthNid

func GetImagesByCtypeWidthNid(ctype int64, nid int64) (*[]Image, error)

func GetImagesByCtypeWithUid

func GetImagesByCtypeWithUid(ctype int64, uid int64) (*[]Image, error)

func GetImagesByCtypeWithUidAndTid

func GetImagesByCtypeWithUidAndTid(ctype int64, uid int64, tid int64) (*[]Image, error)

func GetImagesByHotnessFingerprint

func GetImagesByHotnessFingerprint(usrlimit int, imagelimit int) []*[]Image

func GetImagesByUidAndTid

func GetImagesByUidAndTid(uid int64, tid int64) (*[]Image, error)

func GetImagesOnViewsHotnessFingerprintByUid

func GetImagesOnViewsHotnessFingerprintByUid(uid int64) (*[]Image, error)

func GetImagesOnViewsHotnessFingerprintByUidExcludeCid

func GetImagesOnViewsHotnessFingerprintByUidExcludeCid(uid int64, cid int64) (*[]Image, error)

func GetNodeCountByPid

func GetNodeCountByPid(cid int64) int64

func GetNodes

func GetNodes(offset int, limit int, path string) (*[]Node, error)

func GetQuestions

func GetQuestions(offset int, limit int, path string) (*[]Question, error)

func GetQuestionsByCid

func GetQuestionsByCid(cid int64, offset int, limit int, ctype int64, path string) *[]Question

func GetQuestionsCount

func GetQuestionsCount(offset int, limit int, path string) (int64, error)

func GetReplyCountByPid

func GetReplyCountByPid(tid int64) int64

func GetReplysByPid

func GetReplysByPid(id int64, ctype int64, offset int, limit int, path string) *[]Reply

func GetTimelines

func GetTimelines(offset int, limit int, path string, uid int64) (*[]Timeline, error)

func GetTopicCountByNid

func GetTopicCountByNid(nid int64) int64

func GetTopics

func GetTopics(offset int, limit int, path string) (*[]Topic, error)

func GetTopicsByCategory

func GetTopicsByCategory(category string, offset int, limit int, ctype int64, path string) *[]Topic

func GetTopicsByCategoryCount

func GetTopicsByCategoryCount(category string, offset int, limit int, path string) (int64, error)

func GetTopicsByCid

func GetTopicsByCid(cid int64, offset int, limit int, ctype int64, path string) *[]Topic

大数据下会出现极其严重的性能问题 亟待改善

func GetTopicsByHotnessCategory

func GetTopicsByHotnessCategory(catlimit int, topiclimit int) []*[]Topic

func GetTopicsByHotnessNodes

func GetTopicsByHotnessNodes(nodelimit int, topiclimit int) []*[]Topic

func GetTopicsByNid

func GetTopicsByNid(nodeid int64, offset int, limit int, ctype int64, path string) *[]Topic

func GetTopicsByNode

func GetTopicsByNode(node string, offset int, limit int, path string) (*[]Topic, error)

func GetTopicsByScoreNodes

func GetTopicsByScoreNodes(nodelimit int, topiclimit int) []*[]Topic

func GetTopicsByUid

func GetTopicsByUid(uid int64, offset int, limit int, ctype int64, path string) *[]Topic

func GetTopicsCount

func GetTopicsCount(offset int, limit int, path string) (int64, error)

func GetUsersOnHotness

func GetUsersOnHotness(offset int, limit int, path string) (*[]User, error)

func IsAnswerMark

func IsAnswerMark(uid int64, aid int64) bool

func IsQuestionMark

func IsQuestionMark(uid int64, qid int64) bool

func PostImage

func PostImage(img *Image) (int64, error)

func PostTopic

func PostTopic(tp *Topic) (int64, error)

func PutAnswer

func PutAnswer(aid int64, ans *Reply) (int64, error)

func PutCategory

func PutCategory(cid int64, cat *Category) (int64, error)

func PutImage

func PutImage(mid int64, img *Image) (int64, error)

func PutNode

func PutNode(nid int64, nd *Node) (int64, error)

func PutQuestion

func PutQuestion(qid int64, qs *Question) (int64, error)

func PutReply

func PutReply(rid int64, rp *Reply) (int64, error)

func PutTimeline

func PutTimeline(lid int64, tl *Timeline) (int64, error)

func PutTopic

func PutTopic(tid int64, tp *Topic) (int64, error)

func PutUser

func PutUser(uid int64, usr *User) (int64, error)

func SearchCategory

func SearchCategory(content string, offset int, limit int, path string) (*[]Category, error)

func SearchNode

func SearchNode(content string, offset int, limit int, path string) (*[]Node, error)

func SearchQuestion

func SearchQuestion(content string, offset int, limit int, path string) (*[]Question, error)

func SearchTopic

func SearchTopic(content string, offset int, limit int, path string) (*[]Topic, error)

func SetAcceptAnswer

func SetAcceptAnswer(qid int64, aid int64, uid int64, role int64) error

func SetAnswerMark

func SetAnswerMark(uid int64, aid int64) (int64, error)

func SetCtypeforQuestion

func SetCtypeforQuestion(qid int64, uid int64, role int64, ctype int64) error

func SetEngine

func SetEngine() (*xorm.Engine, error)

func SetIgnoreAnswer

func SetIgnoreAnswer(qid int64, aid int64, uid int64, role int64) error

func SetImageByLocationWithUid

func SetImageByLocationWithUid(location string, uid int64, tid int64, ctype int64) error

func SetImageCtypeByLocation

func SetImageCtypeByLocation(location string, ctype int64) error

func SetImageCtypeByLocationWithUid

func SetImageCtypeByLocationWithUid(location string, uid int64, ctype int64) error

func SetImageCtypeByLocationWithUidAndTid

func SetImageCtypeByLocationWithUidAndTid(location string, uid int64, tid int64, ctype int64) error

func SetImageCtypeByMid

func SetImageCtypeByMid(mid int64, ctype int64) error

func SetQuestionMark

func SetQuestionMark(uid int64, qid int64) (int64, error)

func SetRecordforImageOnEdit

func SetRecordforImageOnEdit(tid int64, uid int64)

func SetRecordforImageOnPost

func SetRecordforImageOnPost(tid int64, uid int64)

func SetReplyContentByRid

func SetReplyContentByRid(rid int64, Content string) error

func SetReplyCountByPid

func SetReplyCountByPid(qid int64) (int64, error)

func SetTimelineContentByRid

func SetTimelineContentByRid(lid int64, Content string) error

func UpdateAnswer

func UpdateAnswer(aid int64, answermap map[string]interface{}) error

map[string]interface{}{"ctype": ctype}

func UpdateCategory

func UpdateCategory(cid int64, catmap *map[string]interface{}) error

map[string]interface{}{"ctype": ctype}

func UpdateNode

func UpdateNode(nid int64, nodemap *map[string]interface{}) error

map[string]interface{}{"ctype": ctype}

Types

type Ads

type Ads struct {
	Id                int64
	Cid               int64 `xorm:"index"`
	Nid               int64 `xorm:"index"`
	Uid               int64 `xorm:"index"`
	Order             int64
	Ctype             int64  `xorm:"index"`
	Title             string `xorm:"index"`
	Content           string `xorm:"text index"`
	Attachment        string `xorm:"text"`
	Begintime         time.Time
	Endtime           time.Time
	Created           time.Time `xorm:"created index"`
	Updated           time.Time `xorm:"updated index"`
	Hotness           float64   `xorm:"index"`
	Hotup             int64     `xorm:"index"`
	Hotdown           int64     `xorm:"index"`
	Hotscore          int64     `xorm:"index"` //Hotup  -	Hotdown
	Hotvote           int64     `xorm:"index"` //Hotup  + 	Hotdown
	Views             int64     `xorm:"index"`
	Author            string    `xorm:"index"`
	Category          string    `xorm:"index"`
	Node              string    `xorm:"index"`
	ReplyTime         time.Time
	ReplyCount        int64 `xorm:"index"`
	ReplyLastUserId   int64
	ReplyLastUsername string
	ReplyLastNickname string
}

type AnswerMark

type AnswerMark struct {
	Id  int64
	Uid int64 `xorm:"index"`
	Aid int64 `xorm:"index"`
}

type Category

type Category struct {
	Id             int64
	Pid            int64 `xorm:"index"`
	Uid            int64 `xorm:"index"`
	Order          int64
	Ctype          int64     `xorm:"index"`
	Title          string    `xorm:"index"`
	Content        string    `xorm:"text index"`
	Attachment     string    `xorm:"text"`
	Created        time.Time `xorm:"created index"`
	Updated        time.Time `xorm:"updated index"`
	Hotness        float64   `xorm:"index"`
	Hotup          int64     `xorm:"index"`
	Hotdown        int64     `xorm:"index"`
	Hotscore       int64     `xorm:"index"` //Hotup  -	Hotdown
	Hotvote        int64     `xorm:"index"` //Hotup  + 	Hotdown
	Views          int64     `xorm:"index"`
	Author         string    `xorm:"index"` //这里指本分类创建者
	NodeTime       time.Time
	NodeCount      int64 `xorm:"index"`
	NodeLastUserId int64
}

category,Pid:root

func GetCategory

func GetCategory(id int64) (*Category, error)

func GetCategorys

func GetCategorys(offset int, limit int, path string) (cate []*Category, err error)

type File

type File struct {
	Id              int64
	Uid             int64 `xorm:"index"`
	Cid             int64 `xorm:"index"`
	Nid             int64 `xorm:"index"`
	Pid             int64 `xorm:"index"`
	Order           int64
	Ctype           int64 `xorm:"index"`
	Filename        string
	Content         string `xorm:"text index"`
	Hash            string
	Location        string `xorm:"index"`
	Url             string `xorm:"index"`
	Size            int64
	Created         time.Time `xorm:"created index"`
	Updated         time.Time `xorm:"updated index"`
	Hotness         float64   `xorm:"index"`
	Hotup           int64     `xorm:"index"`
	Hotdown         int64     `xorm:"index"`
	Hotscore        int64     `xorm:"index"` //Hotup  -	Hotdown
	Hotvote         int64     `xorm:"index"` //Hotup  + 	Hotdown
	Views           int64     `xorm:"index"`
	ReplyTime       time.Time
	ReplyCount      int64 `xorm:"index"`
	ReplyLastUserId int64
}

type Image

type Image struct {
	Id              int64
	Uid             int64 `xorm:"index"`
	Cid             int64 `xorm:"index"`
	Nid             int64 `xorm:"index"`
	Pid             int64 `xorm:"index"`
	Order           int64
	Ctype           int64  `xorm:"index"`
	Fingerprint     string `xorm:"index"`
	Filename        string `xorm:"index"`
	Content         string `xorm:"text index"`
	Hash            string `xorm:"index"`
	Location        string `xorm:"index"`
	Url             string `xorm:"index"`
	Size            int64
	Width           int64
	Height          int64
	Created         time.Time `xorm:"created index"`
	Updated         time.Time `xorm:"updated index"`
	Hotness         float64   `xorm:"index"`
	Hotup           int64     `xorm:"index"`
	Hotdown         int64     `xorm:"index"`
	Hotscore        int64     `xorm:"index"` //Hotup  -	Hotdown
	Hotvote         int64     `xorm:"index"` //Hotup  + 	Hotdown
	Views           int64     `xorm:"index"`
	Author          string    `xorm:"index"`
	ReplyTime       time.Time
	ReplyCount      int64 `xorm:"index"`
	ReplyLastUserId int64
}

func GetImage

func GetImage(id int64) (*Image, error)

type Node

type Node struct {
	Id              int64
	Pid             int64 `xorm:"index"`
	Uid             int64 `xorm:"index"`
	Order           int64
	Ctype           int64     `xorm:"index"`
	Title           string    `xorm:"index"`
	Content         string    `xorm:"text index"`
	Attachment      string    `xorm:"text"`
	Created         time.Time `xorm:"created index"`
	Updated         time.Time `xorm:"updated index"`
	Hotness         float64   `xorm:"index"`
	Hotup           int64     `xorm:"index"`
	Hotdown         int64     `xorm:"index"`
	Hotscore        int64     `xorm:"index"` //Hotup  -	Hotdown
	Hotvote         int64     `xorm:"index"` //Hotup  + 	Hotdown
	Views           int64     `xorm:"index"`
	Author          string    `xorm:"index"` //节点的创建者
	TopicTime       time.Time
	TopicCount      int64 `xorm:"index"`
	TopicLastUserId int64
}

node,Pid:category

func GetNode

func GetNode(id int64) (*Node, error)

func GetNodeByTitle

func GetNodeByTitle(title string) (*Node, error)

type Question

type Question struct {
	Id                int64
	Cid               int64 `xorm:"index"`
	Nid               int64 `xorm:"index"`
	Uid               int64 `xorm:"index"`
	Order             int64
	Ctype             int64     `xorm:"index"`
	Title             string    `xorm:"index"`
	Content           string    `xorm:"text index"`
	Attachment        string    `xorm:"text index"`
	Thumbnails        string    `xorm:"index"` //Original remote file
	ThumbnailsLarge   string    `xorm:"index"` //200x300
	ThumbnailsMedium  string    `xorm:"index"` //200x150
	ThumbnailsSmall   string    `xorm:"index"` //70x70
	Tags              string    `xorm:"index"`
	Created           time.Time `xorm:"created index"`
	Updated           time.Time `xorm:"index"`
	Hotness           float64   `xorm:"index"`
	Hotup             int64     `xorm:"index"`
	Hotdown           int64     `xorm:"index"`
	Hotscore          int64     `xorm:"index"` //Hotup  -	Hotdown
	Hotvote           int64     `xorm:"index"` //Hotup  + 	Hotdown
	Views             int64     `xorm:"index"`
	Author            string    `xorm:"index"`
	Category          string    `xorm:"index"`
	Node              string    `xorm:"index"`
	ReplyTime         time.Time
	ReplyCount        int64 `xorm:"index"`
	ReplyHotscore     int64 `xorm:"index"` //Hotup  -	Hotdown
	ReplyLastUserId   int64
	ReplyLastUsername string
	ReplyLastNickname string
	FavoriteCount     int64 `xorm:"index"`
}

由于cid nid uid都可以是topic的上级所以默认不设置pid字段,这里默认Pid是nid

func GetQuestion

func GetQuestion(id int64) (*Question, error)

func PostQuestion

func PostQuestion(qs *Question) (*Question, int64, error)

type QuestionMark

type QuestionMark struct {
	Id  int64
	Uid int64 `xorm:"index"`
	Qid int64 `xorm:"index"`
}

type Reply

type Reply struct {
	Id                int64
	Uid               int64 `xorm:"index"`
	Pid               int64 `xorm:"index"` //Topic id
	Order             int64
	Ctype             int64     `xorm:"index"`
	Content           string    `xorm:"text index"`
	Attachment        string    `xorm:"text"`
	Created           time.Time `xorm:"created index"`
	Updated           time.Time `xorm:"index"`
	Hotness           float64   `xorm:"index"`
	Hotup             int64     `xorm:"index"`
	Hotdown           int64     `xorm:"index"`
	Hotscore          int64     `xorm:"index"` //Hotup  -	Hotdown
	Hotvote           int64     `xorm:"index"` //Hotup  + Hotdown
	Views             int64     `xorm:"index"`
	Author            string    `xorm:"index"`
	AuthorSignature   string    `xorm:"index"`
	Email             string    `xorm:"index"`
	Website           string    `xorm:"index"`
	ReplyTime         time.Time
	ReplyCount        int64 `xorm:"index"`
	ReplyLastUserId   int64
	ReplyLastUsername string
	ReplyLastNickname string
}

reply,Pid:topic

func GetAnswer

func GetAnswer(id int64) (*Reply, error)

func GetReply

func GetReply(rid int64) (reply *Reply)

type Timeline

type Timeline struct {
	Id                int64
	Cid               int64 `xorm:"index"`
	Nid               int64 `xorm:"index"`
	Uid               int64 `xorm:"index"`
	Order             int64
	Ctype             int64     `xorm:"index"`
	Title             string    `xorm:"index"`
	Content           string    `xorm:"text index"`
	Attachment        string    `xorm:"text index"`
	Created           time.Time `xorm:"created index"`
	Updated           time.Time `xorm:"updated index"`
	Hotness           float64   `xorm:"index"`
	Hotup             int64     `xorm:"index"`
	Hotdown           int64     `xorm:"index"`
	Hotscore          int64     `xorm:"index"` //Hotup  -	Hotdown
	Hotvote           int64     `xorm:"index"` //Hotup  + 	Hotdown
	Views             int64     `xorm:"index"`
	Author            string    `xorm:"index"`
	AuthorSignature   string    `xorm:"index"`
	Category          string    `xorm:"index"`
	Node              string    `xorm:"index"`
	ReplyTime         time.Time
	ReplyCount        int64 `xorm:"index"`
	ReplyLastUserId   int64
	ReplyLastUsername string
	ReplyLastNickname string
}

func GetTimeline

func GetTimeline(lid int64) (*Timeline, error)

type Topic

type Topic struct {
	Id                int64
	Cid               int64 `xorm:"index"`
	Nid               int64 `xorm:"index"`
	Uid               int64 `xorm:"index"`
	Order             int64
	Ctype             int64     `xorm:"index"`
	Title             string    `xorm:"index"`
	Content           string    `xorm:"text index"`
	Attachment        string    `xorm:"text index"`
	Thumbnails        string    `xorm:"index"` //Original remote file
	ThumbnailsLarge   string    `xorm:"index"` //200x300
	ThumbnailsMedium  string    `xorm:"index"` //200x150
	ThumbnailsSmall   string    `xorm:"index"` //70x70
	Tags              string    `xorm:"index"`
	Created           time.Time `xorm:"created index"`
	Updated           time.Time `xorm:"index"`
	Hotness           float64   `xorm:"index"`
	Hotup             int64     `xorm:"index"`
	Hotdown           int64     `xorm:"index"`
	Hotscore          int64     `xorm:"index"` //Hotup  -	Hotdown
	Hotvote           int64     `xorm:"index"` //Hotup  + 	Hotdown
	Views             int64     `xorm:"index"`
	Author            string    `xorm:"index"`
	Category          string    `xorm:"index"`
	Node              string    `xorm:"index"`
	ReplyTime         time.Time
	ReplyCount        int64 `xorm:"index"`
	ReplyLastUserId   int64
	ReplyLastUsername string
	ReplyLastNickname string
}

由于cid nid uid都可以是topic的上级所以默认不设置pid字段,这里默认Pid是nid

func GetTopic

func GetTopic(id int64) (*Topic, error)

func GetTopicsByCidOnBetween

func GetTopicsByCidOnBetween(cid int64, startid int64, endid int64, offset int, limit int, ctype int64, path string) (tps []*Topic)

type User

type User struct {
	Id            int64
	Pid           int64  //用在归属地 归属学校 归属组织 等方面
	Email         string `xorm:"index"`
	Password      string `xorm:"index"`
	Username      string `xorm:"index"`
	Nickname      string `xorm:"index"`
	Realname      string `xorm:"index"`
	Content       string `xorm:"text index"`
	Avatar        string
	AvatarLarge   string
	AvatarMedium  string
	AvatarSmall   string
	Birth         time.Time
	Province      string
	City          string
	Company       string
	Address       string
	Postcode      string
	Mobile        string
	Website       string
	Sex           int64
	Qq            string
	Msn           string
	Weibo         string
	Ctype         int64     `xorm:"index"`
	Role          int64     `xorm:"index"`
	Created       time.Time `xorm:"created index"`
	Updated       time.Time `xorm:"updated index"`
	Hotness       float64   `xorm:"index"`
	Hotup         int64     `xorm:"index"`
	Hotdown       int64     `xorm:"index"`
	Hotscore      int64     `xorm:"index"` //Hotup  -	Hotdown
	Hotvote       int64     `xorm:"index"` //Hotup  + 	Hotdown
	Views         int64     `xorm:"index"`
	LastLoginTime time.Time
	LastLoginIp   string
	LoginCount    int64 `xorm:"index"`
}

func GetUser

func GetUser(id int64) (*User, error)

func GetUserByEmail

func GetUserByEmail(email string) (*User, error)

返回值尽量返回指针 不然会出现诡异的问题

func GetUserByNickname

func GetUserByNickname(nickname string) (*User, error)

func GetUserByRole

func GetUserByRole(role int64) (*User, error)

func GetUserByUsername

func GetUserByUsername(username string) (*User, error)

Jump to

Keyboard shortcuts

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