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
+57
View File
@@ -0,0 +1,57 @@
package synccdnmod
import (
"fmt"
"91porn-server/common/db"
"91porn-server/common/log"
"91porn-server/models"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
)
var mdb *db.MongoDB
const table = models.SyncCdnLog
func coll(t *db.MongoTool) *db.MongoTool {
if t == nil {
return mdb.Coll(table)
}
return t.Coll(table)
}
// initIndex 初始化索引
func initIndex() {
many := []mongo.IndexModel{
{
Keys: bson.D{{Key: "createdAt", Value: -1}},
},
}
if _, err := coll(nil).CreateIndex(many); err != nil {
panic(fmt.Sprintf("%s model set index err ==>[%+v]", table, err))
}
}
// InsertSyncCdnLog InsertSyncCdnLog
func InsertSyncCdnLog(p SyncCdnLog) error {
_, err := coll(nil).InsertOne(&p)
return err
}
// FindSyncRecord 查询
func FindSyncRecord() (pr []SyncCdnLog, err error) {
pr = []SyncCdnLog{}
cond := []bson.M{
bson.M{
"$sort": bson.M{"createdAt": -1},
},
bson.M{
"$limit": 1}}
if err = coll(nil).Aggregate(&pr, cond); err != nil {
log.Error("FindSyncRecord error", log.E(err))
return
}
return
}
+51
View File
@@ -0,0 +1,51 @@
package synccdnmod
import (
"91porn-server/common/db"
"91porn-server/common/stderr"
"time"
)
const (
AccessKey = "4qQTNUrg9MloxqtykJbkf9BTeJ3liBo5fS7Qg6Nu"
SecretKey = "axcamr082kQaJx87ebqkGHNPy-9EBeoTT2XbU6A2"
//AccessKey = "MY_ACCESS_KEY"
//SecretKey = "MY_SECRET_KEY"
URl = "http://rs.qiniu.com/move/bmV3ZG9jczpmaW5kX21hbi50eHQ=/bmV3ZG9jczpmaW5kLm1hbi50eHQ="
Host string = "http://fusion.qiniuapi.com" //域名
FetchUrl string = "/v2/tune/prefetch" //预取接口
PreFetchUrl string = "/v2/tune/prefetch/list" //预期查询接口地址
)
// SyncHttpResp 返回结构体
type SyncHttpResp struct {
Code stderr.Code `json:"code"`
Error string `json:"error"`
RequestId string `json:"requestId"`
InvalidUrls []string `json:"invalidUrls"`
QuotaDay int `json:"quotaDay"`
SurplusDay int `json:"surplusDay"`
}
type SyncCdnLog struct {
RequestIds []string `json:"requestIds" bson:"requestIds"`
LastID string `json:"lastId" bson:"lastId"`
Count int `json:"count" bson:"count"`
FailCount int `json:"failCount" bson:"failCount"`
CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
FailIDs []string `json:"failIDs" bson:"failIDs,omitempty"`
}
// SyncReq 前端参数传递
type SyncReq struct {
Token string `json:"token" binding:"required"`
Cdn string `json:"cdn"`
FilePath string `json:"filePath"`
}
func Init() {
mdb = db.Init(table)
initIndex()
}