当前位置: 首页>>代码示例>>Golang>>正文


Golang Tag.Read方法代码示例

本文整理汇总了Golang中specialTady/models.Tag.Read方法的典型用法代码示例。如果您正苦于以下问题:Golang Tag.Read方法的具体用法?Golang Tag.Read怎么用?Golang Tag.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在specialTady/models.Tag的用法示例。


在下文中一共展示了Tag.Read方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
}
开发者ID:gezhixin,项目名称:goBlog,代码行数:22,代码来源:tag.go

示例2: Delete

//delete
func (this *ArticleController) Delete() {
	var (
		id      int64
		article models.Article
	)

	id, _ = this.GetInt64("id")
	article.Id = id

	if err := article.Read(); err == nil {
		fmt.Println(err)
	}

	article.Status = 2
	article.Update("status")

	tag := models.Tag{Name: article.Tag}
	tag.Read("Name")
	tag.Count--
	tag.Update("count")

	this.Redirect(this.Ctx.Request.Referer(), 302)
}
开发者ID:gezhixin,项目名称:goBlog,代码行数:24,代码来源:article.go

示例3: Batch

//批处理
func (this *ArticleController) Batch() {
	ids := this.GetStrings("ids[]")
	op := this.GetString("op")

	if len(ids) == 0 {
		this.Redirect(this.Ctx.Request.Referer(), 302)
		this.StopRun()
	}

	idarr := make([]int64, 0)
	for _, v := range ids {
		if id, _ := strconv.ParseInt(v, 10, 64); id > 0 {
			idarr = append(idarr, id)
		}
	}

	var post models.Article
	var articleList []*models.Article

	switch op {
	case "topub": //移到已发布
		post.Query().Filter("id__in", idarr).All(&articleList)
		for _, v := range articleList {
			if v.Status == 2 {
				tag := models.Tag{Name: v.Tag}
				tag.Read("name")
				tag.Count++
				tag.Update("count")
			}
		}
		post.Query().Filter("id__in", idarr).Update(orm.Params{"status": 0})

	case "todrafts": //移到草稿箱
		post.Query().Filter("id__in", idarr).All(&articleList)
		for _, v := range articleList {
			if v.Status == 2 {
				tag := models.Tag{Name: v.Tag}
				tag.Read("name")
				tag.Count++
				tag.Update("count")
			}
		}
		post.Query().Filter("id__in", idarr).Update(orm.Params{"status": 1})

	case "totrash": //移到回收站
		post.Query().Filter("id__in", idarr).All(&articleList)
		for _, v := range articleList {
			if v.Status != 2 {
				tag := models.Tag{Name: v.Tag}
				tag.Read("name")
				tag.Count--
				tag.Update("count")
			}
		}
		post.Query().Filter("id__in", idarr).Update(orm.Params{"status": 2})
	case "todestroy":
		post.Query().Filter("id__in", idarr).Delete()
	}

	this.Redirect(this.Ctx.Request.Referer(), 302)
}
开发者ID:gezhixin,项目名称:goBlog,代码行数:62,代码来源:article.go

示例4: 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)
}
开发者ID:gezhixin,项目名称:goBlog,代码行数:70,代码来源:article.go


注:本文中的specialTady/models.Tag.Read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。