Documentation ¶
Index ¶
- Constants
- Variables
- func AddCategory(m *Category) (id int64, err error)
- func AddLabel(m *Label) (id int64, err error)
- func AddTopic(m *Topic) (id int64, err error)
- func CheckToken(token string) bool
- func DeleteCategory(id int) (err error)
- func DeleteLabel(id int) (err error)
- func DeleteTopic(id int) (err error)
- func GenToken() string
- func GetAllCategory(query map[string]string, fields []string, sortby []string, order []string, ...) (ml []interface{}, err error)
- func GetAllLabel(query map[string]string, fields []string, sortby []string, order []string, ...) (ml []interface{}, err error)
- func GetKey(key string) string
- func InitRedisPool()
- func RegisterDB()
- func SetKey(key string, value interface{})
- func UpdateCategoryById(m *Category) (err error)
- func UpdateLabelById(m *Label) (err error)
- func UpdateTopicByID(m *Topic) (err error)
- type Admin
- type Category
- type CommResult
- type Label
- type LoginResult
- type Topic
- func FastFind(vagueName string) ([]*Topic, error)
- func GetAllTopics(query map[string]string, fields []string, sortby []string, order []string, ...) ([]*Topic, error)
- func GetTopicByID(id int) (v *Topic, err error)
- func GetTopicsByCateID(cateId int) ([]*Topic, error)
- func GetTopicsByLabelID(tagId int) ([]*Topic, error)
- type TopicsResult
Constants ¶
const (
DB_DRIVER = "mysql"
)
Variables ¶
var ( // RedisPool RedisPool *redis.Pool )
Functions ¶
func AddCategory ¶
AddCategory insert a new Category into database and returns last inserted Id on success.
func DeleteCategory ¶
DeleteCategory deletes Category by Id and returns error if the record to be deleted doesn't exist
func DeleteLabel ¶
DeleteLabel deletes Label by Id and returns error if the record to be deleted doesn't exist
func DeleteTopic ¶
DeleteTopic deletes Topic by Id and returns error if the record to be deleted doesn't exist
func GetAllCategory ¶
func GetAllCategory(query map[string]string, fields []string, sortby []string, order []string, offset int64, limit int64) (ml []interface{}, err error)
GetAllCategory retrieves all Category matches certain condition. Returns empty list if no records exist
func GetAllLabel ¶
func GetAllLabel(query map[string]string, fields []string, sortby []string, order []string, offset int64, limit int64) (ml []interface{}, err error)
GetAllLabel retrieves all Label matches certain condition. Returns empty list if no records exist
func RegisterDB ¶
func RegisterDB()
func UpdateCategoryById ¶
UpdateCategory updates Category by Id and returns error if the record to be updated doesn't exist
func UpdateLabelById ¶
UpdateLabel updates Label by Id and returns error if the record to be updated doesn't exist
func UpdateTopicByID ¶
UpdateTopic updates Topic by Id and returns error if the record to be updated doesn't exist
Types ¶
type Category ¶
type Category struct { Id int `json:"id" orm:"column(id);auto"` Name string `json:"name" orm:"column(name);size(100)"` Description string `json:"desc" orm:"column(description);size(500)"` Topics []*Topic `json:"-" orm:"reverse(many)"` }
func GetCategoryById ¶
GetCategoryById retrieves Category by Id. Returns error if Id doesn't exist
type CommResult ¶
func NewCommResult ¶
func NewCommResult() *CommResult
type Label ¶
type Label struct { Id int `json:"id" orm:"column(id);auto"` Name string `json:"name" orm:"column(name);size(100)"` Description string `json:"desc" orm:"column(description);size(500)"` Topics []*Topic `json:"-" orm:"reverse(many)"` }
func GetLabelById ¶
GetLabelById retrieves Label by Id. Returns error if Id doesn't exist
type LoginResult ¶
type Topic ¶
type Topic struct { Id int `json:"id" orm:"column(id);auto"` Uid int64 `json:"uid" orm:"column(uid)"` Title string `json:"title" orm:"column(title);size(255)"` Content string `json:"content" orm:"column(content);type(text)"` Summary string `json:"summary" orm:"column(summary);size(200)"` Attachment string `json:"url" orm:"column(attachment);size(255)"` Category *Category `json:"cate" orm:"rel(fk);on_delete(do_nothing)"` Labels []*Label `json:"labels" orm:"rel(m2m)"` Created time.Time `orm:"auto_now_add;column(created);type(datetime)"` Updated time.Time `json:"-" orm:"auto_now;column(updated);type(datetime)"` Deleted time.Time `json:"-" orm:"auto_now;column(deleted);type(datetime)"` Views int64 `json:"views" orm:"column(views)"` Author string `json:"author" orm:"column(author);size(255)"` ReplyTime time.Time `json:"-" orm:"column(reply_time);type(datetime);null"` ReplyCount int64 `json:"reply_count" orm:"column(reply_count)"` ReplyLastUserId int64 `json:"reply_last_user_id" orm:"column(reply_last_user_id)"` }
topic info
func GetAllTopics ¶
func GetAllTopics(query map[string]string, fields []string, sortby []string, order []string, offset int64, limit int64) ([]*Topic, error)
GetAllTopics retrieves all Topic matches certain condition. Returns empty list if no records exist
func GetTopicByID ¶
GetTopicByID retrieves Topic by Id. Returns error if Id doesn't exist
func GetTopicsByCateID ¶
GetTopicsByCateID retrieves Topics by Category
func GetTopicsByLabelID ¶
GetTopicsByTagId retrieves Topics by Label