• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang orm.ColValue函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/astaxie/beego/orm.ColValue函数的典型用法代码示例。如果您正苦于以下问题:Golang ColValue函数的具体用法?Golang ColValue怎么用?Golang ColValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ColValue函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: IncreasePullCount

// IncreasePullCount ...
func IncreasePullCount(name string) (err error) {
	o := GetOrmer()
	num, err := o.QueryTable("repository").Filter("name", name).Update(
		orm.Params{
			"pull_count":  orm.ColValue(orm.ColAdd, 1),
			"update_time": time.Now(),
		})
	if num == 0 {
		err = fmt.Errorf("Failed to increase repository pull count with name: %s %s", name, err.Error())
	}
	return err
}
开发者ID:vmware,项目名称:harbor,代码行数:13,代码来源:repository.go


示例2: PutCollect

func (self *NovelCollectModel) PutCollect(novelid int) (map[string]interface{}, error) {
	o := orm.NewOrm()
	_, err := o.QueryTable("novel").Filter("id", novelid).Update(orm.Params{
		"novelcollect": orm.ColValue(orm.ColAdd, 1),
	})
	if err != nil {
		return nil, err
	}
	ret := map[string]interface{}{
		"novelid": novelid,
	}
	return ret, nil
}
开发者ID:aosen,项目名称:novel,代码行数:13,代码来源:collectmodel.go


示例3: Delete

func (m *Post) Delete() error {
	if m.Tags != "" {
		o := orm.NewOrm()
		oldtags := strings.Split(strings.Trim(m.Tags, ","), ",")
		//标签统计-1
		o.QueryTable(&Tag{}).Filter("name__in", oldtags).Update(orm.Params{"count": orm.ColValue(orm.Col_Minus, 1)})
		//删掉tag_post表的记录
		o.QueryTable(&TagPost{}).Filter("postid", m.Id).Delete()
	}
	if _, err := orm.NewOrm().Delete(m); err != nil {
		return err
	}
	return nil
}
开发者ID:ShinichR,项目名称:myBlog,代码行数:14,代码来源:post.go


示例4: GetArticleById

//根据id获取文章 todo 点击量模型未构建 返回改文章对应的标签
func GetArticleById(id interface{}) (Article, error) {
	article := Article{}
	o := orm.NewOrm()
	err := o.QueryTable("article").Filter("Id", id).RelatedSel().One(&article)

	if err == nil {
		o.QueryTable("article").Filter("Id", id).Update(orm.Params{
			"Views": orm.ColValue(orm.Col_Add, 1),
		})
		//查询该文章对应的标签
		//		var tags []*Tag
		//		_, err = o.QueryTable("tag").Filter("Articles__Article__Id", id).All(&tags)
		//		article.Tags = tags
	}

	return article, err
}
开发者ID:elvizlai,项目名称:Blog-mysql,代码行数:18,代码来源:method.go


示例5: PostBrowsersAdd

func PostBrowsersAdd(uid int, ip string, post *models.Post) {
	var key string
	if uid == 0 {
		key = ip
	} else {
		key = utils.ToStr(uid)
	}
	key = fmt.Sprintf("PCA.%d.%s", post.Id, key)
	if setting.Cache.Get(key) != nil {
		return
	}
	_, err := models.Posts().Filter("Id", post.Id).Update(orm.Params{
		"Browsers": orm.ColValue(orm.Col_Add, 1),
	})
	if err != nil {
		beego.Error("PostCounterAdd ", err)
	}
	setting.Cache.Put(key, true, 60)
}
开发者ID:varding,项目名称:wetalk,代码行数:19,代码来源:util.go


示例6: AddComment

func (this *CommentModel) AddComment(comment *Comment) (int64, error) {
	o := ORM()
	o.Begin()
	comment_id, err := o.Insert(comment)
	if err == nil {
		// adding comment count of the post
		_, err := o.QueryTable(TABLE_NAME_POST).Filter("PostId", comment.Post.PostId).Update(orm.Params{
			"CommentCount": orm.ColValue(orm.ColAdd, 1),
		})
		if err != nil {
			// error adding count
			o.Rollback()
		} else {
			o.Commit()
		}
	} else {
		// error adding comment
		o.Rollback()
	}
	return comment_id, err
}
开发者ID:migege,项目名称:milog,代码行数:21,代码来源:comment.go


示例7: UpdateBet

func UpdateBet(uId int, uName string, uAvtar string, horseId int, money int) int {
	configure := new(Configure)
	configure = GetStatus()
	if configure.CValue != "1" {
		return -1100
	}

	o := orm.NewOrm()
	var bet Bet
	bet.Uid = uId

	err := o.Read(&bet, "Uid")
	if err == orm.ErrNoRows {
		bet.Uname = uName
		bet.Uavtar = uAvtar
		bet.Horseid = horseId
		bet.Money = money

		_, err = o.Insert(&bet)
		if err != nil {
			beego.Error(err)
			return -1
		}
	} else if err == nil {
		bet.Money = money
		_, err = o.QueryTable("bet").Filter("Uid", uId).Update(orm.Params{
			"money": orm.ColValue(orm.Col_Add, money),
		})
		if err != nil {
			beego.Error(err)
			return -2
		}
	} else {
		beego.Error(err)
		return -3
	}
	return 1
}
开发者ID:nihaozzb,项目名称:horse_race,代码行数:38,代码来源:models.go


