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
+90
View File
@@ -0,0 +1,90 @@
package infmtctrl
import (
"time"
"91porn-server/app/service/infmtser"
"91porn-server/common"
"91porn-server/common/log"
"91porn-server/common/stderr"
"91porn-server/models/commod"
"91porn-server/models/v/noticefmtmod"
"github.com/gin-gonic/gin"
"go.mongodb.org/mongo-driver/bson/primitive"
)
// ObjectID
type ObjectID = primitive.ObjectID
// NoticeList doc
// @Summary 消息模块 - 预览
// @Description 动态预览和通知预览
// @Tags Information
// @Accept mpfd,json
// @Produce json,html
// @Success 200 {string} json "{"msg": "操作成功" "data": infmtser.NoticePage }"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/inform/preview [get]
func Preview(c *gin.Context) {
// 检查uid是否存在
uid, err := common.GetUID(c)
if err != nil {
common.ServeJSON(c, stderr.UserIsNotExists, "Notice List Context USER_ID is not exist ")
return
}
noticePreviewList, hasNewNotice, err := infmtser.UpdateNoticePreviewList(uid, time.Now())
if err != nil {
common.ServeJSON(c, stderr.ErrNetWorkBusy, err)
return
}
trendPreMap, hasNewTrend := infmtser.TrendPreviewMap(uid)
common.ServeJSON(c, stderr.Success, gin.H{
"noticePreList": noticePreviewList,
"trendPreMap": trendPreMap,
"hasNew": hasNewNotice || hasNewTrend,
"updatedAt": time.Now(),
})
}
// NoticeList doc
// @Summary 消息模块 - 通知队列
// @Description 获取通知并同步通知状态
// @Tags Information
// @Accept mpfd,json
// @Produce json,html
// @Param sender formData string true "消息发送者"
// @Param pageNumber formData int true "当前页"
// @Param pageSize formData int true "每页条数"
// @Success 200 {string} json "{"msg": "操作成功" "data": infmtser.MailPage }"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/inform/notice/list [get]
func NoticeList(c *gin.Context) {
var arg struct {
Sender noticefmtmod.Sender `form:"sender" json:"sender" binding:"required"` //消息发送者 活动助手、系统消息
commod.Page
}
if err := c.ShouldBind(&arg); err != nil {
common.ServeJSON(c, stderr.ErrParamError, "Notice List arg error "+err.Error())
return
}
// 检查uid是否存在
uid, err := common.GetUID(c)
if err != nil {
common.ServeJSON(c, stderr.UserIsNotExists, "Notice List Context USER_ID is not exist ")
return
}
skip := (arg.PageNumber - 1) * arg.PageSize
limit := arg.PageSize
noticePage, err := infmtser.NoticePages(arg.Sender, uid, int64(skip), int64(limit))
if err != nil {
common.ServeJSON(c, stderr.ErrNetWorkBusy, err)
return
}
common.Go(func() {
if err = infmtser.UpdateNoticeReadTime(arg.Sender, uid, time.Now()); err != nil {
log.Error("UpdateNoticeReadTime faild", log.E(err))
}
})
common.ServeJSON(c, stderr.Success, noticePage)
}