forked from free-lancers/electricity_bill_calc_service
		
	enhance(repository):改进查询条件的生成方式。
This commit is contained in:
		
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							| @@ -10,6 +10,7 @@ require ( | ||||
| 	github.com/shopspring/decimal v1.3.1 | ||||
| 	github.com/spf13/viper v1.12.0 | ||||
| 	github.com/vmihailenco/msgpack/v5 v5.3.5 | ||||
| 	xorm.io/builder v0.3.12 | ||||
| 	xorm.io/xorm v1.3.1 | ||||
| ) | ||||
|  | ||||
| @@ -51,5 +52,4 @@ require ( | ||||
| 	gopkg.in/ini.v1 v1.66.4 // indirect | ||||
| 	gopkg.in/yaml.v2 v2.4.0 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||
| 	xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978 // indirect | ||||
| ) | ||||
|   | ||||
							
								
								
									
										3
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								go.sum
									
									
									
									
									
								
							| @@ -1039,7 +1039,8 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= | ||||
| rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= | ||||
| sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= | ||||
| sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= | ||||
| xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978 h1:bvLlAPW1ZMTWA32LuZMBEGHAUOcATZjzHcotf3SWweM= | ||||
| xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE= | ||||
| xorm.io/builder v0.3.12 h1:ASZYX7fQmy+o8UJdhlLHSW57JDOkM8DNhcAF5d0LiJM= | ||||
| xorm.io/builder v0.3.12/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE= | ||||
| xorm.io/xorm v1.3.1 h1:z5egKrDoOLqZFhMjcGF4FBHiTmE5/feQoHclfhNidfM= | ||||
| xorm.io/xorm v1.3.1/go.mod h1:9NbjqdnjX6eyjRRhh01GHm64r6N9shTb/8Ak3YRt8Nw= | ||||
|   | ||||
| @@ -4,6 +4,8 @@ import ( | ||||
| 	"electricity_bill_calc/cache" | ||||
| 	"electricity_bill_calc/global" | ||||
| 	"electricity_bill_calc/model" | ||||
|  | ||||
| 	"xorm.io/builder" | ||||
| ) | ||||
|  | ||||
| type _UserRepository struct{} | ||||
| @@ -16,7 +18,7 @@ func (_UserRepository) FindUserByUsername(username string) (*model.User, error) | ||||
| 		return cachedUser, nil | ||||
| 	} | ||||
| 	user := new(model.User) | ||||
| 	has, err := global.DBConn.Where("username=?", username).Get(user) | ||||
| 	has, err := global.DBConn.Where(builder.Eq{"username": username}).Get(user) | ||||
| 	if has { | ||||
| 		cache.CacheData(user, "user", username) | ||||
| 	} | ||||
| @@ -29,7 +31,7 @@ func (_UserRepository) RetreiveUserDetail(uid string) (*model.UserDetail, error) | ||||
| 		return cachedUser, nil | ||||
| 	} | ||||
| 	user := new(model.UserDetail) | ||||
| 	has, err := global.DBConn.Where("id=?", uid).Get(user) | ||||
| 	has, err := global.DBConn.ID(uid).Get(user) | ||||
| 	if has { | ||||
| 		cache.CacheData(user, "user_detail", uid) | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user