fix change password dialog, add api readme

This commit is contained in:
mubai
2024-01-25 21:13:15 +08:00
parent 31955638a5
commit f1c757863f
25 changed files with 1071 additions and 139 deletions

View File

@@ -152,3 +152,474 @@ server
DB: 0 ##使用的redis数据库为0号库
```
## 服务端API数据示例
### 1. 网站前台API
#### 1. API接口基本信息
- 响应结构
```json
{
code: 0|1, // 成功|失败
data: {}, // 数据内容
msg: "", // 提示信息
}
```
| 名称 | URL | client component | Method | Params |
| ------------------ | :------------------ | --------------------------------------------- | ------ | ------------------------------------------------------------ |
| 首页数据 | /index | client/src/views/index/Home.vue | GET | 无 |
| 网站基本配置信息 | /config/basic | client/src/components/index/Header.vue | GET | 无 |
| 影片分类导航 | /navCategory | client/src/components/index/Header.vue | GET | 无 |
| 影片详情 | /filmDetail | client/src/views/index/FilmDetails.vue | GET | id (int, 影片ID) |
| 影片播放页数据 | /filmPlayInfo | client/src/views/index/Play.vue | GET | id (int, 影片ID) <br>playFrom (string, 播放源ID)<br>episode (int, 集数索引) |
| 影片检索(名称搜索) | /searchFilm | client/src/views/index/SearchFilm.vue | GET | keyword (string, 影片名) |
| 影片分类首页 | /filmClassify | client/src/views/index/FilmClassify.vue | GET | Pid (int, 一级分类ID) |
| 影片分类详情页 | /filmClassidySearch | client/src/views/index/FilmClassifySearch.vue | GET | Pid (int, 一级分类ID)<br>Category (int, 二级分类ID)<br>Plot (string, 剧情)<br>Area (string, 地区)<br>Language (string, 语言)<br>Year (string, 年份)<br>Sort (string, 排序方式) |
#### 2. 接口响应数据示例:
- `/index` 首页数据
```json
{
"code": 0, // 状态码
"data": {
"category": { // 分类信息
"id": 0, // 分类ID
"name": "分类信息", // 分类名称
"pid": 0, // 上级分类ID
"show": false, // 是否展示
"children": [], // 子分类信息
},
"content": [
{
"hot": [ // 热播影片
{
"CreatedAt": "2024-01-13T19:04:01+08:00", // 创建时间
"DeletedAt": null, // 删除时间
"ID": 100, // ID
"UpdatedAt": "2024-01-13T19:04:01+08:00", // 更新时间
"area": "大陆", // 地区
"cName": "预告片", // 分类名称
"cid": 45, // 分类ID
"classTag": "剧情", // 剧情标签
"hits": 0, // 热度
"initial": "W", // 首字母
"language": "国语", // 语言
"mid": 10000, // 影片ID
"name": "xxx", // 影片名称
"pid": 1, // 上级分类ID
"releaseStamp": 1704880403, // 上映时间戳
"remarks": "预告片", // 备注信息 [预告|完结|更新至xx集]
"score": 0, // 评分
"state": "正片", // 状态
"subTitle": "xxx", // 子标题, 别名
"updateStamp": 1704880403, // 更新时间戳
"year": 2024, // 年份
}
],
"movies": [ // 近期更新影片
{
"id": 10000, // 影片ID
"cid": 6, // 分类ID
"pid": 1, // 上级分类ID
"name": "xxxx", // 影片名称
"subTitle": "xxxx", // 子标题, 别名
"cName": "xxx", // 分类名称
"state": "正片", // 影片状态
"picture": "http://xxxx.jpg", // 海报图片url
"actor": "xxx,xxx", // 演员
"director": "xxx,xxx", // 导演
"blurb": "", // 剧情简介
"remarks": "HD", // 备注信息 [预告|完结|更新至xx集]
"area": "大陆", // 地区
"year": "2024" // 年份
}
],
"nav": [ // 导航信息
{
"id": 0, // 分类ID
"name": "分类信息", // 分类名称
"pid": 0, //上级分类ID
"show": false, // 是否展示
"children": [], //子分类信息
}
]
},
]
},
msg: "", // 提示信息
}
```
- `/config/basic` 网站基本配置信息
```json
{
"code": 0,
"data": {
"siteName": "GoFilm", // 网站名称
"domain": "http://127.0.0.1:3600", // 域名
"logo": "https://xxx.jpg", // 网站logo
"keyword": "xxxx, xxxx", // 网站搜索关键字
"describe": "xxxxxxx", // 网站描述信息
"state": true, //站点状态
"hint": "网站升级中, 暂时无法访问 !!!" // 网站关闭时提示信息
},
"msg": ""
}
```
- `/navCategory` 首页头部分类信息
```json
{
"code": 0,
"data": [
{
"id": 0, // 分类ID
"name": "分类信息", // 分类名称
"pid": 0, // 上级分类ID
"show": false, // 是否展示
},
],
"msg": ""
}
```
- ` /filmDetail` 影片详情信息
```json
{
"code": 0,
"data": {
"detail": { // 影片详情信息
"id": 100000, // 影片ID
"cid": 30, // 影片分类ID
"pid": 4, // 上级分类ID
"name": "xxx", // 影片名称
"picture": "https://xxx.jpg", // 海报封面url
"playFrom": [ "xxx","xxx" ], // 播放来源
"DownFrom": "http", // 下载方式
"playList": [ // 播放地址列表(主站点)
{
"episode": "第xx集", // 集数
"link": "https://xxx/index.m3u8" // 播放地址url
},
],
"downloadList": [ // 下载地址列表
{
"episode": "第xx集", // 集数
"link": "https://xxx/index.m3u8" // 播放地址url
},
],
"descriptor": { // 影片详情
"subTitle": "", // 副标题, 别名
"cName": "xxxx", // 分类名称
"enName": "xxx", // 影片名称中文拼音
"initial": "X", // 影片名称首字母
"classTag": "xxxx", // 内容标签
"actor": "xxx,xxx", // 演员
"director": "xxx", // 导演
"writer": "xxx", // 作者
"blurb": "xxx", // 简介(缺省)
"remarks": "更新至第xx集", // 更新进度
"releaseDate": "2024-01-06", // 上映日期
"area": "xxx", // 地区
"language": "xxx", // 语言
"year": "2024", // 年份
"state": "正片", // 状态 正片|预告
"updateTime": "2024-01-13 00:51:21", // 更新时间
"addTime": 1704511497, // 添加时间戳
"dbId": 26373174, // 豆瓣ID
"dbScore": "0.0", // 豆瓣评分
"hits": 0, // 热度
"content": "xxx" //影片内容简介(全)
},
"list": [ // 播放地址列表(全站点)
{
"id": "xxxxxxxxxxxx", // 播放源ID
"name": "HD(xxx)", // 播放源别名
"linkList": [ // 播放地址列表
{
"episode": "第xx集", // 集数
"link": "https://xxx/index.m3u8" // 播放地址url
},
]
},
]
},
"relate": [ // 相关影片推荐
{
"id": 10000, // 影片ID
"cid": 6, // 分类ID
"pid": 1, // 上级分类ID
"name": "xxxx", // 影片名称
"subTitle": "xxxx", // 子标题, 别名
"cName": "xxx", // 分类名称
"state": "正片", // 影片状态
"picture": "http://xxxx.jpg", // 海报图片url
"actor": "xxx,xxx", // 演员
"director": "xxx,xxx", // 导演
"blurb": "", // 剧情简介
"remarks": "HD", // 备注信息 [预告|完结|更新至xx集]
"area": "大陆", // 地区
"year": "2024" // 年份
},
]
},
"msg": "xxx"
}
```
- ` /filmPlayInfo` 影片播放页信息
```json
{
"code": 0,
"data": {
"current": { // 当前播放信息
"episode": "第xx集", // 当前播放集数
"link": "https://xxx/index.m3u8" // 当前播放地址url
},
"currentEpisode": 0, // 当前播放集数索引
"currentPlayFrom": "xxx", // 当前播放源ID
"detail": { // 影片详情
"id": 100000, // 影片ID
"cid": 30, // 影片分类ID
"pid": 4, // 上级分类ID
"name": "xxx", // 影片名称
"picture": "https://xxx.jpg", // 海报封面url
"playFrom": [ "xxx","xxx" ], // 播放来源
"DownFrom": "http", // 下载方式
"playList": [ // 播放地址列表(主站点)
{
"episode": "第xx集", // 集数
"link": "https://xxx/index.m3u8" // 播放地址url
},
],
"downloadList": [ // 下载地址列表
{
"episode": "第xx集", // 集数
"link": "https://xxx/index.m3u8" // 播放地址url
},
],
"descriptor": { // 影片详情
"subTitle": "", // 副标题, 别名
"cName": "xxxx", // 分类名称
"enName": "xxx", // 影片名称中文拼音
"initial": "X", // 影片名称首字母
"classTag": "xxxx", // 内容标签
"actor": "xxx,xxx", // 演员
"director": "xxx", // 导演
"writer": "xxx", // 作者
"blurb": "xxx", // 简介(缺省)
"remarks": "更新至第xx集", // 更新进度
"releaseDate": "2024-01-06", // 上映日期
"area": "xxx", // 地区
"language": "xxx", // 语言
"year": "2024", // 年份
"state": "正片", // 状态 正片|预告
"updateTime": "2024-01-13 00:51:21", // 更新时间
"addTime": 1704511497, // 添加时间戳
"dbId": 26373174, // 豆瓣ID
"dbScore": "0.0", // 豆瓣评分
"hits": 0, // 热度
"content": "xxx" //影片内容简介(全)
},
"list": [ // 播放地址列表(全站点)
{
"id": "xxxxxxxxxxxx", // 播放源ID
"name": "HD(xxx)", // 播放源别名
"linkList": [ // 播放地址列表
{
"episode": "第xx集", // 集数
"link": "https://xxx/index.m3u8" // 播放地址url
},
]
},
]
},
"relate": [ // 相关影片推荐
{
"id": 10000, // 影片ID
"cid": 6, // 分类ID
"pid": 1, // 上级分类ID
"name": "xxxx", // 影片名称
"subTitle": "xxxx", // 子标题, 别名
"cName": "xxx", // 分类名称
"state": "正片", // 影片状态
"picture": "http://xxxx.jpg", // 海报图片url
"actor": "xxx,xxx", // 演员
"director": "xxx,xxx", // 导演
"blurb": "", // 剧情简介
"remarks": "HD", // 备注信息 [预告|完结|更新至xx集]
"area": "大陆", // 地区
"year": "2024" // 年份
},
]
},
"msg": "影片播放信息获取成功"
}
```
- `/filmClassify` 分类影片首页数据
```json
{
"code": 0,
"data": {
"content": { // 内容区数据
"news": [
"id": 10000, // 影片ID
"cid": 6, // 分类ID
"pid": 1, // 上级分类ID
"name": "xxxx", // 影片名称
"subTitle": "xxxx", // 子标题, 别名
"cName": "xxx", // 分类名称
"state": "正片", // 影片状态
"picture": "http://xxxx.jpg", // 海报图片url
"actor": "xxx,xxx", // 演员
"director": "xxx,xxx", // 导演
"blurb": "", // 剧情简介
"remarks": "HD", // 备注信息 [预告|完结|更新至xx集]
"area": "大陆", // 地区
"year": "2024" // 年份
],
"recent": [
"id": 10000, // 影片ID
"cid": 6, // 分类ID
"pid": 1, // 上级分类ID
"name": "xxxx", // 影片名称
"subTitle": "xxxx", // 子标题, 别名
"cName": "xxx", // 分类名称
"state": "正片", // 影片状态
"picture": "http://xxxx.jpg", // 海报图片url
"actor": "xxx,xxx", // 演员
"director": "xxx,xxx", // 导演
"blurb": "", // 剧情简介
"remarks": "HD", // 备注信息 [预告|完结|更新至xx集]
"area": "大陆", // 地区
"year": "2024" // 年份
],
"top": [
"id": 10000, // 影片ID
"cid": 6, // 分类ID
"pid": 1, // 上级分类ID
"name": "xxxx", // 影片名称
"subTitle": "xxxx", // 子标题, 别名
"cName": "xxx", // 分类名称
"state": "正片", // 影片状态
"picture": "http://xxxx.jpg", // 海报图片url
"actor": "xxx,xxx", // 演员
"director": "xxx,xxx", // 导演
"blurb": "", // 剧情简介
"remarks": "HD", // 备注信息 [预告|完结|更新至xx集]
"area": "大陆", // 地区
"year": "2024" // 年份
]
},
"title": { // 头部标题区数据(暂未使用)
"id": 0, // 分类ID
"name": "分类信息", // 分类名称
"pid": 0, // 上级分类ID
"show": false, // 是否展示
"children": [], // 子分类信息
}
},
"msg": ""
}
```
- ` /filmClassidySearch` 影片分类检索页数据
```json
{
"code": 0,
"data": {
"list": [
{
"id": 10000, // 影片ID
"cid": 6, // 分类ID
"pid": 1, // 上级分类ID
"name": "xxxx", // 影片名称
"subTitle": "xxxx", // 子标题, 别名
"cName": "xxx", // 分类名称
"state": "正片", // 影片状态
"picture": "http://xxxx.jpg", // 海报图片url
"actor": "xxx,xxx", // 演员
"director": "xxx,xxx", // 导演
"blurb": "", // 剧情简介
"remarks": "HD", // 备注信息 [预告|完结|更新至xx集]
"area": "大陆", // 地区
"year": "2024" // 年份
}
],
"page": { // 分页信息
"pageSize": 49, // 每页页数
"current": 1, // 当前页
"pageCount": xx, // 总页数
"total": xx, // 总数据量
},
"params": { // 请求参数
"Area": "", // 地区
"Category": "", // 分类ID
"Language": "", // 语言
"Pid": "1", // 上级分类ID
"Plot": "", // 剧情
"Sort": "xxx", // 排序方式
"Year": "", // 年份
},
"search": {
"sortList": [ "Category","Plot","Area","Language","Year","Sort" ], // 标签数据排序, 固定值
"tags": { // 标签组, 用于页面筛选Tag渲染
"Area": [ { Name:"", Value:"" } ],
"Category": [ { Name:"", Value:"" } ],
"Initial": [ { Name:"", Value:"" } ],
"Language": [ { Name:"", Value:"" } ],
"Plot": [ { Name:"", Value:"" } ],
"Sort": [ { Name:"", Value:"" } ],
"Year": [ { Name:"", Value:"" } ]
},
"titles": { // 标签组标题映射(固定值)
"Area": "地区",
"Category": "类型",
"Initial": "首字母",
"Language": "语言",
"Plot": "剧情",
"Sort": "排序",
"Year": "年份"
}
},
"title": { // 当前一级分类信息
"id": 1, // 分类ID
"pid": 0, // 上级分类ID
"name": "xxx", // 分类名称
"show": true, // 是否展示
}
},
"msg": ""
}
```

View File

@@ -2,7 +2,6 @@ package controller
import (
"github.com/gin-gonic/gin"
"net/http"
"server/logic"
"server/model/system"
"strconv"
@@ -25,18 +24,11 @@ func Index(c *gin.Context) {
func CategoriesInfo(c *gin.Context) {
//data := logic.IL.GetCategoryInfo()
data := logic.IL.GetNavCategory()
if data == nil {
c.JSON(http.StatusOK, gin.H{
`status`: StatusFailed,
`message`: `暂无分类信息!!!`,
})
if data == nil || len(data) <= 0 {
system.Failed("暂无分类信息", c)
return
}
c.JSON(http.StatusOK, gin.H{
`status`: StatusOk,
`data`: data,
})
system.Success(data, "分类信息获取成功", c)
}
// FilmDetail 影片详情信息查询
@@ -102,14 +94,12 @@ func SearchFilm(c *gin.Context) {
current, _ := strconv.Atoi(currStr)
page := system.Page{PageSize: 10, Current: current}
bl := logic.IL.SearchFilmInfo(strings.TrimSpace(keyword), &page)
if page.Total <= 0 {
system.Failed("暂无相关影片信息", c)
return
}
c.JSON(http.StatusOK, gin.H{
"status": StatusOk,
"data": gin.H{
"list": bl,
"page": page,
},
})
system.Success(gin.H{"list": bl, "page": page}, "影片搜索成功", c)
}
// FilmTagSearch 通过tag获取满足条件的对应影片
@@ -119,10 +109,7 @@ func FilmTagSearch(c *gin.Context) {
cidStr := c.DefaultQuery("Category", "")
yStr := c.DefaultQuery("Year", "")
if pidStr == "" {
c.JSON(http.StatusOK, gin.H{
"status": StatusFailed,
"message": "缺少分类信息",
})
system.Failed("缺少分类信息", c)
return
}
params.Pid, _ = strconv.ParseInt(pidStr, 10, 64)
@@ -140,34 +127,28 @@ func FilmTagSearch(c *gin.Context) {
logic.IL.GetFilmsByTags(params, &page)
// 获取当前分类Title
// 返回对应信息
c.JSON(http.StatusOK, gin.H{
"status": StatusOk,
"data": gin.H{
"title": logic.IL.GetPidCategory(params.Pid).Category,
"list": logic.IL.GetFilmsByTags(params, &page),
"search": logic.IL.SearchTags(params.Pid),
"params": map[string]string{
"Pid": pidStr,
"Category": cidStr,
"Plot": params.Plot,
"Area": params.Area,
"Language": params.Language,
"Year": yStr,
"Sort": params.Sort,
},
system.Success(gin.H{
"title": logic.IL.GetPidCategory(params.Pid).Category,
"list": logic.IL.GetFilmsByTags(params, &page),
"search": logic.IL.SearchTags(params.Pid),
"params": map[string]string{
"Pid": pidStr,
"Category": cidStr,
"Plot": params.Plot,
"Area": params.Area,
"Language": params.Language,
"Year": yStr,
"Sort": params.Sort,
},
"page": page,
})
}, "分类影片数据获取成功", c)
}
// FilmClassify 影片分类首页数据展示
func FilmClassify(c *gin.Context) {
pidStr := c.DefaultQuery("Pid", "")
if pidStr == "" {
c.JSON(http.StatusOK, gin.H{
"status": StatusFailed,
"message": "缺少分类信息",
})
system.Failed("主分类信息获取异常", c)
return
}
// 1. 顶部Title数据
@@ -176,12 +157,8 @@ func FilmClassify(c *gin.Context) {
// 2. 设置分页信息
page := system.Page{PageSize: 21, Current: 1}
// 3. 获取当前分类下的 最新上映, 排行榜, 最近更新 影片信息
c.JSON(http.StatusOK, gin.H{
"status": StatusOk,
"data": gin.H{
"title": title,
"content": logic.IL.GetFilmClassify(pid, &page),
},
"page": page,
})
system.Success(gin.H{
"title": title,
"content": logic.IL.GetFilmClassify(pid, &page),
}, "分类影片信息获取成功", c)
}

View File

@@ -7,12 +7,11 @@ import (
"server/plugin/SystemInit"
"server/plugin/db"
"server/router"
"time"
)
func init() {
// 执行初始化前等待20s , 让mysql服务完成初始化指令
time.Sleep(time.Second * 20)
//time.Sleep(time.Second * 20)
//初始化redis客户端
err := db.InitRedisConn()
if err != nil {

View File

@@ -67,6 +67,20 @@ func FailedWithData(data any, message string, c *gin.Context) {
Result(FAILED, data, message, c)
}
// CustomResult 自定义返回状态以及相关数据, 用于异常返回情况
func CustomResult(statusCode int, code int, data any, msg string, c *gin.Context) {
c.JSON(statusCode, Response{
Code: code,
Data: data,
Msg: msg,
})
}
// ExceptionResult 异常状态返回
func ExceptionResult(statusCode int, message string, c *gin.Context) {
CustomResult(statusCode, SUCCESS, nil, message, c)
}
// GetPage 获取分页相关数据
func GetPage(db *gorm.DB, page *Page) {
var count int64