Files
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

296 lines
8.3 KiB
Go
Executable File

package mediactrl
import (
"91porn-server/app/service/mediaser"
"91porn-server/common"
"91porn-server/common/log"
"91porn-server/common/stderr"
"91porn-server/models/v/mediamod"
"fmt"
"github.com/gin-gonic/gin"
)
// List doc
//
// @Summary 获取动漫列表列表接口
// @Description 获取动漫列表列表
// @Tags 移动端-动漫列表
// @Accept mpfd,json
// @Produce json
// @Param q query mediaser.AppQueryListReq false "请求参数"
// @Success 200 object mediaser.AppListRes "成功"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/media/list [get]
func List(ctx *gin.Context) {
p := &mediaser.AppQueryListReq{}
if err := ctx.ShouldBind(&p); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, nil)
return
}
// 获取用户当前配置
// var err error
// p.Uid, err = common.GetUID(ctx)
// if err != nil {
// common.ServeJSON(ctx, stderr.ErrNoToken, err)
// return
// }
list := p.GetList()
common.ServeJSON(ctx, stderr.Success, list)
}
// Info doc
// @Summary 获取动漫列表详情接口
// @Description 获取动漫列表详情
// @Tags 移动端-动漫列表
// @Accept mpfd,json
// @Produce json
// @Param q query mediaser.AppQueryInfoReq false "请求参数"
// @Success 200 object mediamod.AppMediaBase "成功"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/media/info [get]
func Info(ctx *gin.Context) {
uid, err := common.GetUID(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.ErrNoToken, err)
return
}
p := &mediaser.AppQueryInfoReq{}
if err := ctx.ShouldBind(&p); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, nil)
return
}
data, err := p.GetInfo(uid)
if err != nil {
common.ServeJSON(ctx, stderr.Failure, err.Error())
return
}
common.ServeJSON(ctx, stderr.Success, data)
}
// Library doc
// @Summary 获取动漫片库接口
// @Description 获取动漫片库详情
// @Tags 移动端-动漫列表
// @Accept mpfd,json
// @Produce json
// @Success 200 object mediamod.AppLibrary "成功"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/media/library [get]
func Library(ctx *gin.Context) {
data, err := mediaser.GetLibrary()
if err != nil {
common.ServeJSON(ctx, stderr.Failure, err.Error())
return
}
common.ServeJSON(ctx, stderr.Success, data)
}
// LibrarySearch doc
// @Summary 动漫片库搜索接口
// @Description 动漫片库搜索详情
// @Tags 移动端-动漫列表
// @Accept mpfd,json
// @Produce json
// @Param q query mediamod.AppLibraryReq false "请求参数"
// @Success 200 object mediamod.AppElasticSearchLibraryResponse "成功"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/media/library/search [post]
func LibrarySearch(ctx *gin.Context) {
req := mediamod.AppLibraryReq{}
if err := ctx.ShouldBind(&req); err != nil {
log.Error(fmt.Sprintf("media librarySearch param err:%v", err))
common.ServeJSON(ctx, stderr.ErrParamError, err)
return
}
data, err := mediaser.LibrarySearch(req)
if err != nil {
common.ServeJSON(ctx, stderr.Failure, err.Error())
return
}
common.ServeJSON(ctx, stderr.Success, data)
}
// Search doc
// @Summary 动漫片库搜索接口
// @Description 动漫片库搜索详情
// @Tags 移动端-动漫列表
// @Accept mpfd,json
// @Produce json
// @Param q query mediamod.AppSearchReq false "请求参数"
// @Success 200 object mediamod.AppElasticSearchResponse "成功"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/media/search [get]
func Search(ctx *gin.Context) {
req := mediamod.AppSearchReq{}
if err := ctx.ShouldBind(&req); err != nil {
log.Error(fmt.Sprintf("media Search param err:%v", err))
common.ServeJSON(ctx, stderr.ErrParamError, err)
return
}
uid, _ := common.GetUID(ctx)
data, err := mediaser.Search(uid, req)
if err != nil {
log.Error(fmt.Sprintf("media Search err:%v", err))
common.ServeJSON(ctx, stderr.Failure, err.Error())
return
}
common.ServeJSON(ctx, stderr.Success, data)
}
// GetTopicList doc
// @Summary 更多-动漫专题列表
// @Description 动漫专题列表
// @Tags 移动端-动漫专题
// @Accept mpfd,json
// @Produce json
// @Param q query mediaser.AppGetTopicReq false "请求参数"
// @Success 200 object mediaser.AppGetTopicRes "成功"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/media/topic [get]
func GetTopicList(ctx *gin.Context) {
uid, err := common.GetUID(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.ErrNoToken, err)
return
}
p := &mediaser.AppGetTopicReq{}
if err := ctx.ShouldBind(&p); err != nil {
log.Error(fmt.Sprintf("GetTopicList param err:%v", err))
common.ServeJSON(ctx, stderr.ErrParamError, nil)
return
}
list, err := p.GetTopicList(uid)
if err != nil {
common.ServeJSON(ctx, stderr.Failure, nil)
return
}
common.ServeJSON(ctx, stderr.Success, list)
}
// Recommend doc
// @Summary 动漫详情-推荐列表
// @Description 动漫详情-推荐列表
// @Tags 移动端-动漫推荐
// @Accept mpfd,json
// @Produce json
// @Param q query mediaser.AppRecommendReq false "请求参数"
// @Success 200 object mediaser.AppRecommendRes "成功"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/media/recommend [get]
func Recommend(ctx *gin.Context) {
uid, err := common.GetUID(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.ErrNoToken, err)
return
}
p := &mediaser.AppRecommendReq{}
if err := ctx.ShouldBind(&p); err != nil {
log.Error(fmt.Sprintf("Recommend param err:%v", err))
common.ServeJSON(ctx, stderr.ErrParamError, nil)
return
}
list, err := p.GetList(uid)
if err != nil {
log.Error(fmt.Sprintf("Recommend GetList err:%v", err))
common.ServeJSON(ctx, stderr.Failure, nil)
return
}
common.ServeJSON(ctx, stderr.Success, list)
}
// Ranking doc
// @Summary 动漫排行榜
// @Description 动漫排行榜
// @Tags 移动端-动漫排行榜
// @Accept mpfd,json
// @Produce json
// @Param q query mediaser.RankingReq false "请求参数"
// @Success 200 object mediaser.RankingResp "成功"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/media/ranking [get]
func Ranking(ctx *gin.Context) {
p := &mediaser.RankingReq{}
if err := ctx.ShouldBind(&p); err != nil {
log.Error(fmt.Sprintf("Rank param err:%v", err))
common.ServeJSON(ctx, stderr.ErrParamError, nil)
return
}
res, err := p.List()
if err != nil {
log.Error(fmt.Sprintf("Get Ranking List err:%v", err))
common.ServeJSON(ctx, stderr.Failure, nil)
return
}
common.ServeJSON(ctx, stderr.Success, res)
}
// Hot doc
// @Summary 热门动漫
// @Description 热门动漫
// @Tags 移动端-动漫
// @Accept mpfd,json
// @Produce json
// @Param q query mediaser.HotReq false "请求参数"
// @Success 200 object mediaser.HotResp "成功"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/media/hot [get]
func Hot(ctx *gin.Context) {
p := &mediaser.HotReq{}
if err := ctx.ShouldBind(&p); err != nil {
log.Error(fmt.Sprintf("Hot param err:%v", err))
common.ServeJSON(ctx, stderr.ErrParamError, nil)
return
}
resp, err := p.List()
if err != nil {
log.Error(fmt.Sprintf("Get Hot Media List err:%v", err))
common.ServeJSON(ctx, stderr.Failure, nil)
return
}
common.ServeJSON(ctx, stderr.Success, resp)
}
// MyBuy doc
// @Summary 我的购买
// @Description 我的购买
// @Tags 移动端-我的购买
// @Accept mpfd,json
// @Produce json
// @Param q query mediaser.MyBuyReq false "请求参数"
// @Success 200 object mediaser.MyBuyResp "成功"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/media/my_buy [get]
func MyBuy(ctx *gin.Context) {
uid, err := common.GetUID(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.ErrNoToken, err)
return
}
p := &mediaser.MyBuyReq{}
if err := ctx.ShouldBind(&p); err != nil {
log.Error(fmt.Sprintf("MyBuy param err:%v", err))
common.ServeJSON(ctx, stderr.ErrParamError, nil)
return
}
resp, err := p.List(uid)
if err != nil {
log.Error(fmt.Sprintf("Get MyBuy Media List err:%v", err))
common.ServeJSON(ctx, stderr.Failure, nil)
return
}
common.ServeJSON(ctx, stderr.Success, resp)
}