feat: 从黄果 NET hgdjnet-server 9bfbafe 导入 HKDJ 官网后端
来源:hgdjnet-server 9bfbafe10d417deea959bd53117bc88a10e60a83 项目身份 HKDJ / JHA-216,独立官网仓库,Jenkins 守卫键 hkdjnet 测试目录 /server/hkdj_net,App/Web API 30331/30332 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
package web_video
|
||||
|
||||
import (
|
||||
"hkdj-web-server/pub/common"
|
||||
"hkdj-web-server/pub/common/srvdef"
|
||||
"hkdj-web-server/pub/models/videocategorymod"
|
||||
"hkdj-web-server/web/service/srv_videocategory"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 视频分类
|
||||
// @Summary 分组分页获取视频分类
|
||||
// @Description 分组分页获取视频分类
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videocategory.VideoCategoryReq true "参数列表"
|
||||
// @Success 200 {object} srv_videocategory.VideoCategoryResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videocategory/list [POST]
|
||||
func GetVideoCategory(ctx *gin.Context) {
|
||||
var req = &srv_videocategory.VideoCategoryReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
resp, serr := srv_videocategory.GetVideoCategorys(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 视频分类
|
||||
// @Summary 添加一个视频分类
|
||||
// @Description 添加一个视频分类
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body videocategorymod.VideoCategory true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videocategory/add [POST]
|
||||
func AddOneVideoCategory(ctx *gin.Context) {
|
||||
var req = &videocategorymod.VideoCategory{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
serr := srv_videocategory.AddVideoCategory(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 视频分类
|
||||
// @Summary 删除一个视频分类
|
||||
// @Description 删除一个视频分类
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videocategory.VideoCategoryDelReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videocategory/del [POST]
|
||||
func DelOneVideoCategory(ctx *gin.Context) {
|
||||
var req = &srv_videocategory.VideoCategoryDelReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
serr := srv_videocategory.DelVideoCategory(ctx, req.Id)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 视频分类
|
||||
// @Summary 更新一个视频分类
|
||||
// @Description 更新一个视频分类
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videocategory.VideoCategoryUpdateReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videocategory/update [POST]
|
||||
func UpdateOneVideoCategory(ctx *gin.Context) {
|
||||
var req = &srv_videocategory.VideoCategoryUpdateReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
serr := srv_videocategory.UpdateVideoCategory(ctx, req.Id, req.Param)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package web_video
|
||||
|
||||
import (
|
||||
"hkdj-web-server/pub/common"
|
||||
"hkdj-web-server/pub/common/srvdef"
|
||||
"hkdj-web-server/pub/models/videocreatermod"
|
||||
"hkdj-web-server/web/service/srv_videocreater"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 视频作者
|
||||
// @Summary 分组分页获取视频作者
|
||||
// @Description 分组分页获取视频作者
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videocreater.VideoCreaterReq true "参数列表"
|
||||
// @Success 200 {object} srv_videocreater.VideoCreaterResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videocreater/list [POST]
|
||||
func GetVideoCreater(ctx *gin.Context) {
|
||||
var req = &srv_videocreater.VideoCreaterReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
resp, serr := srv_videocreater.GetVideoCreaters(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 视频作者
|
||||
// @Summary 添加一个视频作者
|
||||
// @Description 添加一个视频作者
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body videocreatermod.VideoCreaterInfo true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videocreater/add [POST]
|
||||
func AddOneVideoCreater(ctx *gin.Context) {
|
||||
var req = &videocreatermod.VideoCreaterInfo{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
serr := srv_videocreater.AddVideoCreater(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 视频作者
|
||||
// @Summary 删除一个视频作者
|
||||
// @Description 删除一个视频作者
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videocreater.VideoCreaterDelReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videocreater/del [POST]
|
||||
func DelOneVideoCreater(ctx *gin.Context) {
|
||||
var req = &srv_videocreater.VideoCreaterDelReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
serr := srv_videocreater.DelVideoCreater(ctx, req.Id)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 视频作者
|
||||
// @Summary 更新一个视频作者
|
||||
// @Description 更新一个视频作者
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videocreater.VideoCreaterUpdateReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videocreater/update [POST]
|
||||
func UpdateOneVideoCreater(ctx *gin.Context) {
|
||||
var req = &srv_videocreater.VideoCreaterUpdateReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
serr := srv_videocreater.UpdateVideoCreater(ctx, req.Id, req.Param)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package web_video
|
||||
|
||||
import (
|
||||
"hkdj-web-server/pub/common"
|
||||
"hkdj-web-server/pub/common/srvdef"
|
||||
"hkdj-web-server/web/service/srv_videotag"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 标签管理
|
||||
// @Summary 查询播放量最多的标签
|
||||
// @Description 根据视频累计播放量聚合返回热门标签列表
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param limit query int false "返回条数,默认10,最大1000"
|
||||
// @Success 200 {object} srv_videotag.HotTagResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Router /wbapi/hgdjnet/hottag [GET]
|
||||
func GetVideoPlayData(ctx *gin.Context) {
|
||||
var req = &srv_videotag.HotTagReq{}
|
||||
if err := ctx.ShouldBindQuery(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
resp, serr := srv_videotag.GetHotTagsByPlayData(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 标签管理
|
||||
// @Summary 查询今日和昨日 IP 去重统计
|
||||
// @Description 返回 app 端同步到 MongoDB 的每日访问 IP 去重数
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} srv_videotag.IpStatResp "成功"
|
||||
// @Router /wbapi/hgdjnet/ipstat [GET]
|
||||
func GetIpStatData(ctx *gin.Context) {
|
||||
resp := srv_videotag.FetchIpStat(ctx)
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package web_video
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"hkdj-web-server/pub/common"
|
||||
"hkdj-web-server/pub/common/m3u8"
|
||||
"hkdj-web-server/pub/common/srvdef"
|
||||
"hkdj-web-server/pub/models/cfg"
|
||||
"hkdj-web-server/web/webg"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type fileHandler func(ctx *gin.Context) (contentLength int64, contentType string, reader io.Reader, extraHeaders map[string]string, err error)
|
||||
|
||||
func Play(ctx *gin.Context) {
|
||||
fn := func(c *gin.Context) (contentLength int64, contentType string, reader io.Reader, extraHeaders map[string]string, err error) {
|
||||
m3u8Name := ctx.Param("key")
|
||||
|
||||
var req m3u8.Req
|
||||
if err = ctx.BindQuery(&req); err != nil {
|
||||
return
|
||||
}
|
||||
req.Name = m3u8Name
|
||||
cfgSys, _ := cfg.FindOneSysCfg(ctx, bson.M{})
|
||||
cdnDomain := webg.Conf.CdnDomain
|
||||
if cfgSys != nil {
|
||||
cdnDomain = cfgSys.MediaWebCdn
|
||||
}
|
||||
origDomain := webg.Conf.OrigDomain
|
||||
useNewKey := ctx.Query("useNewKey") == "1" || ctx.Query("newKey") == "1"
|
||||
var buff *bytes.Buffer
|
||||
if useNewKey {
|
||||
// 短剧原片:不追加媒资版本前缀,并使用 conf/newm3u8.key
|
||||
_, buff, err = m3u8.TransformExOriginalPath(req.Name, cdnDomain, origDomain, 3, webg.Conf.TsAuthKey, webg.Conf.LsjMediaConf.M3u8Yuan, "", "/api/web/newenkey")
|
||||
} else {
|
||||
_, buff, err = m3u8.TransFormWithSafely(&req, cdnDomain, origDomain, true, webg.Conf.TsAuthKey, webg.Conf.LsjMediaConf.M3u8Yuan, "")
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
contentType = "application/vnd.apple.mpegurl"
|
||||
reader = bytes.NewReader(buff.Bytes())
|
||||
contentLength = int64(buff.Len())
|
||||
extraHeaders = map[string]string{}
|
||||
return
|
||||
}
|
||||
|
||||
handlerFile(ctx, fn)
|
||||
}
|
||||
|
||||
func Enkey(ctx *gin.Context) {
|
||||
fn := func(c *gin.Context) (contentLength int64, contentType string, reader io.Reader, extraHeaders map[string]string, err error) {
|
||||
buffer, err := m3u8.Enkey(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
contentLength = int64(buffer.Len())
|
||||
contentType = "application/octet-stream"
|
||||
reader = buffer
|
||||
extraHeaders = map[string]string{}
|
||||
return
|
||||
}
|
||||
handlerFile(ctx, fn)
|
||||
}
|
||||
|
||||
// NewEnkey 返回短剧原片使用的新 M3U8 解密密钥(conf/newm3u8.key)。
|
||||
func NewEnkey(ctx *gin.Context) {
|
||||
fn := func(c *gin.Context) (contentLength int64, contentType string, reader io.Reader, extraHeaders map[string]string, err error) {
|
||||
buffer, err := m3u8.NewEnkey(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
contentLength = int64(buffer.Len())
|
||||
contentType = "application/octet-stream"
|
||||
reader = buffer
|
||||
extraHeaders = map[string]string{}
|
||||
return
|
||||
}
|
||||
handlerFile(ctx, fn)
|
||||
}
|
||||
|
||||
// TranscodeM3u8 转码专用 m3u8 接口(不鉴权)。
|
||||
func TranscodeM3u8(ctx *gin.Context) {
|
||||
fn := func(c *gin.Context) (contentLength int64, contentType string, reader io.Reader, extraHeaders map[string]string, err error) {
|
||||
name := ctx.Param("key")
|
||||
_, buff, err := m3u8.TransformForTranscode(name, webg.Conf.OrigDomain, webg.Conf.CdnDomain, webg.Conf.WebM3u8Host, webg.Conf.LsjMediaConf.M3u8Yuan, webg.Conf.LsjMediaConf.TsYuan)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
contentType = "application/vnd.apple.mpegurl"
|
||||
reader = bytes.NewReader(buff.Bytes())
|
||||
contentLength = int64(buff.Len())
|
||||
extraHeaders = map[string]string{}
|
||||
return
|
||||
}
|
||||
handlerFile(ctx, fn)
|
||||
}
|
||||
|
||||
func LsjEnkey(ctx *gin.Context) {
|
||||
fn := func(c *gin.Context) (contentLength int64, contentType string, reader io.Reader, extraHeaders map[string]string, err error) {
|
||||
buffer, err := m3u8.LsjEnkey(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
contentLength = int64(buffer.Len())
|
||||
contentType = "application/octet-stream"
|
||||
reader = buffer
|
||||
extraHeaders = map[string]string{}
|
||||
return
|
||||
}
|
||||
handlerFile(ctx, fn)
|
||||
}
|
||||
|
||||
func handlerFile(ctx *gin.Context, h fileHandler) {
|
||||
contentLength, contentType, reader, extraHeaders, err := h(ctx)
|
||||
if err != nil {
|
||||
common.ServerJSON(ctx, srvdef.DownloadM3u8File, err)
|
||||
return
|
||||
}
|
||||
ctx.DataFromReader(http.StatusOK, contentLength, contentType, reader, extraHeaders)
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package web_video
|
||||
|
||||
import (
|
||||
"hkdj-web-server/pub/common"
|
||||
"hkdj-web-server/pub/common/srvdef"
|
||||
"hkdj-web-server/pub/models/videotagmod"
|
||||
"hkdj-web-server/web/service/srv_videotag"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 标签管理
|
||||
// @Summary 分组分页获取标签管理
|
||||
// @Description 分组分页获取标签管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videotag.VideoTagInfoReq true "参数列表"
|
||||
// @Success 200 {object} srv_videotag.VideoTagInfoResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videotag/list [POST]
|
||||
func GetVideoTagInfo(ctx *gin.Context) {
|
||||
var req = &srv_videotag.VideoTagInfoReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
resp, serr := srv_videotag.GetVideoTagInfos(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 标签管理
|
||||
// @Summary 添加一个标签管理
|
||||
// @Description 添加一个标签管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body videotagmod.VideoTagInfo true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videotag/add [POST]
|
||||
func AddOneVideoTagInfo(ctx *gin.Context) {
|
||||
var req = &videotagmod.VideoTagInfo{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
serr := srv_videotag.AddVideoTagInfo(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 标签管理
|
||||
// @Summary 删除一个标签管理
|
||||
// @Description 删除一个标签管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videotag.VideoTagInfoDelReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videotag/del [POST]
|
||||
func DelOneVideoTagInfo(ctx *gin.Context) {
|
||||
var req = &srv_videotag.VideoTagInfoDelReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
serr := srv_videotag.DelVideoTagInfo(ctx, req.Id)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 标签管理
|
||||
// @Summary 更新一个标签管理
|
||||
// @Description 更新一个标签管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videotag.VideoTagInfoUpdateReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videotag/update [POST]
|
||||
func UpdateOneVideoTagInfo(ctx *gin.Context) {
|
||||
var req = &srv_videotag.VideoTagInfoUpdateReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
serr := srv_videotag.UpdateVideoTagInfo(ctx, req.Id, req.Param)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package web_video
|
||||
|
||||
import (
|
||||
"hkdj-web-server/pub/common"
|
||||
"hkdj-web-server/pub/common/srvdef"
|
||||
"hkdj-web-server/pub/models/videotopicmod"
|
||||
"hkdj-web-server/web/service/srv_videotopic"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 视频专题
|
||||
// @Summary 分组分页获取视频专题
|
||||
// @Description 分组分页获取视频专题
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videotopic.VideoTopicReq true "参数列表"
|
||||
// @Success 200 {object} srv_videotopic.VideoTopicResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videotopic/list [POST]
|
||||
func GetVideoTopic(ctx *gin.Context) {
|
||||
var req = &srv_videotopic.VideoTopicReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
resp, serr := srv_videotopic.GetVideoTopics(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 视频专题
|
||||
// @Summary 添加一个视频专题
|
||||
// @Description 添加一个视频专题
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body videotopicmod.VideoTopicModel true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videotopic/add [POST]
|
||||
func AddOneVideoTopic(ctx *gin.Context) {
|
||||
var req = &videotopicmod.VideoTopicModel{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
serr := srv_videotopic.AddVideoTopic(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 视频专题
|
||||
// @Summary 删除一个视频专题
|
||||
// @Description 删除一个视频专题
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videotopic.VideoTopicDelReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videotopic/del [POST]
|
||||
func DelOneVideoTopic(ctx *gin.Context) {
|
||||
var req = &srv_videotopic.VideoTopicDelReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
serr := srv_videotopic.DelVideoTopic(ctx, req.Id)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 视频专题
|
||||
// @Summary 更新一个视频专题
|
||||
// @Description 更新一个视频专题
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videotopic.VideoTopicUpdateReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videotopic/update [POST]
|
||||
func UpdateOneVideoTopic(ctx *gin.Context) {
|
||||
var req = &srv_videotopic.VideoTopicUpdateReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
serr := srv_videotopic.UpdateVideoTopic(ctx, req.Id, req.Param)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
package web_video
|
||||
|
||||
import (
|
||||
"hkdj-web-server/pub/common"
|
||||
"hkdj-web-server/pub/common/srvdef"
|
||||
"hkdj-web-server/web/api/proto"
|
||||
"hkdj-web-server/web/middleware/auth"
|
||||
"hkdj-web-server/web/service/srv_videoinfo"
|
||||
"hkdj-web-server/web/service/srv_videoslug"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 视频管理
|
||||
// @Summary 分组分页获取视频管理
|
||||
// @Description 分组分页获取视频管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.VideoInfoReq true "参数列表"
|
||||
// @Success 200 {object} srv_videoinfo.VideoInfoResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/list [POST]
|
||||
func GetVideoInfo(ctx *gin.Context) {
|
||||
var req = &srv_videoinfo.VideoInfoReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
resp, serr := srv_videoinfo.GetVideoInfos(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 视频管理
|
||||
// @Summary 从切片列表同步多个视频
|
||||
// @Description 从切片列表同步多个视频
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.AddVideoReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/sync [POST]
|
||||
func SyncVideoInfo(ctx *gin.Context) {
|
||||
var req = &srv_videoinfo.AddVideoReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
serr := srv_videoinfo.SyncVideoInfo(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 视频管理
|
||||
// @Summary 删除一个视频管理
|
||||
// @Description 删除一个视频管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.VideoInfoDelReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/del [POST]
|
||||
func DelOneVideoInfo(ctx *gin.Context) {
|
||||
var req = &srv_videoinfo.VideoInfoDelReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
serr := srv_videoinfo.DelVideoInfo(ctx, req.Id)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 视频管理
|
||||
// @Summary 更新一个视频管理
|
||||
// @Description 更新一个视频管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.VideoInfoUpdateReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/update [POST]
|
||||
func UpdateOneVideoInfo(ctx *gin.Context) {
|
||||
var req = &srv_videoinfo.VideoInfoUpdateReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
userId := ctx.GetInt64(auth.AccId)
|
||||
ua, _ := common.GetUA(ctx)
|
||||
serr := srv_videoinfo.UpdateVideoInfo(ctx, req.Id, userId, req.Param, ua)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 视频管理
|
||||
// @Summary 新增一个视频合集
|
||||
// @Description 新增一个视频合集
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.AddVideoCollectionReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/addcoll [POST]
|
||||
func AddOneVideoCollection(ctx *gin.Context) {
|
||||
var req = &srv_videoinfo.AddVideoCollectionReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
serr := srv_videoinfo.AddVideoCollection(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// SetVideoFakeWatchTimes 单/批量设置视频假观看次数
|
||||
// @Tags 视频管理
|
||||
// @Summary 单/批量设置视频假观看次数 --by 旺鸣
|
||||
// @Description 根据ids批量随机设置视频假观看次数
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.SetFakeWatchTimesReq true "参数列表"
|
||||
// @Success 200 {object} srv_videoinfo.SetFakeCountResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/setFakeWatchTimes [post]
|
||||
func SetVideoFakeWatchTimes(ctx *gin.Context) {
|
||||
req := &srv_videoinfo.SetFakeWatchTimesReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := srv_videoinfo.SetVideoFakeWatchTimes(ctx, req)
|
||||
if err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// SetCategory web端单/批量设置视频分类
|
||||
// @Tags 视频管理
|
||||
// @Summary web端单/批量设置视频分类
|
||||
// @Description 根据视频ID集合批量更新 video_information 集合 categoryIds 字段,传1个ID表示单条设置,传多个ID表示批量设置;categoryIds 可为空,不传或空数组表示清空分类
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.SetVideoCategoryReq true "单/批量设置视频分类请求"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/category/set [post]
|
||||
func SetCategory(ctx *gin.Context) {
|
||||
var req srv_videoinfo.SetVideoCategoryReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if err := srv_videoinfo.SetVideoCategory(ctx, &req); err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
type TranscodeVideoReq struct {
|
||||
Id int64 `json:"id" binding:"required"`
|
||||
}
|
||||
|
||||
// @Tags 视频管理
|
||||
// @Summary 提交视频 H265 转码
|
||||
// @Router /api/web/videoinfo/transcode [POST]
|
||||
func TranscodeVideo(ctx *gin.Context) {
|
||||
var req TranscodeVideoReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if serr := srv_videoinfo.TranscodeVideo(ctx, req.Id); serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, nil)
|
||||
}
|
||||
|
||||
// SyncSlug web端同步视频相关历史空 slug
|
||||
// @Tags 视频管理
|
||||
// @Summary 同步历史空 slug
|
||||
// @Description 为分类、标签、题材、作者、视频中空的 slug 按 SEO 关键词或名称自动生成。可重复调用,hasMore 为 true 时继续请求。
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.VideoSlugSyncReq false "同步参数"
|
||||
// @Success 200 {object} proto.VideoSlugSyncResp "成功"
|
||||
// @Failure 400 {string} string "参数错误"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/slug/sync [POST]
|
||||
func SyncSlug(ctx *gin.Context) {
|
||||
var req proto.VideoSlugSyncReq
|
||||
if ctx.Request.ContentLength > 0 {
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
}
|
||||
resp, serr := srv_videoslug.SyncEmptySlugs(ctx, &req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
Reference in New Issue
Block a user