Skip to content

Commit 25c99cd

Browse files
authored
doc: Update README.md
1 parent a0a6a29 commit 25c99cd

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,84 @@ func main() {
125125

126126
```
127127

128+
## 搜索工具
129+
130+
只需要下面一行代码即可完成单表的所有查询功能
131+
132+
```Bash
133+
gplus.SelectList(gplus.BuildQuery[User](queryParams))
134+
```
135+
136+
137+
138+
例子:
139+
140+
```Bash
141+
func main() {
142+
http.HandleFunc("/", handleRequest)
143+
http.ListenAndServe(":8080", nil)
144+
}
145+
146+
func handleRequest(w http.ResponseWriter, r *http.Request) {
147+
queryParams := r.URL.Query()
148+
list, _ := gplus.SelectList(gplus.BuildQuery[User](queryParams))
149+
marshal, _ := json.Marshal(list)
150+
w.Write(marshal)
151+
}
152+
```
153+
154+
假设我们要查询username为zhangsan的用户
155+
156+
```Bash
157+
http://localhost:8080?q=username=zhangsan
158+
```
159+
160+
161+
162+
假设我们要查询username姓zhang的用户
163+
164+
```Bash
165+
http://localhost:8080?q=username~>=zhang
166+
```
167+
168+
169+
170+
假设我们要查询age大于20的用户
171+
172+
```Bash
173+
http://localhost:8080?q=age>20
174+
```
175+
176+
177+
178+
假设我们要查询username等于zhagnsan,password等于123456的用户
179+
180+
```Bash
181+
http://localhost:8080?q=username=zhangsan&q=password=123456
182+
```
183+
184+
185+
186+
假设我们要查询username等于zhagnsan,password等于123456的用户
187+
188+
```Bash
189+
http://localhost:8080?q=username=zhangsan&q=password=123456
190+
```
191+
192+
193+
194+
假设我们要查询username等于zhagnsan,或者usename等于lisi的用户
195+
196+
可以增加一个分组和gcond的条件查询来实现
197+
198+
```Bash
199+
http://localhost:8080?q=A.username=zhangsan&q=B.username=lisi&gcond=A|B
200+
```
201+
202+
203+
204+
所有的单表查询我们都只需要一行代码即可。
205+
128206

129207

130208
## 总结

0 commit comments

Comments
 (0)