Files
huangguo_server/app/api/aiplazactrl/aiplaza.go
T
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

117 lines
3.1 KiB
Go
Executable File

package aiplazactrl
import (
"91porn-server/app/service/aiplazaser"
"91porn-server/app/service/m3u8ticket"
"91porn-server/common"
"91porn-server/common/stderr"
"github.com/gin-gonic/gin"
)
// List doc
//
// @Summary 获取ai广场帖子列表接口
// @Description 获取ai广场帖子列表
// @Tags 移动端-ai广场帖子
// @Accept mpfd,json
// @Produce json
// @Param q query aiplazaser.AppQueryListReq false "请求参数"
// @Success 200 object aiplazaser.AppListRes "成功"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/aiplaza/list [get]
func List(ctx *gin.Context) {
p := &aiplazaser.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()
uid := common.TryGetUID(ctx)
for i := range list.List {
if list.List[i] == nil {
continue
}
m3u8ticket.SignURL(ctx, uid, &list.List[i].OriginalVideo, true, false)
m3u8ticket.SignURL(ctx, uid, &list.List[i].GenerateVideo, true, false)
}
common.ServeJSON(ctx, stderr.Success, list)
}
// Info doc
//
// @Summary 获取ai广场帖子详情接口
// @Description 获取ai广场帖子详情
// @Tags 移动端-ai广场帖子
// @Accept mpfd,json
// @Produce json
// @Param q query aiplazaser.AppQueryInfoReq false "请求参数"
// @Success 200 object aiplazaser.AppQueryInfoResp "成功"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/aiplaza/info [get]
func Info(ctx *gin.Context) {
p := &aiplazaser.AppQueryInfoReq{}
if err := ctx.ShouldBind(&p); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, nil)
return
}
// 获取用户当前配置
var err error
uid, err := common.GetUID(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.ErrNoToken, err)
return
}
data, err := p.GetInfo(uid)
if err != nil {
common.ServeJSON(ctx, stderr.Failure, err.Error())
return
}
if data.Detail != nil {
m3u8ticket.SignURL(ctx, uid, &data.Detail.OriginalVideo, true, false)
m3u8ticket.SignURL(ctx, uid, &data.Detail.GenerateVideo, true, false)
}
common.ServeJSON(ctx, stderr.Success, data)
}
// Share doc
// @Summary 分享ai记录到ai广场
// @Description 分享ai记录到ai广场
// @Tags 移动端-ai广场帖子
// @Accept mpfd,json
// @Produce json
// @Param q body aiplazaser.ShareReq false "请求参数"
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/aiplaza/share [post]
func Share(ctx *gin.Context) {
uid, err := common.GetUID(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.ErrNoToken, err)
return
}
p := &aiplazaser.ShareReq{}
err = ctx.ShouldBindJSON(&p)
if err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
return
}
// 创建
err = p.Create(uid)
if err != nil {
common.ServeJSON(ctx, stderr.Failure, err.Error())
return
}
common.ServeJSON(ctx, stderr.Success, "")
}