增加 用户名或姓名或邮箱 搜索支持

This commit is contained in:
bjdgyc
2024-01-15 17:46:47 +08:00
parent 4a33b42726
commit 7c3ed549d0
14 changed files with 382 additions and 999 deletions

View File

@@ -38,11 +38,11 @@ func UserList(w http.ResponseWriter, r *http.Request) {
// 查询前缀匹配
if len(prefix) > 0 {
prefixFuzzy := "%" + prefix + "%"
fuzzy := "%" + prefix + "%"
where := "username LIKE ? OR nickname LIKE ? OR email LIKE ?"
count = dbdata.FindWhereCount(&dbdata.User{}, where, prefixFuzzy, prefixFuzzy, prefixFuzzy)
err = dbdata.FindWhere(&datas, pageSize, page, where, prefixFuzzy, prefixFuzzy, prefixFuzzy)
count = dbdata.FindWhereCount(&dbdata.User{}, where, fuzzy, fuzzy, fuzzy)
err = dbdata.FindWhere(&datas, pageSize, page, where, fuzzy, fuzzy, fuzzy)
} else {
count = dbdata.CountAll(&dbdata.User{})
err = dbdata.Find(&datas, pageSize, page)