示例8: Save

//保存
func (this *ArticleController) Save() {
	var (
		id      int64  = 0
		title   string = strings.TrimSpace(this.GetString("title"))
		content string = this.GetString("content")
		tags    string = strings.TrimSpace(this.GetString("tags"))
		urlname string = strings.TrimSpace(this.GetString("urlname"))
		color   string = strings.TrimSpace(this.GetString("color"))
		cover   string = strings.TrimSpace(this.GetString("cover"))
		timestr string = strings.TrimSpace(this.GetString("posttime"))
		status  int64  = 0
		istop   int8   = 0
		urltype int8   = 0
		post    models.Post
	)

	if title == "" {
		this.showmsg("标题不能为空!")
	}

	id, _ = this.GetInt64("id")
	status, _ = this.GetInt64("status")

	if this.GetString("istop") == "1" {
		istop = 1
	}
	if this.GetString("urltype") == "1" {
		urltype = 1
	}
	if status != 1 && status != 2 {
		status = 0
	}
	if cover == "" {
		cover = "/static/upload/defaultcover.png"
	}
	addtags := make([]string, 0)
	//标签过滤
	if tags != "" {
		tagarr := strings.Split(tags, ",")
		for _, v := range tagarr {
			if tag := strings.TrimSpace(v); tag != "" {
				exists := false
				for _, vv := range addtags {
					if vv == tag {
						exists = true
						break
					}
				}
				if !exists {
					addtags = append(addtags, tag)
				}
			}
		}
	}

	if id < 1 {
		post.Userid = this.userid
		post.Author = this.username
		post.Posttime = this.getTime()
		post.Updated = this.getTime()
		post.Insert()
		models.Cache.Delete("latestblog")
	} else {
		post.Id = id
		if post.Read() != nil {
			goto RD
		}
		if post.Tags != "" {
			var tagobj models.Tag
			var tagpostobj models.TagPost
			oldtags := strings.Split(strings.Trim(post.Tags, ","), ",")
			//标签统计-1
			tagobj.Query().Filter("name__in", oldtags).Update(orm.Params{"count": orm.ColValue(orm.ColMinus, 1)})
			//删掉tag_post表的记录
			tagpostobj.Query().Filter("postid", post.Id).Delete()
		}
	}

	if len(addtags) > 0 {
		for _, v := range addtags {
			tag := models.Tag{Name: v}
			if tag.Read("Name") == orm.ErrNoRows {
				tag.Count = 1
				tag.Insert()
			} else {
				tag.Count += 1
				tag.Update("Count")
			}
			tp := models.TagPost{Tagid: tag.Id, Postid: post.Id, Poststatus: int8(status), Posttime: this.getTime()}
			tp.Insert()
		}
		post.Tags = "," + strings.Join(addtags, ",") + ","
	}
	if posttime, err := time.Parse("2006-01-02 15:04:05", timestr); err == nil {
		post.Posttime = posttime
	} else {
		post.Posttime, _ = time.Parse("2006-01-02 15:04:05", post.Posttime.Format("2006-01-02 15:04:05"))
	}
	post.Status = int8(status)
//.........这里部分代码省略.........
开发者ID:gusa1120,项目名称:beego_sample,代码行数:101,代码来源:article.go


示例9: AddPV

func AddPV(id interface{}) {
	o := orm.NewOrm()
	o.QueryTable("Topic").Filter("Id", id).Update(orm.Params{"PV": orm.ColValue(orm.Col_Add, 1)})
}
开发者ID:elvizlai,项目名称:Blog,代码行数:4,代码来源:method.go


示例10: UpdateUserCourseHour

func UpdateUserCourseHour(uid int64, count int) error {
	o := orm.NewOrm()
	_, err := o.QueryTable("user").Filter("id", uid).Update(orm.Params{
		"coursehour": orm.ColValue(orm.ColAdd, count)})
	return err
}
开发者ID:SHP00001,项目名称:selectcourse,代码行数:6,代码来源:user.go


示例11: BuildApi

func (this *ProjectEnvironmentController) BuildApi() {

	//projectenvid := this.Input().Get("projectenvid")
	envid := this.Input().Get("envid")
	intenvid, _ := strconv.Atoi(envid)

	rundeckbuildjobid := this.Input().Get("rundeckbuildjobid")
	//rundeckpackagejobid := this.Input().Get("rundeckpackagejobid")
	projectid := this.Input().Get("projectid")
	branchname := this.Input().Get("branchname")

	o := orm.NewOrm()

	//添加版本号数据以及更新项目版本号
	var project models.Projectinfo

	o.QueryTable("Projectinfo").Filter("Id", projectid).Update(orm.Params{
		"BuildNumber": orm.ColValue(orm.Col_Add, 1),
	})

	o.QueryTable("Projectinfo").Filter("Id", projectid).One(&project)

	now := time.Now()

	fmt.Println(now)

	var pb models.Projectbuild
	pb.Projectid = project.Id
	pb.Buildnumber = project.Buildnumber
	pb.Branchname = branchname
	pb.Created = now
	pb.Buildstatus = 1
	pb.Envid = intenvid
	id, _ := o.Insert(&pb)

	//获取项目环境信息进行编译部署
	var env models.Environmentinfo
	o.QueryTable("Environmentinfo").Filter("id", envid).One(&env)

	args := map[string]string{"BUILD_NUMBER": strconv.Itoa(project.Buildnumber), "Branch_NAME": branchname, "Repository_Path": project.Repositorypath}

	response := utility.RundeckRunJob(env.Rundeckapiurl, env.Rundeckapiauthtoken, rundeckbuildjobid, args)
	fmt.Println(response)

	//parse rundeck api xml response
	r := models.RunJobExecutions{}
	xml_err := xml.Unmarshal([]byte(response), &r)

	if xml_err != nil {
		fmt.Printf("error: %v", xml_err)
		this.Data["json"] = xml_err //url.QueryEscape(logs[0].Packagepath)
		this.ServeJson()
	}

	if r.Exs != nil {
		o.QueryTable("Projectbuild").Filter("Id", id).Update(orm.Params{
			"BuildStatus": 2,
			"ExecutionId": r.Exs[0].Id,
		})
		fmt.Println(r.Exs[0].Id)
	}
	//rundeck执行完成之后读取git hash
	dat, _ := ioutil.ReadFile("/Volumes/ftproot/mtime/upversion/MtimeGoConfigWeb/2/config-web/GitBranchHash")
	//check(err)
	fmt.Print(string(dat))

	o.QueryTable("Projectbuild").Filter("Id", id).Update(orm.Params{
		"BranchHash": string(dat),
	})

	//fmt.Println(response)

	//fmt.Println(projectenvid)
	//fmt.Println(envid)
	//fmt.Println(rundeckbuildjobid)
	//fmt.Println(rundeckpackagejobid)
	//fmt.Println(projectid)
	//fmt.Println(branchname)

	this.Data["json"] = models.BuildApiModel{models.JsonResultBaseStruct{Result: true, Message: "操作成功"}, r.Exs[0].Id}
	this.ServeJson()
}
开发者ID:beerbubble,项目名称:MtimeCI,代码行数:82,代码来源:projectenvironment.go


示例12: UpdateCourseSelected

func UpdateCourseSelected(cid int64, count int) error {
	o := orm.NewOrm()
	_, err := o.QueryTable("course").Filter("id", cid).Update(orm.Params{
		"selected": orm.ColValue(orm.ColAdd, count)})
	return err
}
开发者ID:SHP00001,项目名称:selectcourse,代码行数:6,代码来源:coursestatus.go


示例13: UpdateRaceRuselt

func UpdateRaceRuselt(WinnerId int) int {
	configure := new(Configure)
	configure = GetStatus()
	if configure.CValue != "2" {
		return -1101
	}

	o := orm.NewOrm()

	// 事务开始
	err := o.Begin()

	winNum, err := o.QueryTable("horse").Filter("id", WinnerId).Update(orm.Params{
		"win": orm.ColValue(orm.Col_Add, 1),
	})
	if err != nil || winNum != 1 {
		beego.Error(err)
		return -1
	}

	loseNum, err := o.QueryTable("horse").Exclude("id", WinnerId).Update(orm.Params{
		"lose": orm.ColValue(orm.Col_Add, 1),
	})
	if err != nil || loseNum != 5 {
		beego.Error(err)
		return -2
	}

	if winNum == 1 && loseNum == 5 {
		err = o.Commit()
	} else {
		err = o.Rollback()
		return -3
	}

	if err != nil {
		beego.Error(err)
		return 0
	}

	// 将中奖者的记录从bet表移动到winlog表
	bets, err := GetBet(WinnerId)
	// winlogs := make([]*Winlog,0)
	if err != nil {
		beego.Error(err)
		if err != orm.ErrNoRows {
			return -5
		}
	} else {
		var winlog Winlog
		timeStr := time.Now().Format("2006-01-02 15:04:05")
		qs := o.QueryTable("winlog")
		i, _ := qs.PrepareInsert()
		for _, val := range bets {
			winlog.Uid = val.Uid
			winlog.Uname = val.Uname
			winlog.Uavtar = val.Uavtar
			winlog.Horseid = val.Horseid
			winlog.Money = val.Money
			winlog.Time = timeStr
			_, err := i.Insert(&winlog)
			if err != nil {
				beego.Error(err)
				return -4
			}
		}
		i.Close()
	}

	UpdateStatus("0")
	return 1
}
开发者ID:nihaozzb,项目名称:horse_race,代码行数:72,代码来源:models.go



注:本文中的github.com/astaxie/beego/orm.ColValue函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang orm.NewCondition函数代码示例发布时间:2022-05-24
下一篇:
Golang middleware.ShowErr函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap