202 lines
6.5 KiB
Go
Executable File
202 lines
6.5 KiB
Go
Executable File
package nakedchatser
|
|
|
|
import (
|
|
"time"
|
|
|
|
"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 WebListReq struct {
|
|
Title *string `json:"title" form:"title"`
|
|
Status *int `json:"status" form:"status"` // 0-下架 1-上架
|
|
Mid *string `json:"mid" form:"mid"` // 模块id
|
|
commod.Page
|
|
}
|
|
type WebListRes struct {
|
|
Total int64 `json:"total"`
|
|
HasNext bool `json:"hasNext"`
|
|
List []nakedchatmod.NakedChat `json:"list"`
|
|
}
|
|
|
|
// GetList 获取列表
|
|
func (q *WebListReq) GetList() (res WebListRes, err error) {
|
|
filter := bson.M{}
|
|
if q.Title != nil {
|
|
filter["title"] = bson.M{
|
|
"$regex": *q.Title,
|
|
}
|
|
}
|
|
if q.Status != nil {
|
|
filter["status"] = *q.Status
|
|
}
|
|
if q.Mid != nil {
|
|
mid, _ := primitive.ObjectIDFromHex(*q.Mid)
|
|
filter["mid"] = mid
|
|
}
|
|
res.List, res.Total, res.HasNext, err = nakedchatmod.GetList(filter, int64(q.Skip()), int64(q.Limit()), q.GetSort())
|
|
|
|
return
|
|
}
|
|
|
|
type WebCreateReq struct {
|
|
Title string `json:"title" form:"title" binding:"required"` // 标题
|
|
Cover string `json:"cover" form:"cover" binding:"required"` // 封面
|
|
Price uint64 `json:"price" form:"price" binding:"required"` // 价格 n金币/分钟
|
|
Options []uint64 `json:"options" form:"options" binding:"required"` // 可供购买选项 ,多少分钟
|
|
Images []string `json:"images" form:"images"` // 图片列表
|
|
Video string `json:"video" form:"video"` // 展示的视频
|
|
Contact string `json:"contact" form:"contact" binding:"required"` // 联系方式
|
|
Age int `json:"age" form:"age" binding:"required"` // 年龄 单位 岁
|
|
Weight int `json:"weight" form:"weight" binding:"required"` // 体重 单位 kg
|
|
Height int `json:"height" form:"height" binding:"required"` // 身高 单位 cm
|
|
Cup string `json:"cup" form:"cup" binding:"required"` // 罩杯
|
|
FakeSaleNum int64 `json:"fakeSaleNum" form:"fakeSaleNum" binding:"required"` // 销售数量(假)
|
|
BusinessHours string `json:"businessHours" form:"businessHours" binding:"required"` // 连线时间
|
|
Summary string `json:"summary" form:"summary"` // 简介
|
|
Status int `json:"status" form:"status"` // 0-下架 1-上架
|
|
SortCode int64 `json:"sortCode" bson:"sortCode"` // 排序号
|
|
|
|
}
|
|
|
|
// Create 发布数据
|
|
func (p *WebCreateReq) Create() error {
|
|
data := nakedchatmod.NakedChat{
|
|
Title: p.Title,
|
|
Cover: p.Cover,
|
|
Price: p.Price,
|
|
Options: p.Options,
|
|
Images: p.Images,
|
|
Video: p.Video,
|
|
Contact: p.Contact,
|
|
Age: p.Age,
|
|
Weight: p.Weight,
|
|
Height: p.Height,
|
|
Cup: p.Cup,
|
|
FakeSaleNum: p.FakeSaleNum,
|
|
BusinessHours: p.BusinessHours,
|
|
Summary: p.Summary,
|
|
Status: p.Status,
|
|
SortCode: p.SortCode,
|
|
CreatedAt: time.Now(),
|
|
UpdatedAt: time.Now(),
|
|
}
|
|
|
|
// 创建数据
|
|
if _, err := nakedchatdata.InsertData(nil, data); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type WebUpdateReq struct {
|
|
ID primitive.ObjectID `json:"id" binding:"required"`
|
|
Title *string `json:"title"` // 标题
|
|
Cover *string `json:"cover"` // 封面
|
|
Price *int64 `json:"price"` // 价格 n金币/分钟
|
|
Options *[]int64 `json:"options"` // 可供购买选项 ,多少分钟
|
|
Images *[]string `json:"images"` // 图片列表
|
|
Video *string `json:"video"` // 展示的视频
|
|
Contact *string `json:"contact"` // 联系方式
|
|
Age *int `json:"age"` // 年龄 单位 岁
|
|
Weight *int `json:"weight"` // 体重 单位 kg
|
|
Height *int `json:"height"` // 身高 单位 cm
|
|
Cup *string `json:"cup"` // 罩杯
|
|
FakeSaleNum *int64 `json:"fakeSaleNum"` // 销售数量(假)
|
|
BusinessHours *string `json:"businessHours"` // 连线时间
|
|
Summary *string `json:"summary"` // 简介
|
|
Status *int `json:"status" bson:"status"` // 0-下架 1-上架
|
|
SortCode *int64 `json:"sortCode" bson:"sortCode"` // 排序号
|
|
|
|
}
|
|
|
|
// Update 更新数据
|
|
func (p *WebUpdateReq) Update() error {
|
|
_, err := nakedchatmod.GetInfo(p.ID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
data := make(map[string]interface{})
|
|
if p.Title != nil {
|
|
data["title"] = *p.Title
|
|
}
|
|
if p.Cover != nil {
|
|
data["cover"] = *p.Cover
|
|
}
|
|
if p.Price != nil {
|
|
data["price"] = *p.Price
|
|
}
|
|
if p.Options != nil {
|
|
data["options"] = *p.Options
|
|
}
|
|
if p.Images != nil {
|
|
data["images"] = *p.Images
|
|
}
|
|
if p.Video != nil {
|
|
data["video"] = *p.Video
|
|
}
|
|
if p.Contact != nil {
|
|
data["contact"] = *p.Contact
|
|
}
|
|
if p.Age != nil {
|
|
data["age"] = *p.Age
|
|
}
|
|
if p.Weight != nil {
|
|
data["weight"] = *p.Weight
|
|
}
|
|
if p.Height != nil {
|
|
data["height"] = *p.Height
|
|
}
|
|
if p.Cup != nil {
|
|
data["cup"] = *p.Cup
|
|
}
|
|
if p.FakeSaleNum != nil {
|
|
data["fakeSaleNum"] = *p.FakeSaleNum
|
|
}
|
|
if p.BusinessHours != nil {
|
|
data["businessHours"] = *p.BusinessHours
|
|
}
|
|
if p.Summary != nil {
|
|
data["summary"] = *p.Summary
|
|
}
|
|
if p.Status != nil {
|
|
data["status"] = *p.Status
|
|
}
|
|
if p.SortCode != nil {
|
|
data["sortCode"] = *p.SortCode
|
|
}
|
|
data["updatedAt"] = time.Now()
|
|
|
|
if _, err = nakedchatdata.UpdateData(nil, p.ID.Hex(), data); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type WebBatchUpdateReq struct {
|
|
Ids []primitive.ObjectID `json:"ids" binding:"required"`
|
|
Mid *primitive.ObjectID `json:"mid" form:"mid"` // 模块id
|
|
|
|
}
|
|
|
|
// Update 更新数据
|
|
func (p *WebBatchUpdateReq) Update() error {
|
|
data := make(map[string]interface{})
|
|
if p.Mid != nil {
|
|
data["mid"] = *p.Mid
|
|
}
|
|
data["updatedAt"] = time.Now()
|
|
for _, id := range p.Ids {
|
|
if _, err := nakedchatdata.UpdateData(nil, id.Hex(), data); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|