71 lines
1.7 KiB
Go
Executable File
71 lines
1.7 KiB
Go
Executable File
package nakedchatser
|
|
|
|
import (
|
|
"91porn-server/common/log"
|
|
"91porn-server/models/cache/nakedchatdata"
|
|
"91porn-server/models/commod"
|
|
"91porn-server/models/v/nakedchatmod"
|
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
)
|
|
|
|
type AppQueryListReq struct {
|
|
Mid string `json:"mid" form:"mid" binding:"required"` // 模块id
|
|
commod.Page
|
|
}
|
|
|
|
type AppListRes struct {
|
|
Total int64 `json:"total"`
|
|
HasNext bool `json:"hasNext"`
|
|
List []*nakedchatmod.NakedChatSimple `json:"list"`
|
|
}
|
|
|
|
// GetList 获取列表
|
|
func (p *AppQueryListReq) GetList() AppListRes {
|
|
var res AppListRes
|
|
var err error
|
|
mid, _ := primitive.ObjectIDFromHex(p.Mid)
|
|
if mid.IsZero() {
|
|
return res
|
|
}
|
|
filter := bson.M{
|
|
"mid": mid,
|
|
"status": 1,
|
|
}
|
|
sort := bson.D{{"sortCode", -1}, {"createdAt", -1}}
|
|
// 获取列表
|
|
var data []nakedchatmod.NakedChat
|
|
data, res.Total, res.HasNext, err = nakedchatdata.GetListFromCache(filter, int64(p.Skip()), int64(p.Limit()), sort)
|
|
if err != nil {
|
|
log.Error("获取裸聊列表数据错误", log.Any("Params", *p), log.E(err))
|
|
return res
|
|
}
|
|
res.List = nakedchatdata.FormatAppDataList(data)
|
|
|
|
return res
|
|
}
|
|
|
|
type AppQueryInfoReq struct {
|
|
ID string `json:"id" form:"id"` // id
|
|
}
|
|
type AppQueryInfoRes = *nakedchatmod.NakedChatInfo
|
|
|
|
// GetInfo 获取详情
|
|
func (p *AppQueryInfoReq) GetInfo() (res AppQueryInfoRes, err error) {
|
|
oid, err := primitive.ObjectIDFromHex(p.ID)
|
|
if err != nil {
|
|
return res, err
|
|
}
|
|
|
|
var item nakedchatmod.NakedChat
|
|
item, err = nakedchatdata.GetInfoFromCache(oid)
|
|
if err != nil {
|
|
log.Error("获取裸聊详情数据错误", log.Any("ID", p.ID), log.E(err))
|
|
return
|
|
}
|
|
|
|
res = nakedchatdata.FormatAppData(item)
|
|
return
|
|
}
|