+68
@@ -0,0 +1,68 @@
|
||||
package nakedchatorderser
|
||||
|
||||
import (
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/models/cache/nakedchatorderdata"
|
||||
"91porn-server/models/commod"
|
||||
"91porn-server/models/v/nakedchatordermod"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type AppQueryListReq struct {
|
||||
Status *int `json:"status" form:"status"` // 0-已下单 1-已完成
|
||||
commod.Page
|
||||
}
|
||||
|
||||
type AppListRes struct {
|
||||
Total int64 `json:"total"`
|
||||
HasNext bool `json:"hasNext"`
|
||||
List []*nakedchatordermod.NakedChatOrderInfo `json:"list"`
|
||||
}
|
||||
|
||||
// GetList 获取列表
|
||||
func (p *AppQueryListReq) GetList(uid uint64) AppListRes {
|
||||
var res AppListRes
|
||||
var err error
|
||||
filter := bson.M{
|
||||
"uid": uid,
|
||||
}
|
||||
if p.Status != nil {
|
||||
filter["status"] = *p.Status
|
||||
}
|
||||
sort := bson.D{{"_id", -1}}
|
||||
// 获取列表
|
||||
var data []nakedchatordermod.NakedChatOrder
|
||||
data, res.Total, res.HasNext, err = nakedchatordermod.GetList(filter, int64(p.Skip()), int64(p.Limit()), sort)
|
||||
if err != nil {
|
||||
log.Error("获取裸聊订单列表数据错误", log.Any("Params", *p), log.E(err))
|
||||
return res
|
||||
}
|
||||
res.List = nakedchatorderdata.FormatAppDataList(data)
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
type AppQueryInfoReq struct {
|
||||
ID string `json:"id" form:"id"` // id
|
||||
}
|
||||
type AppQueryInfoRes = *nakedchatordermod.NakedChatOrderInfo
|
||||
|
||||
// GetInfo 获取详情
|
||||
func (p *AppQueryInfoReq) GetInfo() (res AppQueryInfoRes, err error) {
|
||||
oid, err := primitive.ObjectIDFromHex(p.ID)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
var item nakedchatordermod.NakedChatOrder
|
||||
item, err = nakedchatordermod.GetInfo(oid)
|
||||
if err != nil {
|
||||
log.Error("获取裸聊订单详情数据错误", log.Any("ID", p.ID), log.E(err))
|
||||
return
|
||||
}
|
||||
|
||||
res = nakedchatorderdata.FormatAppData(item)
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user