本文整理汇总了Golang中github.com/coocood/qbs.Qbs.WhereEqual方法的典型用法代码示例。如果您正苦于以下问题:Golang Qbs.WhereEqual方法的具体用法?Golang Qbs.WhereEqual怎么用?Golang Qbs.WhereEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coocood/qbs.Qbs
的用法示例。
在下文中一共展示了Qbs.WhereEqual方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: updateImportInfo
func updateImportInfo(q *qbs.Qbs, path string, pid int, add bool) {
// Save package information.
info := new(PkgInfo)
err := q.WhereEqual("path", path).Find(info)
if err == nil {
// Check if pid exists in this project.
i := strings.Index(info.ImportPid, "$"+strconv.Itoa(pid)+"|")
switch {
case i == -1 && add: // Add operation and does not contain.
info.ImportPid += "$" + strconv.Itoa(pid) + "|"
info.ImportedNum++
_, err = q.Save(info)
if err != nil {
beego.Error("models.updateImportInfo(): add:", path, err)
}
case i > -1 && !add: // Delete operation and contains.
info.ImportPid = strings.Replace(info.ImportPid, "$"+strconv.Itoa(pid)+"|", "", 1)
info.ImportedNum--
_, err = q.Save(info)
if err != nil {
beego.Error("models.updateImportInfo(): delete:", path, err)
}
}
}
// Error means this project does not exist, simply skip.
}
示例2: GetEpisodes
//分页查询
func GetEpisodes(q *qbs.Qbs, page int, column string, value interface{}, order string, url string) ([]*Episode, *Pagination) {
page -= 1
if page < 0 {
page = 0
}
var episode []*Episode
var rows int64
if column == "" {
fmt.Println(ItemsPerPage)
fmt.Println(page)
rows = q.Count("episode")
err := q.OrderByDesc(order).
Limit(ItemsPerPage).Offset(page * ItemsPerPage).FindAll(&episode)
if err != nil {
fmt.Println(err)
}
} else {
rows = q.WhereEqual(column, value).Count("episode")
err := q.WhereEqual(column, value).OrderByDesc(order).
Limit(ItemsPerPage).Offset(page * ItemsPerPage).FindAll(&episode)
if err != nil {
fmt.Println(err)
}
}
fmt.Println(episode)
url = url[:strings.Index(url, "=")+1]
pagination := NewPagination(page, int(rows), url)
return episode, pagination
}
示例3: UpdateMultipleUsers
func UpdateMultipleUsers(q *qbs.Qbs) (affected int64, err error) {
type User struct {
Name string
}
user := new(User)
user.Name = "Blue"
return q.WhereEqual("name", "Green").Update(user)
}
示例4: getPkgInfoWithQ
func getPkgInfoWithQ(path, tag string, q *qbs.Qbs) (*hv.PkgInfo, error) {
// Check path length to reduce connect times.
if len(path) == 0 {
return nil, errors.New("models.getPkgInfoWithQ -> Empty path as not found.")
}
pinfo := new(hv.PkgInfo)
q.WhereEqual("import_path", path).Find(pinfo)
proPath := utils.GetProjectPath(path)
if utils.IsGoRepoPath(path) {
proPath = "code.google.com/p/go"
}
beego.Trace("models.getPkgInfoWithQ -> proPath:", proPath)
ptag := new(PkgTag)
cond := qbs.NewCondition("path = ?", proPath).And("tag = ?", tag)
err := q.Condition(cond).Find(ptag)
if err != nil {
pinfo.Ptag = "ptag"
return pinfo, errors.New(
fmt.Sprintf("models.getPkgInfoWithQ( %s:%s ) -> 'PkgTag': %s", path, tag, err))
}
pinfo.Vcs = ptag.Vcs
pinfo.Tags = ptag.Tags
// Only 'PkgInfo' cannot prove that package exists,
// we have to check 'PkgDecl' as well in case it was deleted by mistake.
pdecl := new(PkgDecl)
cond = qbs.NewCondition("pid = ?", pinfo.Id).And("tag = ?", tag)
err = q.Condition(cond).Find(pdecl)
if err != nil {
// Basically, error means not found, so we set 'pinfo.PkgVer' to 0
// because server uses it to decide whether force update.
pinfo.PkgVer = 0
pinfo.Ptag = "ptag"
return pinfo, errors.New(
fmt.Sprintf("models.getPkgInfoWithQ( %s:%s ) -> 'PkgDecl': %s", path, tag, err))
}
docPath := path + utils.TagSuffix("-", tag)
if !com.IsExist("." + utils.DocsJsPath + docPath + ".js") {
pinfo.PkgVer = 0
pinfo.Ptag = "ptag"
return pinfo, errors.New(
fmt.Sprintf("models.getPkgInfoWithQ( %s:%s ) -> JS: File not found", path, tag))
}
return pinfo, nil
}
示例5: getGroupPkgInfoWithQ
func getGroupPkgInfoWithQ(q *qbs.Qbs, paths []string) []*hv.PkgInfo {
pinfos := make([]*hv.PkgInfo, 0, len(paths))
for _, v := range paths {
if len(v) > 0 {
pinfo := new(hv.PkgInfo)
err := q.WhereEqual("import_path", v).Find(pinfo)
if err == nil {
pinfos = append(pinfos, pinfo)
} else {
pinfos = append(pinfos, &hv.PkgInfo{ImportPath: v})
}
}
}
return pinfos
}
示例6: getGroupPkgInfoByIdWithQ
func getGroupPkgInfoByIdWithQ(q *qbs.Qbs, pids []string) []*hv.PkgInfo {
pinfos := make([]*hv.PkgInfo, 0, len(pids))
for _, v := range pids {
pid, _ := strconv.ParseInt(v, 10, 64)
if pid > 0 {
pinfo := new(hv.PkgInfo)
err := q.WhereEqual("id", pid).Find(pinfo)
if err == nil {
pinfos = append(pinfos, pinfo)
} else {
beego.Trace("models.GetGroupPkgInfoById ->", err)
}
}
}
return pinfos
}
示例7: calRefRanks
func calRefRanks(q *qbs.Qbs, refPids []string) int64 {
refRank := 0
for _, spid := range refPids {
pid, _ := strconv.Atoi(spid)
if pid == 0 {
continue
}
info := new(hv.PkgInfo)
err := q.WhereEqual("id", pid).Find(info)
if err == nil {
refRank += int(info.Rank) * 10 / 100
} else {
beego.Trace("models.calRefRanks ->", err)
}
}
return int64(refRank)
}
示例8: FindUserByName
func FindUserByName(q *qbs.Qbs, n string) (*User, error) {
user := new(User)
err := q.WhereEqual("name", n).Find(user)
return user, err
}
示例9: findPersonByUserId
/*
* 通过用户编号获得人员信息
* @param userId 用户编号
* @return person
*/
func (p *Person) findPersonByUserId(userId string, q *qbs.Qbs) *Person {
person := new(Person)
q.WhereEqual("user_id", userId).Find(person)
return person
}
示例10: FindUserByCode
//查询验证码是否存在
func FindUserByCode(q *qbs.Qbs, code string) *models.User {
user := new(models.User)
q.WhereEqual("validate_code", code).Find(user)
return user
}
示例11: FindUserById
func FindUserById(q *qbs.Qbs, id int64) *models.User {
user := new(models.User)
q.WhereEqual("id", id).Find(user)
return user
}
示例12: HasEmail
func (u *User) HasEmail(q *qbs.Qbs) bool {
user := new(User)
q.WhereEqual("email", u.Email).Find(user)
return user.Id > 0
}
示例13: updateImportInfo
func updateImportInfo(q *qbs.Qbs, path string, pid, rank int, add bool) {
spid := strconv.Itoa(pid)
// Save package information.
info := new(hv.PkgInfo)
err := q.WhereEqual("import_path", path).Find(info)
if err == nil {
// Check if pid exists in this project.
refPids := strings.Split(info.RefPids, "|")
i := getRefIndex(refPids, spid)
if add {
// Add operation.
if i == -1 {
refPids = append(refPids, spid)
i = len(refPids) - 1
}
info.RefPids = strings.Join(refPids, "|")
info.RefNum = len(refPids)
if info.RefNum > 0 && strings.HasPrefix(info.RefPids, "|") {
info.RefPids = info.RefPids[1:]
info.RefNum--
}
_, err = q.Save(info)
if err != nil {
beego.Error("models.updateImportInfo -> add:", path, err)
}
} else if i > -1 {
// Delete operation
refPids = append(refPids[:i], refPids[i+1:]...)
info.RefPids = strings.Join(refPids, "|")
info.RefNum = len(refPids)
if info.RefNum > 0 && strings.HasPrefix(info.RefPids, "|") {
info.RefPids = info.RefPids[1:]
info.RefNum--
}
_, err = q.Save(info)
if err != nil {
beego.Error("models.updateImportInfo -> delete:", path, err)
}
}
return
}
if add {
// Record imports.
pimp := new(PkgImport)
q.WhereEqual("path", path).Find(pimp)
pimp.Path = path
pimps := strings.Split(pimp.Imports, "|")
i := getRefIndex(pimps, spid)
if i == -1 {
pimps = append(pimps, spid)
pimp.Imports = strings.Join(pimps, "|")
_, err = q.Save(pimp)
if err != nil {
beego.Error("models.updateImportInfo -> record import:", path, err)
}
}
}
}
示例14: FindNaById
func FindNaById(q *qbs.Qbs, id int64) (*Topic, error) {
na := new(Topic)
//na.Id = id
err := q.WhereEqual("id", id).Find(na)
return na, err
}