@@ -0,0 +1,131 @@
|
||||
package officialWebsitectrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
officialwebsiteser "91porn-server/web/service/officialWebsiteser"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ListVideo(ctx *gin.Context) {
|
||||
req := &officialwebsiteser.VideoListReq{}
|
||||
if err := ctx.ShouldBindQuery(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
total, data, err := officialwebsiteser.ListVideo(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"total": total, "list": data})
|
||||
}
|
||||
|
||||
func CreateVideo(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyVideoReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.CreateVideo(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func UpdateVideo(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyVideoReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.UpdateVideo(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func DeleteVideo(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.DeleteVideoReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.DeleteVideo(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func BatchUpdateVideos(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.BatchUpdateVideoOwnerReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.BatchUpdateVideoOwner(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func BatchImportVideos(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.BatchImportVideoReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.BatchImportVideo(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.OfficialWebsiteImportVideoFailed, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
Reference in New Issue
Block a user