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
+42
View File
@@ -0,0 +1,42 @@
package noticerecdmod
import "time"
// 动态类型
type TrendType string
const (
Fans TrendType = "fans" //粉丝
Like TrendType = "like" //点赞
Cmet TrendType = "cmet" //评论
Itte TrendType = "itte" //互动
)
// UpdateTrendReadTime 更新动态的阅读时间
func UpdateTrendReadTime(trend TrendType, uid uint64, readAt time.Time) error {
filter := M{
"uid": uid,
"noticeCode": trend,
}
noticeRecord := NoticeRecord{}
if err := coll(nil).FindOne(&noticeRecord, filter); err != nil {
return err
}
if noticeRecord.LastReadAt.After(readAt) {
return nil
}
filter["lastReadAt"] = M{"$lt": readAt}
update := M{
"$setOnInsert": M{
"uid": uid,
"noticeCode": trend,
"createdAt": time.Now(),
},
"$set": M{
"lastReadAt": readAt,
"updatedAt": time.Now(),
},
}
_, err := coll(nil).UpsertOne(filter, update)
return err
}