init: hgmj server initial commit

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 16:50:13 +08:00
co-authored by Claude Opus 4.7
commit 625e89c15d
1870 changed files with 254090 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
package vipconfigmod
import (
"fmt"
"time"
"91jd-server/common/db"
"91jd-server/common/log"
"91jd-server/models"
"go.mongodb.org/mongo-driver/bson"
)
const table = models.VipConfig
func coll(t *db.MongoTool) *db.MongoTool {
if t == nil {
return mdb.Coll(table)
}
return t.Coll(table)
}
func FindOne() (c VIPConfig, err error) {
err = coll(nil).FindOne(&c, bson.M{"_id": 1})
if err != nil {
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "GetByID", table, "FindOne", err))
}
return
}
//todo app
// todo web
// InsertVIP 插入一条数据
func Update(set EditSelector) error {
now := time.Now()
set.UpdatedAt = now
_, err := coll(nil).UpsertOne(bson.M{"_id": 1}, bson.M{"$set": set, "$setOnInsert": bson.M{"createdAt": set.UpdatedAt}})
if err != nil {
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "Update", table, "UpsertOne", err))
}
return err
}