Skip to content

Commit

Permalink
增加大于和小于的查询
Browse files Browse the repository at this point in the history
  • Loading branch information
wzkun committed Feb 28, 2021
1 parent 298b4cd commit c164b81
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 29 deletions.
91 changes: 73 additions & 18 deletions common.v2/CommonModel.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,79 @@ func (model2 *CommonModel) WhereEqual(name string, values ...interface{}) *Commo
return model2
}

// WhereNotEqual 通用查询条件设置
func (model2 *CommonModel) WhereNotEqual(name string, values ...interface{}) *CommonModel {
values2 := make([]interface{}, len(values))
for index, v := range values {
values2[index] = v
}

model2.Imp = model2.Imp.Where(name, model.NotEqual, values2...)
return model2
}

// WhereGreaterThan 通用查询条件设置
func (model2 *CommonModel) WhereGreaterThan(name string, values ...interface{}) *CommonModel {
values2 := make([]interface{}, len(values))
for index, v := range values {
values2[index] = v
}

model2.Imp = model2.Imp.Where(name, model.GreaterThan, values2...)
return model2
}

// WhereGreaterThanOrEqual 通用查询条件设置
func (model2 *CommonModel) WhereGreaterThanOrEqual(name string, values ...interface{}) *CommonModel {
values2 := make([]interface{}, len(values))
for index, v := range values {
values2[index] = v
}

model2.Imp = model2.Imp.Where(name, model.GreaterThanOrEqual, values2...)
return model2
}

// WhereSmallerThan 通用查询条件设置
func (model2 *CommonModel) WhereSmallerThan(name string, values ...interface{}) *CommonModel {
values2 := make([]interface{}, len(values))
for index, v := range values {
values2[index] = v
}

model2.Imp = model2.Imp.Where(name, model.SmallerThan, values2...)
return model2
}

// WhereSmallerThanOrEqual 通用查询条件设置
func (model2 *CommonModel) WhereSmallerThanOrEqual(name string, values ...interface{}) *CommonModel {
values2 := make([]interface{}, len(values))
for index, v := range values {
values2[index] = v
}

model2.Imp = model2.Imp.Where(name, model.SmallerThanOrEqual, values2...)
return model2
}

// WhereLeftLike 查询条件设置
func (model2 *CommonModel) WhereLeftLike(name, value string) *CommonModel {
model2.Imp.DB = model2.GormDB().Where(fmt.Sprintf("%v like (?)", name), "%"+value)
return model2
}

// WhereRightLike 查询条件设置
func (model2 *CommonModel) WhereRightLike(name, value string) *CommonModel {
model2.Imp.DB = model2.GormDB().Where(fmt.Sprintf("%v like (?)", name), value+"%")
return model2
}

// WhereLike 查询条件设置
func (model2 *CommonModel) WhereLike(name, value string) *CommonModel {
model2.Imp.DB = model2.GormDB().Where(fmt.Sprintf("%v like (?)", name), "%"+value+"%")
return model2
}

// WherePublishRecordID 查询条件设置
func (model2 *CommonModel) WherePublishRecordID(Predicate model.Predicate, values ...string) *CommonModel {
values2 := make([]interface{}, len(values))
Expand Down Expand Up @@ -623,24 +696,6 @@ func (model2 *CommonModel) WhereTitle(Predicate model.Predicate, value string) *
return model2
}

// WhereLeftLike 查询条件设置
func (model2 *CommonModel) WhereLeftLike(name, value string) *CommonModel {
model2.Imp.DB = model2.GormDB().Where(fmt.Sprintf("%v like (?)", name), "%"+value)
return model2
}

// WhereRightLike 查询条件设置
func (model2 *CommonModel) WhereRightLike(name, value string) *CommonModel {
model2.Imp.DB = model2.GormDB().Where(fmt.Sprintf("%v like (?)", name), value+"%")
return model2
}

// WhereLike 查询条件设置
func (model2 *CommonModel) WhereLike(name, value string) *CommonModel {
model2.Imp.DB = model2.GormDB().Where(fmt.Sprintf("%v like (?)", name), "%"+value+"%")
return model2
}

// WhereProcInstID 查询条件设置
func (model2 *CommonModel) WhereProcInstID(Predicate model.Predicate, values ...string) *CommonModel {
values2 := make([]interface{}, len(values))
Expand Down
34 changes: 23 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ go 1.14

require (
code.aliyun.com/bim_backend/zoogoer v0.0.0-20200812075521-c4f16747a85b
code.aliyun.com/new_backend/scodi_nqc v0.0.0-20210114030334-97ab5af7008a
code.aliyun.com/new_backend/scodi_nqc v0.0.0-20210223091003-00abfd0ae8af
code.aliyun.com/yjkj.ink/apidoc v0.0.0-20201020094723-3602466ee351 // indirect
code.aliyun.com/yjkj.ink/grpc v1.0.2 // indirect
code.aliyun.com/yjkj.ink/grpc-gateway v0.0.0-20201027102054-874d43aed0be // indirect
code.aliyun.com/yjkj.ink/http v0.0.0-20201130100530-fc40bd278070 // indirect
code.aliyun.com/yjkj.ink/otto v0.0.0-20200916023345-342d44144870 // indirect
code.aliyun.com/yjkj.ink/proto v0.0.0-20201010090016-05b131bdc257 // indirect
code.aliyun.com/yjkj.ink/utils v0.0.0-20201216080429-7c2ceb59667a // indirect
github.com/andybalholm/brotli v1.0.1 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
Expand All @@ -13,26 +19,32 @@ require (
github.com/gomodule/redigo/redis v0.0.0-20200429221454-e14091dffc1b // indirect
github.com/jinzhu/gorm v1.9.16
github.com/json-iterator/go v1.1.10
github.com/klauspost/compress v1.11.6 // indirect
github.com/klauspost/compress v1.11.8 // indirect
github.com/magefile/mage v1.11.0 // indirect
github.com/magiconair/properties v1.8.4 // indirect
github.com/mattn/go-sqlite3 v1.14.5 // indirect
github.com/mitchellh/mapstructure v1.4.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-sqlite3 v1.14.6 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/olivere/elastic/v7 v7.0.22 // indirect
github.com/pelletier/go-toml v1.8.1 // indirect
github.com/satori/go.uuid v1.2.0
github.com/sirupsen/logrus v1.7.0
github.com/sirupsen/logrus v1.8.0
github.com/spf13/afero v1.5.1 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.7.1 // indirect
github.com/valyala/fasthttp v1.19.0
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
github.com/valyala/fasthttp v1.21.0
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a // indirect
golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78 // indirect
golang.org/x/text v0.3.4 // indirect
golang.org/x/sys v0.0.0-20210228012217-479acdf4ea46 // indirect
golang.org/x/text v0.3.5 // indirect
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705 // indirect
google.golang.org/grpc v1.36.0 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/sourcemap.v1 v1.0.5 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gorm.io/driver/mysql v1.0.3 // indirect
gorm.io/gorm v1.20.11
gorm.io/driver/mysql v1.0.4 // indirect
gorm.io/gorm v1.20.12
)

0 comments on commit c164b81

Please sign in to comment.