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
+80
View File
@@ -0,0 +1,80 @@
package annouser
import (
"fmt"
"time"
"91porn-server/common/log"
"91porn-server/common/stderr"
"91porn-server/models/v/annoumod"
"91porn-server/web/vidhelp"
"go.mongodb.org/mongo-driver/bson/primitive"
)
// GetAnnouList 获取公告列表
func GetAnnouList(req annoumod.ListReq) (code stderr.Code, data interface{}) {
if len(req.Sort) == 0 {
req.Sort = "createdAt"
}
desc := -1
if req.Desc == 1 {
desc = req.Desc
}
aInfos, _, total, err := annoumod.GetAnnou(req.PageNumber, req.PageSize, req.Sort, desc)
if err != nil {
return stderr.ErrDbQueryError, nil
}
return stderr.Success, annoumod.ListResp{AInfos: aInfos, Total: total}
}
// UpdateAnnou 更新公告信息
func UpdateAnnou(req annoumod.EditReq) (code stderr.Code, data interface{}) {
oid, err := primitive.ObjectIDFromHex(req.ID)
if err != nil {
log.Error(fmt.Sprintf("exchange string(%s) to objectID error.", req.ID))
return stderr.ErrParamError, nil
}
m := vidhelp.Struct2Map(req.EditInfo)
cnt, err := annoumod.UpdateAnnou(oid, m)
if err != nil {
return stderr.ErrDbUpdateError, nil
}
return stderr.Success, annoumod.OpeResp{Count: cnt}
}
// DeleteAnnou 删除公告
func DeleteAnnou(ids []string) (code stderr.Code, data interface{}) {
oids := make([]primitive.ObjectID, 0, len(ids))
for _, id := range ids {
oid, err := primitive.ObjectIDFromHex(id)
if err != nil {
log.Error(fmt.Sprintf("exchange string(%s) to objectID error.", id))
continue
}
oids = append(oids, oid)
}
cnt, err := annoumod.DeleteAnnou(oids)
if err != nil {
return stderr.ErrDbUpdateError, nil
}
return stderr.Success, annoumod.OpeResp{Count: cnt}
}
// AddAnnou 添加公告
func AddAnnou(req annoumod.AddReq) (code stderr.Code, data interface{}) {
infos := []annoumod.Annou{annoumod.Annou{
Title: req.Title,
Content: req.Content,
Cover: req.Cover,
Type: req.Type,
Href: req.Href,
Active: req.Active,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
}}
if err := annoumod.AddAnnou(infos); err != nil {
return stderr.ErrDbInsertError, ""
}
return stderr.Success, nil
}
+88
View File
@@ -0,0 +1,88 @@
package annouser
import (
"fmt"
"time"
"91porn-server/common/log"
"91porn-server/common/stderr"
"91porn-server/models/v/annoumod"
"91porn-server/web/vidhelp"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
)
// GetAnnounceList 获取会员中心跑马灯列表
func GetAnnounceListApi() (code stderr.Code, announce string) {
aInfos, err := annoumod.GetAnnounceApi("createdAt", -1)
if err != nil && err != mongo.ErrNoDocuments {
return stderr.ErrDbQueryError, ""
}
if err == mongo.ErrNoDocuments || len(aInfos) <= 0 {
return stderr.Success, ""
}
return stderr.Success, aInfos[0].Content
}
// GetAnnounceList 获取会员中心跑马灯列表
func GetAnnounceList() (code stderr.Code, data []annoumod.Announce) {
aInfos, err := annoumod.GetAnnounce("createdAt", -1)
if err != nil && err != mongo.ErrNoDocuments {
return stderr.ErrDbQueryError, nil
}
if err == mongo.ErrNoDocuments || len(aInfos) <= 0 {
return stderr.Success, nil
}
return stderr.Success, aInfos
}
// UpdateAnnounce 更新会员中心跑马灯信息
func UpdateAnnounce(req annoumod.EditAnnounceReq) (code stderr.Code, data interface{}) {
oid, err := primitive.ObjectIDFromHex(req.ID)
if err != nil {
log.Error(fmt.Sprintf("exchange string(%s) to objectID error.", req.ID))
return stderr.ErrParamError, nil
}
m := vidhelp.Struct2Map(req.EditAnnounceInfo)
cnt, err := annoumod.UpdateAnnounce(oid, m)
if err != nil {
return stderr.ErrDbUpdateError, nil
}
return stderr.Success, annoumod.OpeResp{Count: cnt}
}
// DeleteAnnounce 删除会员中心跑马灯
func DeleteAnnounce(ids []string) (code stderr.Code, data interface{}) {
oids := make([]primitive.ObjectID, 0, len(ids))
for _, id := range ids {
oid, err := primitive.ObjectIDFromHex(id)
if err != nil {
log.Error(fmt.Sprintf("exchange string(%s) to objectID error.", id))
continue
}
oids = append(oids, oid)
}
cnt, err := annoumod.DeleteAnnounce(oids)
if err != nil {
return stderr.ErrDbUpdateError, nil
}
return stderr.Success, annoumod.OpeResp{Count: cnt}
}
// AddAnnounce 添加会员中心跑马灯
func AddAnnounce(req annoumod.AddAnnounceReq) (code stderr.Code) {
infos := []annoumod.Announce{annoumod.Announce{
ID: primitive.NewObjectID(),
Content: req.Content,
Url: req.Url,
Type: annoumod.UserCenter,
Active: req.Active,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
}}
if err := annoumod.AddAnnounce(infos); err != nil {
return stderr.ErrDbInsertError
}
return stderr.Success
}