42 lines
1.7 KiB
Go
42 lines
1.7 KiB
Go
package dailytaskmod
|
|
|
|
import (
|
|
"91porn-server/common/db"
|
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
)
|
|
|
|
type AddDailyTaskReq struct {
|
|
Title *string `json:"title"` // 任务标题
|
|
Img *string `json:"img"` // 任务图片
|
|
Type *DailyTaskTypeEnum `json:"type"` // 0 每日广告点击; 1 每日邀请
|
|
Desc *string `json:"desc"` // 任务说明
|
|
Detail []TaskDetail `json:"detail"` // 任务详情
|
|
Status *bool `json:"status"` // 启用/禁用
|
|
Link *string `json:"link"` // 跳转链接
|
|
SortNum *int `json:"sortNum"` // 排序
|
|
}
|
|
|
|
func AddDailyTask(t *db.MongoTool, dt DailyTask) error {
|
|
_, err := coll(t).InsertOne(dt)
|
|
return err
|
|
}
|
|
|
|
type EditDailyTaskReq struct {
|
|
ID primitive.ObjectID `json:"_id" binding:"required"` // 被编辑的任务id
|
|
Title *string `json:"title" bson:"title"` // 任务标题
|
|
Img *string `json:"img" bson:"img"` // 任务图片
|
|
Type *DailyTaskTypeEnum `json:"type" bson:"type"` // 0 每日广告点击; 1 每日邀请
|
|
Desc *string `json:"desc" bson:"desc"` // 任务说明
|
|
Detail []TaskDetail `json:"detail" bson:"detail"` // 任务详情
|
|
Status *bool `json:"status" bson:"status"` // 启用/禁用
|
|
Link *string `json:"link" bson:"link"` // 跳转链接
|
|
SortNum *int `json:"sortNum" bson:"sortNum"` // 排序
|
|
}
|
|
|
|
func EditDailyTask(t *db.MongoTool, id primitive.ObjectID, set bson.M) error {
|
|
_, err := coll(t).UpdateOne(bson.M{"_id": id}, bson.M{"$set": set})
|
|
return err
|
|
}
|