@@ -0,0 +1,54 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"videoweb/app/service/playletser"
|
||||
"videoweb/pub/common/log"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// ChapterList 代理上游短剧选集列表接口。
|
||||
func ChapterList(c *gin.Context) {
|
||||
playletID, _ := strconv.ParseInt(c.Query("playletId"), 10, 64)
|
||||
playletSlug := strings.TrimSpace(c.Query("playletSlug"))
|
||||
if playletSlug == "" && playletID <= 0 {
|
||||
c.JSON(http.StatusOK, gin.H{"code": 1001, "msg": "参数错误", "tip": "缺少 playletSlug 或 playletId", "data": nil})
|
||||
return
|
||||
}
|
||||
data, err := playletser.FetchChapterList(c, playletID, playletSlug)
|
||||
if err != nil {
|
||||
log.Error("chapter list upstream failed", log.E(err))
|
||||
c.JSON(http.StatusOK, gin.H{"code": 500, "msg": "chapter list failed", "tip": "获取选集失败,请稍后重试", "data": nil})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"code": 200, "msg": "success", "tip": "成功", "data": data})
|
||||
}
|
||||
|
||||
// OperateList 代理上游运营位短剧列表接口。
|
||||
func OperateList(c *gin.Context) {
|
||||
q := playletser.OperateListQuery{
|
||||
OperateType: parsePositiveInt(c.Query("operateType")),
|
||||
FilterType: parsePositiveInt(c.Query("filterType")),
|
||||
PageNum: parsePositiveInt(c.Query("pageNum")),
|
||||
PageSize: parsePositiveInt(c.Query("pageSize")),
|
||||
}
|
||||
q.Normalize()
|
||||
data, err := playletser.FetchOperateList(c, q)
|
||||
if err != nil {
|
||||
log.Error("operate list upstream failed", log.E(err))
|
||||
c.JSON(http.StatusOK, gin.H{"code": 500, "msg": "operate list failed", "tip": "获取运营短剧失败,请稍后重试", "data": nil})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"code": 200, "msg": "success", "tip": "成功", "data": data})
|
||||
}
|
||||
|
||||
func parsePositiveInt(raw string) int {
|
||||
n, err := strconv.Atoi(strings.TrimSpace(raw))
|
||||
if err != nil || n <= 0 {
|
||||
return 0
|
||||
}
|
||||
return n
|
||||
}
|
||||
Reference in New Issue
Block a user