Initial commit

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 13:57:10 +08:00
co-authored by Claude Opus 5
commit 8679200f41
1897 changed files with 257900 additions and 0 deletions
+61
View File
@@ -0,0 +1,61 @@
package common
import (
"reflect"
"strings"
"time"
"91porn-server/common/log"
"go.mongodb.org/mongo-driver/bson"
)
// ParseFilter ParseFilter
func ParseFilter(cond map[string]interface{}) []bson.M {
ret := []bson.M{}
for key := range cond {
if strings.HasSuffix(key, "Start") {
keyS := strings.TrimSuffix(key, "Start")
endK := keyS + "End"
ts, err := time.Parse(time.RFC3339, cond[key].(string))
if err != nil {
log.Error("buildFilter解析查询条件出错", log.E(err))
continue
}
te, err := time.Parse(time.RFC3339, cond[endK].(string))
if err != nil {
continue
}
a := bson.M{
keyS: bson.M{
"$gte": ts,
"$lte": te,
},
}
b := bson.M{
"$match": a,
}
ret = append(ret, b)
continue
}
if strings.HasSuffix(key, "End") {
continue
}
if reflect.TypeOf(cond[key]).Kind() == reflect.Slice {
mm := bson.M{
"$match": bson.M{
key: bson.M{
"$in": cond[key],
},
},
}
ret = append(ret, mm)
continue
}
e := bson.M{
"$match": bson.M{key: cond[key]},
}
ret = append(ret, e)
}
return ret
}