@@ -0,0 +1,840 @@
|
||||
package vidctrl
|
||||
|
||||
import (
|
||||
"91porn-server/models/v/export_task_mod"
|
||||
"91porn-server/models/v/vidtimeonlinemod"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/constant/redisconst"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/s/statrecordmod"
|
||||
"91porn-server/models/v/operationlogmod"
|
||||
"91porn-server/models/v/pushmod"
|
||||
"91porn-server/models/v/tagmod"
|
||||
"91porn-server/models/v/vidmod"
|
||||
"91porn-server/models/v/vidpopmod"
|
||||
"91porn-server/web/service/vidser"
|
||||
"91porn-server/web/webg"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// GetVidList doc
|
||||
// @Summary 获取视频列表
|
||||
// @Description 根据各种条件获取视频的列表
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param pageNumber formData integer true "查询页码"
|
||||
// @Param pageSize formData integer true "页码大小"
|
||||
// @Param status formData integer true "是否通过审核,0 未审核 1通过 2审核失败 3视为免费 4所有 5非零"
|
||||
// @Param key formData string true "查询的排序条件,createdAt,playCount"
|
||||
// @Param value formData integer true "正序反序,-1,1"
|
||||
// @Param isFree formData integer true "是否付费视频,0, 付费,1,免费, 2, 所有"
|
||||
// @Param isUserUp formData integer true "是否用户上传,0, 所有,1,是, 2,否"
|
||||
// @Param chosen formData integer true "是否精选 1精选 2未精选"
|
||||
// @Param title formData string true "过滤标题"
|
||||
// @Param uid formData string true "上传用户uid过滤"
|
||||
// @Param start formData integer true "上传时间,开始范围,时间戳"
|
||||
// @Param end formData integer true "上传时间,结束范围,时间戳"
|
||||
// @Param sectionID formData string false "专题ID"
|
||||
// @Param isSortedUnderModule formData string false "视频在专题下是否设置了排序"
|
||||
// @Param seedLinkUrl formData string false "种子下载链接"
|
||||
// @Param seedSize formData int false "种子影片大小"
|
||||
// @Param seedPlayTime formData int false "种子影片时长"
|
||||
// @Success 200 {object} vidmod.ListResp "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} string "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/vid/list [get]
|
||||
func GetVidList(ctx *gin.Context) {
|
||||
req := vidmod.ListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
m, sort, err := assembleConditions(req)
|
||||
if err != stderr.Success {
|
||||
common.ServeJSON(ctx, err, err)
|
||||
return
|
||||
}
|
||||
code, data := vidser.GetVidList(m, sort, req.PageNumber, req.PageSize, req.IsPush)
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// GetVidList doc
|
||||
// @Summary 导出视频列表
|
||||
// @Description 根据各种条件导出视频的列表
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param status formData integer true "是否通过审核,0 未审核 1通过 2审核失败 3视为免费 4所有 5非零"
|
||||
// @Param key formData string true "查询的排序条件,createdAt,playCount"
|
||||
// @Param value formData integer true "正序反序,-1,1"
|
||||
// @Param isFree formData integer true "是否付费视频,0, 付费,1,免费, 2, 所有"
|
||||
// @Param isUserUp formData integer true "是否用户上传,0, 所有,1,是, 2,否"
|
||||
// @Param chosen formData integer true "是否精选 1精选 2未精选"
|
||||
// @Param title formData string true "过滤标题"
|
||||
// @Param uid formData string true "上传用户uid过滤"
|
||||
// @Param start formData integer true "上传时间,开始范围,时间戳"
|
||||
// @Param end formData integer true "上传时间,结束范围,时间戳"
|
||||
// @Param sectionID formData string false "专题ID"
|
||||
// @Param isSortedUnderModule formData string false "视频在专题下是否设置了排序"
|
||||
// @Success 200 {string} string "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/vid/export [post]
|
||||
func ExportVidList(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := vidmod.ListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
err = export_task_mod.CreateTask(export_task_mod.ExportVidTask, manager, req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrExportFileFail, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, "success")
|
||||
//m, sort, err := assembleConditions(req)
|
||||
//if err != stderr.Success {
|
||||
// common.ServeJSON(ctx, err, err)
|
||||
// return
|
||||
//}
|
||||
//buff, err := vidser.ExportVidList(m, sort)
|
||||
//if err != stderr.Success {
|
||||
// common.ServeJSON(ctx, err, err)
|
||||
// return
|
||||
//}
|
||||
//common.ServeFile(ctx, "video-list", common.FileExcel, &buff)
|
||||
}
|
||||
|
||||
func assembleConditions(req vidmod.ListReq) (m map[string]interface{}, sort vidser.SortModeList, err stderr.Code) {
|
||||
sort = vidser.SortModeList{{Field: "createdAt", Value: -1}}
|
||||
m = make(map[string]interface{})
|
||||
if req.ShowType != nil {
|
||||
m["showType"] = *req.ShowType
|
||||
}
|
||||
if req.Status != 4 {
|
||||
if req.Status == 7 {
|
||||
m["status"] = map[string]int{"$gt": 0}
|
||||
} else {
|
||||
m["status"] = req.Status
|
||||
}
|
||||
}
|
||||
if req.IsFree == 0 {
|
||||
m["coins"] = map[string]int{"$gt": 0}
|
||||
}
|
||||
if req.IsFree == 1 {
|
||||
m["coins"] = map[string]int{"$eq": 0}
|
||||
}
|
||||
if req.IsUserUp == 2 {
|
||||
m["publisherID"] = map[string]int{"$lt": 115000}
|
||||
}
|
||||
if req.IsUserUp == 1 {
|
||||
m["publisherID"] = map[string]int{"$gt": 115000}
|
||||
}
|
||||
if len(req.Title) != 0 {
|
||||
m["title"] = map[string]string{"$regex": req.Title, "$options": "i"}
|
||||
}
|
||||
if req.UID > 0 {
|
||||
m["publisherID"] = req.UID
|
||||
}
|
||||
if req.Chosen == 1 {
|
||||
m["chosen"] = true
|
||||
}
|
||||
if req.Chosen == 2 {
|
||||
m["chosen"] = false
|
||||
}
|
||||
if req.FreeArea == 1 {
|
||||
m["freeArea"] = true
|
||||
}
|
||||
if req.FreeArea == 2 {
|
||||
m["freeArea"] = false
|
||||
}
|
||||
if !req.End.IsZero() {
|
||||
m["createdAt"] = map[string]time.Time{"$gte": req.Start, "$lt": req.End}
|
||||
}
|
||||
if req.ReviewAccount != "" {
|
||||
m["reviewAccount"] = req.ReviewAccount
|
||||
}
|
||||
if len(req.Tag) != 0 {
|
||||
id, err := tagmod.GetTagIDByName(req.Tag)
|
||||
if err != nil {
|
||||
return m, sort, stderr.ErrDbQueryError
|
||||
}
|
||||
m["tags"] = id
|
||||
//sort = vidser.SortModeList{{Field: "tagSort." + id.Hex(), Value: -1}, {Field: "createdAt", Value: -1}}
|
||||
}
|
||||
if len(req.ID) != 0 {
|
||||
oid, err := primitive.ObjectIDFromHex(req.ID)
|
||||
if err != nil {
|
||||
return m, sort, stderr.ErrParamError
|
||||
}
|
||||
m["_id"] = oid
|
||||
}
|
||||
//通过初始价格判断是否是马甲账号
|
||||
if req.IsPretendAcc == 1 {
|
||||
m["coins"] = vidmod.PretendAccInitCoins
|
||||
}
|
||||
if req.IsPretendAcc == 2 {
|
||||
//i := make(map[string]int64)
|
||||
//i["$ne"] = vidmod.PretendAccInitCoins
|
||||
m["coins"] = map[string]int64{"$ne": vidmod.PretendAccInitCoins}
|
||||
}
|
||||
m["deleteAt"] = bson.M{"$exists": false}
|
||||
if req.NewsType != "" {
|
||||
m["newsType"] = req.NewsType
|
||||
}
|
||||
|
||||
if req.LiaoBaTop != nil {
|
||||
if *req.LiaoBaTop {
|
||||
sort = vidser.LiaoBaTopSortModeList()
|
||||
m["liaoBaTopSort"] = bson.M{"$gt": 0}
|
||||
} else {
|
||||
m["liaoBaTopSort"] = 0
|
||||
}
|
||||
}
|
||||
if req.SectionID != "" {
|
||||
m["sectionID"] = req.SectionID
|
||||
}
|
||||
m["isSortedUnderModule"] = req.IsSortedUnderModule
|
||||
if req.IsSortedUnderModule {
|
||||
sort = nil
|
||||
}
|
||||
if req.IsRecommended != nil {
|
||||
if *req.IsRecommended {
|
||||
m["recoWeight"] = bson.M{"$gte": 0}
|
||||
} else {
|
||||
m["recoWeight"] = bson.M{"$lt": 0}
|
||||
}
|
||||
}
|
||||
if req.Key == "likeRate" || req.Key == "purchaseRate" {
|
||||
m[req.Key] = req.Value
|
||||
}
|
||||
if req.IsHappinessPlazaTop != nil && *req.IsHappinessPlazaTop {
|
||||
if *req.IsHappinessPlazaTop {
|
||||
m["happinessPlazaTop"] = bson.M{"$gt": 0}
|
||||
} else {
|
||||
m["happinessPlazaTop"] = bson.M{"$lte": 0}
|
||||
}
|
||||
}
|
||||
return m, sort, stderr.Success
|
||||
}
|
||||
|
||||
// GetVidListByIds doc
|
||||
// @Summary 根据Ids获取视频列表
|
||||
// @Description 根据各种条件获取视频的列表
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ids formData array true "id数组"
|
||||
// @Param token formData string true "token"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/vid/listDetail [POST]
|
||||
func ListDetail(ctx *gin.Context) {
|
||||
var args struct {
|
||||
IDs []string `json:"ids" form:"ids" binding:"required"`
|
||||
Token string `json:"token" form:"token" binding:"required"`
|
||||
}
|
||||
if err := ctx.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if args.Token != "q7ydjHVIVBYiTqQ&" {
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, nil)
|
||||
return
|
||||
}
|
||||
m := make(map[string]interface{})
|
||||
i := make(map[string][]primitive.ObjectID)
|
||||
i["$in"] = common.String2ObjectID(args.IDs)
|
||||
m["_id"] = i
|
||||
code, data := vidser.GetVidList(m, vidser.SortModeList{{Field: "createdAt", Value: 1}}, 1, 100, false)
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// UpdateVidInfo doc
|
||||
// @Summary 编辑视频信息
|
||||
// @Description 编辑视频信息
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData integer true "id"
|
||||
// @Param uid formData integer true "用户ID"
|
||||
// @Param title formData string true "视频标题"
|
||||
// @Param tags formData array true "视频标签数组"
|
||||
// @Param playTime formData string false "视频时长"
|
||||
// @Param cover formData string false "封面图"
|
||||
// @Param coverThumb formData string false "小图"
|
||||
// @Param via formData string false "视频来源"
|
||||
// @Param coins formData integer false "观看金币"
|
||||
// @Param size formData integer false "文件大小"
|
||||
// @Param mimeType formData string false "影片类型"
|
||||
// @Param sourceURL formData string true "资源url"
|
||||
// @Param sourceID formData string true "上传视频成功后 返回的ID"
|
||||
// @Param filename formData string true "文件名"
|
||||
// @Param resolution formData string false "分辨率"
|
||||
// @Param md5 formData string true "文件摘要"
|
||||
// @Param freeTime formData integer false "免费观影时长"
|
||||
// @Param seedLinkUrl formData string false "种子下载链接"
|
||||
// @Param seedSize formData integer false "种子影片大小"
|
||||
// @Param seedPlayTime formData integer false "种子影片时长"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/vid/update [post]
|
||||
func UpdateVidInfo(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := vidmod.EditReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code, data := vidser.UpdateVidInfo(req, manager)
|
||||
if code == stderr.Success {
|
||||
_, _ = webg.Redis.Del(fmt.Sprintf(redisconst.VideoInfoKey(), req.ID))
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoManageList, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// DeleteVids doc
|
||||
// @Summary 删除视频资源
|
||||
// @Description 删除视频资源
|
||||
// @Tags follow
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param vids formData []string true "视频id数组"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/vid/del [delete]
|
||||
func DeleteVids(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := vidmod.DeleteReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
ids, err := common.IDArray(req.IDs)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, "")
|
||||
return
|
||||
}
|
||||
for _, id := range ids {
|
||||
if err = operationlogmod.Insert(operationlogmod.OperationLog{
|
||||
ID: primitive.NewObjectID(),
|
||||
OperationType: constant.Media_Del,
|
||||
AfterContent: fmt.Sprintf("%v", id),
|
||||
CreatedUser: manager,
|
||||
}); err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, "")
|
||||
return
|
||||
}
|
||||
}
|
||||
code, data := vidser.DeleteManyByTTL(ids...)
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoManageList, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// UpdateVids doc
|
||||
// @Summary 批量更新视频状态
|
||||
// @Description 批量更新视频状态
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ids formData []string true "批量更新的视频id"
|
||||
// @Param reco formData bool true "是否推荐, true:推荐,false:不推荐"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/vid/batch/reco [post]
|
||||
func BatchUpdateReco(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := vidmod.BatchUpdateRecoRequest{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if err = vidser.BatchUpdateReco(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertManyError, err)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoManageList, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// UpdateVids doc
|
||||
// @Summary 批量更新视频状态
|
||||
// @Description 批量更新视频状态
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ids formData []string true "批量更新的视频id"
|
||||
// @Param field formData string true "更新的字段名"
|
||||
// @Param status formData bool true "状态变更"
|
||||
// @Param publisherID formData integer true "发布者id"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/vid/batch/update [post]
|
||||
func UpdateVids(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := vidmod.EditManyReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code, data := vidser.UpdateVids(req)
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoManageList, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// PassAndEditVids doc
|
||||
// @Summary 批量更新视频状态
|
||||
// @Description 批量更新视频状态
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ids formData []string true "批量更新的视频id"
|
||||
// @Param field formData string true "更新的字段名"
|
||||
// @Param status formData bool true "状态变更"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/vid/batch/edit [post]
|
||||
func PassAndEditVids(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := vidmod.PassManyReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code, data := vidser.PassAndEditVids(req, manager)
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoManageList, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// PassVid doc
|
||||
// @Summary 视频通过审核
|
||||
// @Description 视频通过审核
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ids formData []string true "通过审核的视频id"
|
||||
// @Param pass formData integer true "是否通过审核"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/vid/batch/pass [post]
|
||||
func PassVid(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := vidmod.BatchReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code, data := vidser.PassVid(req, manager)
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoManageList, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// ViewVid doc
|
||||
// @Summary 查看视频状态
|
||||
// @Description 查看视频状态
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData string true "查看视频id"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/vid/view/:id [get]
|
||||
func ViewVid(ctx *gin.Context) {
|
||||
id := ctx.Param("id")
|
||||
if id == "" {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code, data := vidser.ViewVideoFromFs(id)
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// PushVid doc
|
||||
// @Summary 视频推送
|
||||
// @Description 视频推送
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ids formData []string true "通过审核的视频id"
|
||||
// @Param pass formData integer true "是否通过审核"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/vid/push [post]
|
||||
func PushVid(ctx *gin.Context) {
|
||||
req := pushmod.AddReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
//判断视频是否审核通过
|
||||
status, err := vidmod.GetVidStatus(req.VideoID)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
if status != vidmod.CheckPass {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code, data := vidser.PushVid(req)
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// PushVidList doc
|
||||
// @Summary 视频推送列表
|
||||
// @Description 视频推送列表
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ids formData []string true "通过审核的视频id"
|
||||
// @Param pass formData integer true "是否通过审核"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/vid/push/list [get]
|
||||
func PushVidList(ctx *gin.Context) {
|
||||
req := pushmod.ListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code, data := vidser.PushVidList(req)
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// DeletePushVid doc
|
||||
// @Summary 视频推送列表
|
||||
// @Description 视频推送列表
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ids formData []string true "通过审核的视频id"
|
||||
// @Param pass formData integer true "是否通过审核"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/vid/push/delete [delete]
|
||||
func DeletePushVid(ctx *gin.Context) {
|
||||
req := pushmod.DeleteReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code, data := vidser.DeletePushVid(req.IDs)
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// ConfigPopularity doc
|
||||
// @Summary 配置视频热度计算方式
|
||||
// @Description 配置视频热度计算方式
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param request body vidpopmod.VideoPopularityConfig true "request"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/vid/popularity/config [POST]
|
||||
func ConfigPopularity(ctx *gin.Context) {
|
||||
req := vidpopmod.VideoPopularityConfig{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
for i := range req.PlayTimePercentage {
|
||||
req.PlayTimePercentage[i].Max *= 60
|
||||
req.PlayTimePercentage[i].Min *= 60
|
||||
}
|
||||
if err := vidpopmod.InsertOne(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// GetPopularityConfig doc
|
||||
// @Summary 获取视频热度计算方式
|
||||
// @Description 获取视频热度计算方式
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {object} vidpopmod.VideoPopularityConfig "Success"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/vid/popularity/config [get]
|
||||
func GetPopularityConfig(ctx *gin.Context) {
|
||||
resp, err := vidpopmod.FindOne()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
func Reindex(ctx *gin.Context) {
|
||||
if err := statrecordmod.DeleteStatRecordByName(statrecordmod.ElasticSyncVideoJob); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// Search doc
|
||||
// @Summary 按照app搜索逻辑搜索视频
|
||||
// @Description 按照app搜索逻辑搜索视频
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param request body vidmod.WebElasticSearchRequest true "request"
|
||||
// @Success 200 {object} vidmod.WebElasticSearchResponse "Success"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/vid/search [post]
|
||||
func Search(ctx *gin.Context) {
|
||||
req := vidmod.WebElasticSearchRequest{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
res, err := vidmod.SearchWithTotal(req.Keyword, int64((req.PageNumber-1)*(req.PageSize)), int64(req.PageSize+1))
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrInterServerError, err)
|
||||
return
|
||||
}
|
||||
hasNext := false
|
||||
if uint64(len(res.Hits)) > req.PageSize {
|
||||
res.Hits = res.Hits[:req.PageSize]
|
||||
hasNext = true
|
||||
}
|
||||
list := make([]vidmod.ESVideo, len(res.Hits))
|
||||
for i := range res.Hits {
|
||||
list[i] = res.Hits[i].Source
|
||||
}
|
||||
resp := vidmod.WebElasticSearchResponse{List: list, HasNext: hasNext, Total: res.Total.Value}
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
// BatchAudit doc
|
||||
// @Summary 批量自动上架
|
||||
// @Description 批量自动上架
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param vids formData []string true "帖子id"
|
||||
// @Param sectionID formData string false "专题id"
|
||||
// @Param onlineTime formData string false "上架时间"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/vid/timeOnline/batchAudit [post]
|
||||
func BatchAudit(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := vidtimeonlinemod.BatchAuditReq{}
|
||||
err = ctx.ShouldBind(&req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
code, data := vidser.BatchAuditVidTimeOnlineInfo(req, -1, manager)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// GetTimeOnlineVidList doc
|
||||
// @Summary 获取定时上线视频列表
|
||||
// @Description 根据各种条件获取定时上线视频列表
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param uid formData string true "上传用户uid过滤"
|
||||
// @Param pageNumber formData integer true "查询页码"
|
||||
// @Param pageSize formData integer true "页码大小"
|
||||
// @Success 200 {object} vidmod.ListResp "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} string "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/vid/timeOnline/list [get]
|
||||
func GetTimeOnlineVidList(ctx *gin.Context) {
|
||||
var req = vidtimeonlinemod.ListReq{}
|
||||
err := ctx.ShouldBind(&req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
code, data := vidser.GetTimeOnlineVidList(&req)
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// DeleteVids doc
|
||||
// @Summary 删除准备自动上架视频
|
||||
// @Description 删除准备自动上架视频
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ids formData []string true "记录的id数组"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/vid/timeOnline/del [post]
|
||||
func DelVidTimeOnlines(ctx *gin.Context) {
|
||||
req := vidtimeonlinemod.DeleteReq{}
|
||||
err := ctx.ShouldBind(&req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
ids, err := common.IDArray(req.IDs)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, "")
|
||||
return
|
||||
}
|
||||
code := vidser.DeleteTimeOnlineVid(ids)
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
}
|
||||
|
||||
// EditVidTimeOnlineInfo doc
|
||||
// @Summary 修改自动上架视频信息
|
||||
// @Description 修改自动上架视频信息
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param vidId formData string true "帖子id"
|
||||
// @Param price formData int true "价格"
|
||||
// @Param sectionID formData string false "专题id"
|
||||
// @Param onlineTime formData string false "上架时间"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/vid/timeOnline/edit [post]
|
||||
func EditVidTimeOnlineInfo(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := vidtimeonlinemod.EditReq{}
|
||||
err1 := ctx.ShouldBind(&req)
|
||||
if err1 != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code, data := vidser.BatchAuditVidTimeOnlineInfo(vidtimeonlinemod.BatchAuditReq{
|
||||
Vids: []primitive.ObjectID{req.VidId},
|
||||
SectionID: req.SectionID,
|
||||
OnlineTime: req.OnlineTime,
|
||||
}, req.Price, manager)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// BatchUpdateVidNewsType doc
|
||||
// @Summary 批量修改帖子类型
|
||||
// @Description 批量修改帖子类型
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param q body vidmod.BatchUpdateVidNewsTypeReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/vid/batch/newsType/update [post]
|
||||
func BatchUpdateVidNewsType(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := vidmod.BatchUpdateVidNewsTypeReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
code := vidser.UpdateVidNewsType(req)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoManageList, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, code, code.Msg())
|
||||
}
|
||||
|
||||
// UpdateVidTags doc
|
||||
// @Summary 批量修改视频标签
|
||||
// @Description 批量修改视频标签
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ids formData []string true "批量修改的帖子id"
|
||||
// @Param tags formData []string true "标签名称"
|
||||
// @Param tagSort formData []string true "标签排序"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/vid/batch/update/tags [post]
|
||||
func UpdateVidTags(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := vidmod.EditVideTagsReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code := vidser.UpdateVidTags(req)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoManageList, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, code, code.Msg())
|
||||
}
|
||||
Reference in New Issue
Block a user