Files
huangguo_server/app/api/mediabookshelfctrl/mediabookshelf.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

146 lines
3.9 KiB
Go
Executable File

package mediabookshelfctrl
import (
"91porn-server/app/service/mediabookshelfser"
"91porn-server/common"
"91porn-server/common/stderr"
"github.com/gin-gonic/gin"
)
// List doc
// @Summary 获取媒体书架列表接口
// @Description 获取媒体书架列表
// @Tags 移动端-媒体书架列表
// @Accept mpfd,json
// @Produce json
// @Param q query mediabookshelfser.AppQueryListReq false "请求参数"
// @Success 200 object mediabookshelfser.AppListRes "成功"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/media_bookshelf/list [get]
func List(ctx *gin.Context) {
uid, err := common.GetUID(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.ErrNoToken, err)
return
}
p := &mediabookshelfser.AppQueryListReq{}
if err := ctx.ShouldBind(&p); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, nil)
return
}
list, err := p.GetList(uid)
if err != nil {
common.ServeJSON(ctx, stderr.ErrDbQueryError, nil)
return
}
common.ServeJSON(ctx, stderr.Success, list)
}
// Add doc
// @Summary 添加媒体进入书架接口
// @Description 添加媒体进入书架
// @Tags 移动端-媒体书架列表
// @Accept mpfd,json
// @Produce json
// @Param q query mediabookshelfser.AppAddBookshelfReq false "请求参数"
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/media_bookshelf/add [post]
func Add(ctx *gin.Context) {
uid, err := common.GetUID(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.ErrNoToken, err)
return
}
p := &mediabookshelfser.AppAddBookshelfReq{}
if err := ctx.ShouldBind(&p); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, nil)
return
}
ua, err := common.GetUA(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.Failure, err.Error())
return
}
ip := common.GetIP(ctx)
err = p.Add(uid, ua, ip)
if err != nil {
common.ServeJSON(ctx, stderr.Failure, err.Error())
return
}
common.ServeJSON(ctx, stderr.Success, stderr.Success.Msg())
}
// Del doc
// @Summary 删除书架中媒体接口
// @Description 删除书架中媒体
// @Tags 移动端-媒体书架列表
// @Accept mpfd,json
// @Produce json
// @Param q query mediabookshelfser.AppDelBookshelfReq false "请求参数"
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/media_bookshelf/del [post]
func Del(ctx *gin.Context) {
uid, err := common.GetUID(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.ErrNoToken, err)
return
}
p := &mediabookshelfser.AppDelBookshelfReq{}
if err := ctx.ShouldBind(&p); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, nil)
return
}
ua, err := common.GetUA(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.Failure, err.Error())
return
}
ip := common.GetIP(ctx)
err = p.Del(uid, ua, ip)
if err != nil {
common.ServeJSON(ctx, stderr.Failure, err.Error())
return
}
common.ServeJSON(ctx, stderr.Success, stderr.Success.Msg())
}
// DelBatch doc
// @Summary 批量删除书架中媒体接口
// @Description 批量删除书架中媒体
// @Tags 移动端-媒体书架列表
// @Accept mpfd,json
// @Produce json
// @Param q query mediabookshelfser.AppDelBatchBookshelfReq false "请求参数"
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/media_bookshelf/del/batch [post]
func DelBatch(ctx *gin.Context) {
uid, err := common.GetUID(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.ErrNoToken, err)
return
}
p := &mediabookshelfser.AppDelBatchBookshelfReq{}
if err := ctx.ShouldBind(&p); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, nil)
return
}
err = p.Del(uid)
if err != nil {
common.ServeJSON(ctx, stderr.Failure, err.Error())
return
}
common.ServeJSON(ctx, stderr.Success, stderr.Success.Msg())
}