119 lines
4.5 KiB
Go
119 lines
4.5 KiB
Go
package vidctrl
|
|
|
|
import (
|
|
"91porn-server/common"
|
|
"91porn-server/common/stderr"
|
|
"91porn-server/models/commod"
|
|
"91porn-server/web/service/vidser"
|
|
"time"
|
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// GetMediaList doc
|
|
// @Summary 获取媒体资源库资源
|
|
// @Description 获取媒体资源库资源
|
|
// @Tags vid
|
|
// @Accept mpfd,json
|
|
// @Produce json,html
|
|
// @Param pageNumber formData integer true "查询页码"
|
|
// @Param pageSize formData integer true "页码大小"
|
|
// @Router /api/web/admin/mediaResource/list [get]
|
|
func GetMediaList(ctx *gin.Context) {
|
|
var p struct {
|
|
Title string `form:"title" json:"title" `
|
|
TagText string `form:"tag_text" json:"tag_text"` //标签搜索
|
|
HashId string `form:"hash_id" json:"hash_id"`
|
|
MVia int `form:"mVia" json:"mVia"` //0 (defalut) from all;1 from uploader;2 from non-uploader
|
|
VideoType int `form:"videoType" json:"videoType"` //0 长视频 1短视频 2图文
|
|
VloggerUserId int `form:"vlogger_user_id" json:"vlogger_user_id"` //up主所在平台的uid
|
|
SyncType string `form:"syncType" json:"syncType"` //同步类型all 全量 incr
|
|
TerminalCdo string `form:"terminalCdo" json:"terminalCdo"` // 上传者
|
|
SortType int `form:"sortType" json:"sortType"` // 0-正序 1-倒序
|
|
StartTime time.Time `form:"start" json:"start"` // 开始时间
|
|
EndTime time.Time `form:"end" json:"end"` // 结束时间
|
|
MaxTotal int `json:"maxTotal" form:"maxTotal"` // 最大列表总数
|
|
commod.Page
|
|
}
|
|
if err := ctx.ShouldBind(&p); err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
|
return
|
|
}
|
|
data, total, err := vidser.GetMediaList(ctx, int64(p.PageNumber), int64(p.PageSize), int64(p.VloggerUserId),
|
|
p.Title, p.TagText, p.HashId, p.MVia, p.VideoType, p.SyncType, p.TerminalCdo, p.StartTime, p.EndTime, p.SortType, p.MaxTotal)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
|
return
|
|
}
|
|
common.ServeJSON(ctx, stderr.Success, gin.H{
|
|
"count": total,
|
|
"list": data,
|
|
})
|
|
}
|
|
|
|
// UseMedia doc
|
|
// @Summary 使用资源
|
|
// @Description 使用资源媒体资源库资源
|
|
// @Tags vid
|
|
// @Accept mpfd,json
|
|
// @Produce json,html
|
|
// @Param pageNumber formData integer true "查询页码"
|
|
// @Param pageSize formData integer true "页码大小"
|
|
// @Router /api/web/admin/mediaResource/use [post]
|
|
func UseMedia(ctx *gin.Context) {
|
|
manager, err := common.GetAdminAct(ctx)
|
|
if err != nil {
|
|
return
|
|
}
|
|
var p struct {
|
|
IDs []int64 `json:"ids"`
|
|
AuthorID uint64 `json:"authorID"`
|
|
Tags []string `json:"tags"`
|
|
SectionID primitive.ObjectID `json:"sectionID"`
|
|
VideoType int `json:"videoType"` //0 长视频 1短视频 2图文
|
|
OnlineTime time.Time `json:"onlineTime" form:"onlineTime"` // 自动上架时间
|
|
Coins *int64 `json:"coins" form:"coins"`
|
|
}
|
|
if err = ctx.ShouldBind(&p); err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
|
return
|
|
}
|
|
hits, err := vidser.UseMedias(ctx, p.IDs, p.AuthorID, p.SectionID, p.Tags, p.VideoType, manager, p.Coins, p.OnlineTime)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
|
return
|
|
}
|
|
resp := gin.H{"sensitiveHits": hits}
|
|
if len(hits) > 0 {
|
|
resp["sensitiveTip"] = vidser.SensitiveForcedOfflineTip
|
|
}
|
|
common.ServeJSON(ctx, stderr.Success, resp)
|
|
}
|
|
|
|
// IgnoreMedia doc
|
|
// @Summary 忽略媒体资源
|
|
// @Description 忽略媒体资源库资源
|
|
// @Tags vid
|
|
// @Accept mpfd,json
|
|
// @Produce json,html
|
|
// @Param pageNumber formData integer true "查询页码"
|
|
// @Param pageSize formData integer true "页码大小"
|
|
// @Router /api/web/admin/mediaResource/ignore [post]
|
|
func IgnoreMedia(ctx *gin.Context) {
|
|
var p struct {
|
|
IDs []int64 `json:"ids"`
|
|
VideoType int `json:"videoType"`
|
|
}
|
|
if err := ctx.ShouldBind(&p); err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
|
return
|
|
}
|
|
if err := vidser.IgnoreMedias(ctx, p.IDs, p.VideoType); err != nil {
|
|
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
|
return
|
|
}
|
|
common.ServeJSON(ctx, stderr.Success, "")
|
|
}
|