本文整理汇总了Golang中github.com/astaxie/beego/orm.NewCondition函数的典型用法代码示例。如果您正苦于以下问题:Golang NewCondition函数的具体用法?Golang NewCondition怎么用?Golang NewCondition使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewCondition函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: QueryMineTeams
func QueryMineTeams(query string, uid int64) (orm.QuerySeter, error) {
qs := orm.NewOrm().QueryTable(new(Team))
condMine := orm.NewCondition()
condMine = condMine.Or("Creator", uid)
tids, err := Tids(uid)
if err != nil {
return qs, err
}
if len(tids) > 0 {
condMine = condMine.Or("Id__in", tids)
}
condResult := orm.NewCondition().AndCond(condMine)
if query != "" {
condQuery := orm.NewCondition()
condQuery = condQuery.And("Name__icontains", query)
condResult = condResult.AndCond(condQuery)
}
qs = qs.SetCond(condResult)
return qs, nil
}
开发者ID:Liuyanglong,项目名称:uic,代码行数:26,代码来源:team.go
示例2: GetAll
// @Title 获取日志列表
// @Description 获取日志列表
// @Param level query int false "日志级别"
// @Param type query int false "日志类型"
// @Param by query string false "记录产生者"
// @Param on_begin query string false "日志记录起始时间"
// @Param on_end query string false "日志记录终止时间"
// @Param pageIndex query int false "页码, 默认1"
// @Param pageSize query int false "每页显示条数, 默认30"
// @Success 200 {object} models.Log
// @Failure 400 请求的参数不正确
// @router / [get]
func (this *LogController) GetAll() {
cond := orm.NewCondition()
if level, _ := this.GetInt64("level", -1); level != -1 {
cond = cond.And("Level", level)
}
if typi, _ := this.GetInt64("type", -1); typi != -1 {
cond = cond.And("Type", typi)
}
if by := this.GetString("by"); by != "" {
cond = cond.And("LogBy", by)
}
if on_begin := this.GetString("on_begin"); on_begin != "" {
cond = cond.And("LogOn__gt", on_begin)
}
if on_end := this.GetString("on_end"); on_end != "" {
cond = cond.And("LogOn__lt", on_end)
}
pageIndex, _ := this.GetInt("pageIndex", 1)
pageSize, _ := this.GetInt("pageSize", 30)
logs, total, err := models.GetAllLogs(cond, pageIndex, pageSize)
if err != nil {
this.ResponseErrorJSON(400, errorFormat(ErrorBadRequest_400, err.Error()))
}
this.Data["json"] = map[string]interface{}{
"code": 0,
"data": logs,
"total": total,
}
this.ServeJson()
}
开发者ID:endville,项目名称:gpsapi,代码行数:42,代码来源:log.go
示例3: UpdateResourcePools
func UpdateResourcePools(resourcesPools []ResourcesPools) ([]ResourcesPools, error) {
qs := orm.NewOrm().QueryTable(new(ResourcesPools))
cond := orm.NewCondition()
cond1 := cond.And("id__isnull", false)
qs.SetCond(cond1).Delete()
insert, _ := qs.PrepareInsert()
for index, values := range resourcesPools {
id, err := insert.Insert(&values)
if err != nil {
beego.Error("Insert ResourcePools error :%s", err)
} else {
values.Id = id
resourcesPools[index] = values
}
}
insert.Close()
return resourcesPools, nil
}
开发者ID:alex8023,项目名称:citycloud.cf-deploy-ui,代码行数:25,代码来源:cloudfoundry.go
示例4: QueryRoles
func QueryRoles(query string) orm.QuerySeter {
qs := orm.NewOrm().QueryTable(new(Role))
if query != "" {
qs = qs.SetCond(orm.NewCondition().Or("Name__icontains", query))
}
return qs
}
开发者ID:yubo,项目名称:falcon,代码行数:7,代码来源:m_role.go
示例5: Search
func (this *TbOption) Search(key string, columns map[string]string, offset, limit int) []Tb {
tbs := make([]Tb, 0)
cond := orm.NewCondition()
if len(columns) > 0 {
condColumn := orm.NewCondition()
for column, columnVal := range columns {
condColumn = condColumn.And(fmt.Sprintf("%s__icontains", column), columnVal)
}
cond = cond.AndCond(condColumn)
}
if len(key) > 0 {
cond = cond.AndCond(cond.Or("title__icontains", key).Or("desc__icontains", key).Or("why__icontains", key).Or("fix__icontains", key))
}
this.Orm.QueryTable("Tb").SetCond(cond).OrderBy("-id").Offset(offset).Limit(limit).All(&tbs)
return tbs
}
开发者ID:tangseng,项目名称:gtt,代码行数:16,代码来源:tb.go
示例6: CanRegistered
func (this *UserService) CanRegistered(userName string, email string) (canName bool, canEmail bool, err error) {
cond := orm.NewCondition()
cond = cond.Or("Username", userName).Or("email", email)
var maps []orm.Params
var n int64
n, err = this.Queryable().SetCond(cond).Values(&maps, "Username", "email")
if err != nil {
return false, false, err
}
canName = true
canEmail = true
if n > 0 {
for _, m := range maps {
if canName && orm.ToStr(m["Username"]) == userName {
canName = false
}
if canEmail && orm.ToStr(m["Email"]) == email {
canEmail = false
}
}
}
return canName, canEmail, nil
}
开发者ID:thanzen,项目名称:identity,代码行数:26,代码来源:userservice.go
示例7: Get
func (this *OptionController) Get() {
this.CheckAvaliable("选项设置")
this.TplNames = "manage/basic/option.tpl"
this.LayoutSections["LayoutFooter"] = "manage/basic/option_script.tpl"
cond := orm.NewCondition()
if section := this.GetString(":section"); section != "" {
cond = cond.And("section", section)
}
var optionSections []models.OptionSection = make([]models.OptionSection, 0)
var optionList []models.Option
if _, err := models.Orm.QueryTable("option").SetCond(cond).All(&optionList); err == nil {
for _, option := range optionList {
if !putOptionToSection(option, &optionSections) {
var new_section models.OptionSection
new_section.Options = make([]models.Option, 1)
new_section.SectionName = option.SectionName
new_section.Options[0] = option
if len(optionSections) > 0 {
optionSections[len(optionSections)-1].HasNext = true
}
optionSections = append(optionSections, new_section)
}
}
} else {
beego.Error(err.Error())
}
this.Data["OptionSections"] = &optionSections
}
开发者ID:xiongpf,项目名称:Jeremiah,代码行数:31,代码来源:option.go
示例8: GetAll
// @Title 获取警告列表
// @Description 获取警告列表
// @Param tid query int false "终端ID"
// @Param uid query int false "用户ID"
// @Param gid query int false "车队ID"
// @Param time_begin query string false "警告记录起始时间"
// @Param time_end query string false "警告记录终止时间"
// @Param pageIndex query int false "页码, 默认1"
// @Param pageSize query int false "每页显示条数, 默认30"
// @Success 200 {object} models.Warning
// @Failure 400 请求的参数不正确
// @router / [get]
func (this *WarningController) GetAll() {
cond := orm.NewCondition()
if tid, _ := this.GetInt64("tid", -1); tid != -1 {
cond = cond.And("TerminalId", tid)
}
if uid, _ := this.GetInt64("uid", -1); uid != -1 {
cond = cond.And("UserId", uid)
}
if gid, _ := this.GetInt64("gid", -1); gid != -1 {
cond = cond.And("GroupId", gid)
}
if on_begin := this.GetString("time_begin"); on_begin != "" {
cond = cond.And("CreateOn__gt", on_begin)
}
if on_end := this.GetString("time_end"); on_end != "" {
cond = cond.And("CreateOn__lt", on_end)
}
pageIndex, _ := this.GetInt("pageIndex", 1)
pageSize, _ := this.GetInt("pageSize", 30)
warnings, total, err := models.GetAllWarnings(cond, pageIndex, pageSize)
if err != nil {
this.ResponseErrorJSON(400, errorFormat(ErrorBadRequest_400, err.Error()))
}
this.Data["json"] = map[string]interface{}{
"code": 0,
"data": warnings,
"total": total,
}
this.ServeJson()
}
开发者ID:endville,项目名称:gpsapi,代码行数:42,代码来源:warning.go
示例9: CanRegistered
func CanRegistered(userName string, email string) (bool, bool, error) {
cond := orm.NewCondition()
cond = cond.Or("UserName", userName).Or("Email", email)
var maps []orm.Params
o := orm.NewOrm()
n, err := o.QueryTable("user").SetCond(cond).Values(&maps, "UserName", "Email")
if err != nil {
return false, false, err
}
e1 := true
e2 := true
if n > 0 {
for _, m := range maps {
if e1 && orm.ToStr(m["UserName"]) == userName {
e1 = false
}
if e2 && orm.ToStr(m["Email"]) == email {
e2 = false
}
}
}
return e1, e2, nil
}
开发者ID:codeshredder,项目名称:infoboard,代码行数:27,代码来源:user.go
示例10: ParseQuery
func (this *Base) ParseQuery(fields ...string) *orm.Condition {
cond := orm.NewCondition()
for _, v := range fields {
entity := this.GetString("q" + v)
if len(entity) != 0 {
switch entity[0] {
case '*':
{
cond = cond.And(v+"__icontains", entity[1:])
}
case '?':
{
cond = cond.Or(v+"__icontains", entity[1:])
}
case '!':
{
cond = cond.AndNot(v+"__icontains", entity[1:])
}
case '~':
{
cond = cond.OrNot(v+"__icontains", entity[1:])
}
}
}
}
return cond
}
开发者ID:doomsplayer,项目名称:helper,代码行数:29,代码来源:parse.go
示例11: GetMessageList
// @router /api/manage/weixin/message/getMessageList [post]
func (this *MessageController) GetMessageList() {
this.CheckAvaliable("消息查看")
lastID, _ := this.GetInt("lastID")
size, _ := this.GetInt("size")
if size == 0 {
size = 25
}
cond := orm.NewCondition()
if lastID > 0 {
cond = cond.And("Id__lt", lastID)
}
var messageList []models.Message
if _, err := models.Orm.QueryTable("message").SetCond(cond).OrderBy("-Id").Limit(size).All(&messageList); err == nil {
var messageExList []models.MessageEx = make([]models.MessageEx, len(messageList))
for i, v := range messageList {
var user models.FollowUser
user.UserId = v.UserId
models.Orm.Read(&user, "UserId")
messageExList[i] = models.MessageEx{Message: v, User: user}
messageExList[i].CreateOnFmt = v.CreateOn.Format("2006-01-02 15:04:05")
}
this.Data["json"] = &messageExList
} else {
beego.Error(err.Error())
}
this.ServeJson()
}
开发者ID:xiongpf,项目名称:Jeremiah,代码行数:31,代码来源:message.go
示例12: QueryUsers
func QueryUsers(query string) orm.QuerySeter {
qs := orm.NewOrm().QueryTable(new(User))
if query != "" {
cond := orm.NewCondition()
cond = cond.Or("Name__icontains", query).Or("Email__icontains", query)
qs = qs.SetCond(cond)
}
return qs
}
开发者ID:LianjiaTech,项目名称:UIC,代码行数:9,代码来源:user.go
示例13: ReadInMonth
func (this *PlanOption) ReadInMonth(startTime, endTime int64) []Plan {
plans := make([]Plan, 0)
cond := orm.NewCondition()
condS := cond.And("startTime__gt", startTime).And("startTime__lt", endTime)
condE := cond.And("endTime__gt", startTime).And("endTime__lt", endTime)
condR := cond.And("realTime__gt", startTime).And("realTime__lt", endTime)
this.Orm.QueryTable("plan").SetCond(cond.AndCond(condS).OrCond(condE).OrCond(condR)).All(&plans)
return plans
}
开发者ID:tangseng,项目名称:gtt,代码行数:9,代码来源:plan.go
示例14: GetList
func (pl *ProjectList) GetList(filter map[string]interface{}) (projects []*models.Project, err error) {
qs := models.GetDB().QueryTable("projects").RelatedSel("BussinessUser", "Progress", "ArtUser", "TechUser", "Registrant").OrderBy("-created").Filter("del_status", 0)
for k, v := range filter {
if !isKeyFitForFilter(k) {
continue
}
if k == "start_date" {
start, _ := time.Parse(timeFormat, v.(string))
qs = qs.Filter("started__gte", start)
continue
}
if k == "end_date" {
end, _ := time.Parse(timeFormat, v.(string))
qs = qs.Filter("started__lte", end)
continue
}
qs = qs.Filter(k, v)
}
if filter["user"] != nil {
cond := orm.NewCondition()
cond1 := cond.And("tech_user_id", filter["user"]).Or("art_user_id", filter["user"]).Or("registrant", filter["user"]).Or("bussiness_user_id", filter["user"])
qs = qs.SetCond(cond1)
}
count, err := qs.Count()
if err != nil {
return nil, err
}
pl.count = count
if filter["limit"] != nil {
qs = qs.Limit(filter["limit"].(int))
}
if filter["offset"] != nil {
qs = qs.Offset(filter["offset"].(int))
}
_, err = qs.All(&pl.projectList)
if err != nil {
return nil, err
}
//
err = setProjectListJobsNum(pl.projectList)
if err != nil {
return nil, err
}
return pl.projectList, nil
}
开发者ID:zbzzbd,项目名称:beego,代码行数:56,代码来源:project_list.go
示例15: GetQuestionsCount
//-----------------------------------------------------------------------------
func GetQuestionsCount(offset int, limit int, path string) (int64, error) {
if path == "unanswered" {
cond1 := orm.NewCondition().And("ReplyCount", 0).Or("Ctype", Unanswered)
total, err := Questions().SetCond(cond1).Limit(limit, offset).Count()
return total, err
} else {
total, err := Questions().Limit(limit, offset).Count()
return total, err
}
}
开发者ID:wcreate,项目名称:lawoto,代码行数:11,代码来源:question.go
示例16: GenerateCondition
func GenerateCondition(options SearchOptions) *orm.Condition {
cond := orm.NewCondition()
if len(options) > 0 {
for key, val := range options {
cond = cond.And(key, val)
}
} else {
cond = cond.And("1", 1)
}
return cond
}
开发者ID:thanzen,项目名称:identity,代码行数:11,代码来源:base.go
示例17: GetQuestions
//-----------------------------------------------------------------------------
func GetQuestions(offset int, limit int, path string) (*[]Question, error) {
var tps []Question
if path == "unanswered" {
cond1 := orm.NewCondition().And("ReplyCount", 0).Or("Ctype", Unanswered)
_, err := Questions().SetCond(cond1).Limit(limit, offset).OrderBy("-Id").All(&tps)
return &tps, err
} else {
_, err := Questions().Limit(limit, offset).OrderBy("-" + path).All(&tps)
return &tps, err
}
}
开发者ID:wcreate,项目名称:lawoto,代码行数:12,代码来源:question.go
示例18: GetUser
func GetUser(email, passwd string) ([]User, error) {
o := orm.NewOrm()
var users []User
var cond *orm.Condition
cond = orm.NewCondition()
cond = cond.And("email", email)
cond = cond.And("passwd", passwd)
var qs orm.QuerySeter
qs = o.QueryTable("user").SetCond(cond)
_, err := qs.All(&users)
return users, err
}
开发者ID:dishytianxiang,项目名称:just-some-go-note,代码行数:14,代码来源:models.go
示例19: GetTerminals
// @Title 获取车队的终端设备列表
// @Description 获取车队的终端设备列表
// @Param id path int true 车队唯一ID号
// @Success 200 {object} models.Terminal
// @Failure 400 请求的参数不正确
// @router /:id/terminal [get]
func (this *GroupController) GetTerminals() {
id, _ := this.GetInt64(":id")
cond := orm.NewCondition().And("group__id", id)
list, total, err := models.GetAllTerminals(cond, 1, 1000)
if err != nil {
this.ResponseErrorJSON(400, errorFormat(ErrorBadRequest_400, err.Error()))
}
this.Data["json"] = map[string]interface{}{
"code": 0,
"data": list,
"total": total,
}
this.ServeJson()
}
开发者ID:endville,项目名称:gpsapi,代码行数:20,代码来源:group.go
示例20: queryData
// 根据条件查询数据
func queryData(param *StatFilter) []*modelp.TaxRecordRef {
// 结果集
var taxs []*modelp.TaxRecordRef
// orm.Debug = true
o := orm.NewOrm()
// 设置要查询的表
qs := o.QueryTable("tax_record_ref")
// 自定义条件
cond := orm.NewCondition()
// 判断参数
if param.OrgIndus != "" {
cond = cond.And("org_industry__contains", param.OrgIndus)
}
if param.OrgBusScope != "" {
cond = cond.And("org_bus_scope__contains", param.OrgBusScope)
}
if param.StatTaxSumStart >= 0 {
cond = cond.And("stat_tax_sum__gte", param.StatTaxSumStart)
}
if param.StatTaxSumEnd > 0 {
cond = cond.And("stat_tax_sum__lte", param.StatTaxSumEnd)
}
if param.OrgIsExport {
cond = cond.And("org_is_export__contains", "是")
}
if param.IsImportant {
cond = cond.And("is_important__contains", "Y")
}
// 设置有效记录
cond = cond.And("status", 0)
// if param.RowLimit > 0 {
// qs = qs.Limit(param.RowLimit)
// }
qs = qs.SetCond(cond)
// 查询
qs.All(&taxs)
// fmt.Printf("%+v", taxs)
go setRowsInvalid(taxs)
// 返回
return taxs
}
开发者ID:LaughingVzr,项目名称:taxrecrd,代码行数:51,代码来源:mainfrm.go
注:本文中的github.com/astaxie/beego/orm.NewCondition函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论