mirror of
https://github.com/ProudMuBai/GoFilm.git
synced 2026-02-12 21:14:41 +08:00
ABS v1 test
This commit is contained in:
@@ -18,10 +18,7 @@ const (
|
||||
func Index(c *gin.Context) {
|
||||
// 获取首页所需数据
|
||||
data := logic.IL.IndexPage()
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"data": data,
|
||||
})
|
||||
system.Success(data, "首页数据获取成功", c)
|
||||
}
|
||||
|
||||
// CategoriesInfo 分类信息获取
|
||||
@@ -47,54 +44,50 @@ func FilmDetail(c *gin.Context) {
|
||||
// 获取请求参数
|
||||
id, err := strconv.Atoi(c.Query("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "请求异常,暂无影片信息!!!",
|
||||
})
|
||||
system.Failed("请求异常,影片请求参数异常!!!", c)
|
||||
return
|
||||
}
|
||||
// 获取影片详情信息
|
||||
detail := logic.IL.GetFilmDetail(id)
|
||||
// 获取相关推荐影片数据
|
||||
page := system.Page{Current: 0, PageSize: 14}
|
||||
relateMovie := logic.IL.RelateMovie(detail, &page)
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"data": gin.H{
|
||||
"detail": detail,
|
||||
"relate": relateMovie,
|
||||
},
|
||||
})
|
||||
relateMovie := logic.IL.RelateMovie(detail.MovieDetail, &page)
|
||||
system.Success(gin.H{
|
||||
"detail": detail,
|
||||
"relate": relateMovie,
|
||||
}, "影片详情信息获取成功", c)
|
||||
}
|
||||
|
||||
// FilmPlayInfo 影视播放页数据
|
||||
func FilmPlayInfo(c *gin.Context) {
|
||||
// 获取请求参数
|
||||
id, err := strconv.Atoi(c.DefaultQuery("id", "0"))
|
||||
playFrom, err := strconv.Atoi(c.DefaultQuery("playFrom", "0"))
|
||||
playFrom := c.DefaultQuery("playFrom", "")
|
||||
episode, err := strconv.Atoi(c.DefaultQuery("episode", "0"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "请求异常,暂无影片信息!!!",
|
||||
})
|
||||
system.Failed("请求异常,暂无影片信息!!!", c)
|
||||
return
|
||||
}
|
||||
// 获取影片详情信息
|
||||
detail := logic.IL.GetFilmDetail(id)
|
||||
// 获取当前影片播放信息
|
||||
var currentPlay system.MovieUrlInfo
|
||||
for _, v := range detail.List {
|
||||
if v.Id == playFrom {
|
||||
currentPlay = v.LinkList[episode]
|
||||
}
|
||||
}
|
||||
|
||||
// 推荐影片信息
|
||||
page := system.Page{Current: 0, PageSize: 14}
|
||||
relateMovie := logic.IL.RelateMovie(detail, &page)
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"data": gin.H{
|
||||
"detail": detail,
|
||||
"current": detail.PlayList[playFrom][episode],
|
||||
"currentPlayFrom": playFrom,
|
||||
"currentEpisode": episode,
|
||||
"relate": relateMovie,
|
||||
},
|
||||
})
|
||||
relateMovie := logic.IL.RelateMovie(detail.MovieDetail, &page)
|
||||
system.Success(gin.H{
|
||||
"detail": detail,
|
||||
"current": currentPlay,
|
||||
"currentPlayFrom": playFrom,
|
||||
"currentEpisode": episode,
|
||||
"relate": relateMovie,
|
||||
}, "影片播放信息获取成功", c)
|
||||
}
|
||||
|
||||
// SearchFilm 通过片名模糊匹配库存中的信息
|
||||
@@ -187,53 +180,3 @@ func FilmClassify(c *gin.Context) {
|
||||
"page": page,
|
||||
})
|
||||
}
|
||||
|
||||
// FilmCategory 获取指定分类的影片分页数据,(已弃用)
|
||||
func FilmCategory(c *gin.Context) {
|
||||
// 1.1 首先获取Cid 二级分类id是否存在
|
||||
cidStr := c.DefaultQuery("cid", "")
|
||||
// 1.2 如果pid也不存在直接返回错误信息
|
||||
pidStr := c.DefaultQuery("pid", "")
|
||||
if pidStr == "" {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "缺少分类信息",
|
||||
})
|
||||
return
|
||||
}
|
||||
// 1.3 获取pid对应的分类信息
|
||||
pid, _ := strconv.ParseInt(pidStr, 10, 64)
|
||||
category := logic.IL.GetPidCategory(pid)
|
||||
|
||||
// 2 设置分页信息
|
||||
currentStr := c.DefaultQuery("current", "1")
|
||||
current, _ := strconv.Atoi(currentStr)
|
||||
page := system.Page{PageSize: 49, Current: current}
|
||||
// 2.1 如果不存在cid则根据Pid进行查询
|
||||
if cidStr == "" {
|
||||
// 2.2 如果存在pid则根据pid进行查找
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"data": gin.H{
|
||||
"list": logic.IL.GetFilmCategory(pid, "pid", &page),
|
||||
"category": category,
|
||||
"search": logic.IL.SearchTags(pid),
|
||||
},
|
||||
"page": page,
|
||||
})
|
||||
return
|
||||
}
|
||||
// 2.2 如果存在cid 则根据具体的cid去查询数据
|
||||
cid, _ := strconv.ParseInt(cidStr, 10, 64)
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"data": gin.H{
|
||||
"list": logic.IL.GetFilmCategory(cid, "cid", &page),
|
||||
"category": category,
|
||||
"search": logic.IL.SearchTags(pid),
|
||||
},
|
||||
"page": page,
|
||||
})
|
||||
|
||||
// 获取请求参数
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user