Initial commit: web_hghl_server
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package mwacc
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"videoweb/pub/pubdef"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
func MakeSearch(keyWords string, status int64, page pubdef.Page) (searchs bson.M) {
|
||||
var search []bson.M
|
||||
if len(keyWords) > 0 {
|
||||
userId, _ := strconv.ParseInt(keyWords, 10, 64)
|
||||
search = append(search, bson.M{FN.MwAcc.Id: userId})
|
||||
search = append(search, bson.M{FN.MwAcc.UserName: bson.M{"$regex": keyWords}})
|
||||
search = append(search, bson.M{FN.MwAcc.Acc: bson.M{"$regex": keyWords}})
|
||||
search = append(search, bson.M{FN.MwAcc.Email: bson.M{"$regex": keyWords}})
|
||||
}
|
||||
|
||||
match := bson.M{}
|
||||
if len(search) > 0 {
|
||||
match["$or"] = search
|
||||
}
|
||||
|
||||
if status > 0 {
|
||||
if status == 1 {
|
||||
match[FN.MwAcc.IsEnb] = true
|
||||
} else {
|
||||
match[FN.MwAcc.IsEnb] = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
searchs = bson.M{}
|
||||
searchs["$match"] = match
|
||||
return
|
||||
}
|
||||
|
||||
func MakeSort(pageNum int64, pageSize int64) (sort []bson.M) {
|
||||
sort = append(sort, bson.M{
|
||||
"$sort": bson.M{
|
||||
FN.MwAcc.CreatedAt: -1,
|
||||
},
|
||||
})
|
||||
if pageNum <= 0 {
|
||||
pageNum = 1
|
||||
}
|
||||
if pageSize <= 0 {
|
||||
pageSize = 10
|
||||
}
|
||||
skip := (pageNum - 1) * pageSize
|
||||
sort = append(sort, bson.M{
|
||||
"$skip": skip,
|
||||
})
|
||||
|
||||
sort = append(sort, bson.M{
|
||||
"$limit": pageSize,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user