本文整理汇总了Golang中specialTady/models.Tag.Count方法的典型用法代码示例。如果您正苦于以下问题:Golang Tag.Count方法的具体用法?Golang Tag.Count怎么用?Golang Tag.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类specialTady/models.Tag
的用法示例。
在下文中一共展示了Tag.Count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Delete
func (this *TagController) Delete() {
var tagId, _ = this.GetInt64("id")
var tag = models.Tag{Id: tagId}
tag.Read()
var deleteTagName = tag.Name
if deleteTagName == "未分组" {
this.StopRun()
}
tag.Delete()
o := orm.NewOrm()
o.Raw("UPDATE tbl_article SET tag = ? WHERE tag = ?", "未分组", deleteTagName).Exec()
var count int64 = 0
orm.NewOrm().Raw("SELECT COUNT(*) FROM tbl_article WHERE tag = ?", "未分组").QueryRow(&count)
noGroupTag := models.Tag{Name: "未分组"}
noGroupTag.Read("name")
noGroupTag.Count = count
noGroupTag.Update("count")
this.Redirect("/admin/tag/list", 301)
}
示例2: Save
//保存
func (this *ArticleController) Save() {
var (
id int64 = 0
title string = strings.TrimSpace(this.GetString("title"))
content string = this.GetString("content")
status int = 0
happenMonth string = strings.TrimSpace(this.GetString("happenMonth"))
happenDay string = strings.TrimSpace(this.GetString("happenDay"))
article models.Article
tag models.Tag
)
if title == "" {
this.showmsg("标题不能为空!")
}
id, _ = this.GetInt64("id")
status, _ = this.GetInt("status")
tagName := this.GetString("tag")
fmt.Println(tagName)
tag.Name = tagName
tag.Read("name")
if status != 1 {
status = 0
}
if id < 1 {
article.AuthorId = this.userid
article.AuthorName = this.username
article.Tag = tagName
err := article.Insert()
if err != nil {
fmt.Println(err)
}
tag.Count = tag.Count + 1
tag.Update()
} else {
article.Id = id
if article.Read() != nil {
goto RD
}
}
if article.Tag != tagName {
desTag := models.Tag{Name: article.Tag}
desTag.Read("name")
desTag.Count--
desTag.Update("count")
tag.Count = tag.Count + 1
tag.Update()
article.Tag = tagName
}
article.Status = status
article.Title = title
article.Content = content
article.HappenMonth = happenMonth
article.HappenDay = happenDay
article.Update("tag", "status", "title", "content", "happen_month", "happen_day")
RD:
url := "/admin/article/list?t=date&m=" + happenMonth + "&d=" + happenDay
this.Redirect(url, 302)
}