From 042c99aa46ee004c1573833074d85a98c13dc488 Mon Sep 17 00:00:00 2001 From: Blizzard Date: Tue, 3 Mar 2026 17:09:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=A2=E9=98=85=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=92=8C=E5=85=8D=E8=B4=B9=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.zh.md | 2 +- api/v1/radio/category.go | 19 + api/v1/radio/channel.go | 30 + config-dev.yaml | 8 +- docs/docs.go | 1507 ++++++++++++++++++++++++- docs/swagger.json | 1506 +++++++++++++++++++++++- docs/swagger.yaml | 1020 ++++++++++++++++- model/radio/radio_category.go | 17 +- model/radio/radio_channel.go | 26 +- model/radio/radio_history.go | 9 +- model/radio/radio_program.go | 27 +- model/radio/radio_subscription.go | 7 +- model/radio/request/category.go | 1 - model/radio/request/channel.go | 43 +- model/radio/request/program.go | 7 +- router/radio/category_router.go | 3 +- router/radio/channel_router.go | 1 + service/radio/category_service.go | 19 +- service/radio/channel_service.go | 97 +- service/radio/interaction_service.go | 2 +- service/radio/subscription_service.go | 40 +- 21 files changed, 4182 insertions(+), 209 deletions(-) diff --git a/README.zh.md b/README.zh.md index a5e28c4..da82a0d 100644 --- a/README.zh.md +++ b/README.zh.md @@ -70,4 +70,4 @@ ## 部署说明 (参考) 项目支持跨平台编译: - **Windows**: `GOOS=windows GOARCH=amd64 go build -o planting-fun.exe` -- **Linux**: `GOOS=linux GOARCH=amd64 go build -o sundynix-plant` +- **Linux**: `GOOS=linux GOARCH=amd64 go build -o sundynix-radio` diff --git a/api/v1/radio/category.go b/api/v1/radio/category.go index 56f6c74..3783b86 100644 --- a/api/v1/radio/category.go +++ b/api/v1/radio/category.go @@ -42,6 +42,25 @@ func (a *CategoryApi) GetCategoryPage(c *gin.Context) { }, c) } +// GetCategoryTree 获取分类tree +// @Tags 分类管理 +// @Summary 获取分类列表 +// @Accept application/json +// @Produce application/json +// @Success 200 {object} response.Response +// @Router /radio/category/tree [get] +func (a *CategoryApi) GetCategoryTree(c *gin.Context) { + list, err := categoryService.GetCategoryTree() + if err != nil { + global.Logger.Error("获取分类列表失败!", zap.Error(err)) + response.FailWithMsg(err.Error(), c) + return + } + response.OkWithData(response.ListResult{ + List: list, + }, c) +} + // GetCategoryList 获取分类列表 // @Tags 分类管理 // @Summary 获取分类列表 diff --git a/api/v1/radio/channel.go b/api/v1/radio/channel.go index b3c93b3..417588b 100644 --- a/api/v1/radio/channel.go +++ b/api/v1/radio/channel.go @@ -14,6 +14,36 @@ import ( type ChannelApi struct{} +// GetFreeChannelList 获取免费频道列表 +// @Tags 频道管理 +// @Summary 获取频道列表 +// @Accept application/json +// @Produce application/json +// @Param data body request.GetChannelList true "分页查询" +// @Success 200 {object} response.Response +// @Router /radio/channel/freeList [post] +func (a *ChannelApi) GetFreeChannelList(c *gin.Context) { + var req common.PageInfo + err := c.ShouldBindJSON(&req) + if err != nil { + response.FailWithMsg("参数错误: "+err.Error(), c) + return + } + list, total, err := channelService.GetFreeChannelList(req) + if err != nil { + global.Logger.Error("获取频道列表失败!", zap.Error(err)) + response.FailWithMsg(err.Error(), c) + return + } + + response.OkWithData(response.PageResult{ + List: list, + Total: total, + Page: req.Current, + PageSize: req.PageSize, + }, c) +} + // GetChannelList 获取频道列表 // @Tags 频道管理 // @Summary 获取频道列表 diff --git a/config-dev.yaml b/config-dev.yaml index 60f2690..513f982 100644 --- a/config-dev.yaml +++ b/config-dev.yaml @@ -1,5 +1,5 @@ system: - addr: 8889 + addr: 8888 db-type: mysql router-prefix: "" enable-captcha: 0 @@ -12,10 +12,10 @@ jwt: issuer: sundynix signing-key: 9149f2eb-d517-4a50-a03a-231dbcf0d872 -# 早安电台微信小程序 +# 电台微信小程序 mini-program: - app-id: wxb463820bf36dd5d6 - app-secret: 731784a74c76c6d31fa00bb847af2c7d + app-id: wx52dfc635739a9c19 + app-secret: 84c6ddab1f24d0222da57bedb681c81f # 微信支付 wechat-pay: diff --git a/docs/docs.go b/docs/docs.go index 55203da..657d669 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -248,7 +248,7 @@ const docTemplate = `{ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -298,7 +298,7 @@ const docTemplate = `{ "get": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "description": "id获取详情", @@ -347,7 +347,7 @@ const docTemplate = `{ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -400,7 +400,7 @@ const docTemplate = `{ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -450,7 +450,7 @@ const docTemplate = `{ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -500,7 +500,7 @@ const docTemplate = `{ "get": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "description": "删除menu", @@ -546,7 +546,7 @@ const docTemplate = `{ "get": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "description": "id获取详情", @@ -595,7 +595,7 @@ const docTemplate = `{ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -651,7 +651,7 @@ const docTemplate = `{ "get": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "produces": [ @@ -693,7 +693,7 @@ const docTemplate = `{ "get": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "produces": [ @@ -735,7 +735,7 @@ const docTemplate = `{ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -784,7 +784,7 @@ const docTemplate = `{ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -1022,6 +1022,904 @@ const docTemplate = `{ } } }, + "/radio/category/delete": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "分类管理" + ], + "summary": "删除分类", + "parameters": [ + { + "description": "分类ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetById" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/category/detail": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "分类管理" + ], + "summary": "获取分类详情", + "parameters": [ + { + "type": "string", + "description": "分类ID", + "name": "id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/category/list": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "分类管理" + ], + "summary": "获取分类列表", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/category/page": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分类管理" + ], + "summary": "获取分类列表", + "parameters": [ + { + "description": "分页查询", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetCategoryList" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/category/save": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分类管理" + ], + "summary": "保存分类", + "parameters": [ + { + "description": "分类信息", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.SaveCategory" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/category/tree": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分类管理" + ], + "summary": "获取分类列表", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/category/update": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分类管理" + ], + "summary": "更新分类", + "parameters": [ + { + "description": "Success 200 {分类信息", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.UpdateCategory" + } + } + ], + "responses": {} + } + }, + "/radio/channel/delete": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "频道管理" + ], + "summary": "删除频道", + "parameters": [ + { + "description": "频道ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetById" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/channel/detail": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "频道管理" + ], + "summary": "获取频道详情", + "parameters": [ + { + "type": "string", + "description": "频道ID", + "name": "id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/channel/list": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "频道管理" + ], + "summary": "获取频道列表", + "parameters": [ + { + "description": "分页查询", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetChannelList" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/channel/save": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "频道管理" + ], + "summary": "保存频道", + "parameters": [ + { + "description": "频道信息", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.SaveChannel" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/channel/update": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "频道管理" + ], + "summary": "更新频道", + "parameters": [ + { + "description": "频道信息", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.UpdateChannel" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/comment/add": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "用户互动" + ], + "summary": "添加评论", + "parameters": [ + { + "description": "评论信息", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AddComment" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/comment/delete": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "用户互动" + ], + "summary": "删除评论", + "parameters": [ + { + "description": "评论ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.DeleteComment" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/comment/list": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "用户互动" + ], + "summary": "获取评论列表", + "parameters": [ + { + "description": "分页查询", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetCommentList" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/favorite/add": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "用户互动" + ], + "summary": "添加收藏", + "parameters": [ + { + "description": "节目ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AddFavorite" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/favorite/list": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "用户互动" + ], + "summary": "获取收藏列表", + "parameters": [ + { + "description": "分页查询", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetFavoriteList" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/favorite/remove": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "用户互动" + ], + "summary": "取消收藏", + "parameters": [ + { + "description": "节目ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.RemoveFavorite" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/history/add": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "用户互动" + ], + "summary": "添加收听历史", + "parameters": [ + { + "description": "收听信息", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AddHistory" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/history/list": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "用户互动" + ], + "summary": "获取收听历史列表", + "parameters": [ + { + "description": "分页查询", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetHistoryList" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/like/toggle": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "用户互动" + ], + "summary": "切换点赞状态", + "parameters": [ + { + "description": "节目ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.ToggleLike" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/program/delete": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "节目管理" + ], + "summary": "删除节目", + "parameters": [ + { + "description": "节目ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetById" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/program/detail": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "节目管理" + ], + "summary": "获取节目详情", + "parameters": [ + { + "type": "string", + "description": "节目ID", + "name": "id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/program/list": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "节目管理" + ], + "summary": "获取节目列表", + "parameters": [ + { + "description": "分页查询", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetProgramList" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/program/save": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "节目管理" + ], + "summary": "保存节目", + "parameters": [ + { + "description": "节目信息", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.SaveProgram" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/program/update": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "节目管理" + ], + "summary": "更新节目", + "parameters": [ + { + "description": "节目信息", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.UpdateProgram" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/subscription/can-subscribe": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "订阅管理" + ], + "summary": "检查是否可以订阅", + "parameters": [ + { + "description": "频道ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.SubscribeChannel" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/subscription/list": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "订阅管理" + ], + "summary": "获取我的订阅列表", + "parameters": [ + { + "description": "分页查询", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetSubscriptionList" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/subscription/subscribe": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "订阅管理" + ], + "summary": "订阅频道", + "parameters": [ + { + "description": "频道ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.SubscribeChannel" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/subscription/unsubscribe": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "订阅管理" + ], + "summary": "退订频道", + "parameters": [ + { + "description": "频道ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.UnsubscribeChannel" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, "/role/delete": { "post": { "description": "删除角色", @@ -1072,7 +1970,7 @@ const docTemplate = `{ "get": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "produces": [ @@ -1166,7 +2064,7 @@ const docTemplate = `{ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -1204,7 +2102,7 @@ const docTemplate = `{ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -1242,7 +2140,7 @@ const docTemplate = `{ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -1280,7 +2178,7 @@ const docTemplate = `{ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "description": "修改密码", @@ -1331,7 +2229,7 @@ const docTemplate = `{ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -1381,7 +2279,7 @@ const docTemplate = `{ "get": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "produces": [ @@ -1426,7 +2324,7 @@ const docTemplate = `{ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -1479,7 +2377,7 @@ const docTemplate = `{ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -1517,7 +2415,7 @@ const docTemplate = `{ "get": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "produces": [ @@ -1541,7 +2439,7 @@ const docTemplate = `{ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -1579,7 +2477,7 @@ const docTemplate = `{ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -1615,6 +2513,59 @@ const docTemplate = `{ } }, "definitions": { + "request.AddComment": { + "type": "object", + "required": [ + "content", + "programId" + ], + "properties": { + "content": { + "description": "评论内容", + "type": "string" + }, + "parentId": { + "description": "父评论ID", + "type": "string" + }, + "programId": { + "description": "节目ID", + "type": "string" + } + } + }, + "request.AddFavorite": { + "type": "object", + "required": [ + "programId" + ], + "properties": { + "programId": { + "description": "节目ID", + "type": "string" + } + } + }, + "request.AddHistory": { + "type": "object", + "required": [ + "programId" + ], + "properties": { + "duration": { + "description": "节目总时长(秒)", + "type": "integer" + }, + "programId": { + "description": "节目ID", + "type": "string" + }, + "progress": { + "description": "播放进度(秒)", + "type": "integer" + } + } + }, "request.ChangePwd": { "type": "object", "properties": { @@ -1626,6 +2577,81 @@ const docTemplate = `{ } } }, + "request.DeleteComment": { + "type": "object", + "required": [ + "commentId" + ], + "properties": { + "commentId": { + "description": "评论ID", + "type": "string" + } + } + }, + "request.GetById": { + "type": "object", + "properties": { + "id": { + "description": "主键ID", + "type": "string" + } + } + }, + "request.GetCategoryList": { + "type": "object", + "properties": { + "current": { + "description": "页码", + "type": "integer" + }, + "keyword": { + "description": "关键字", + "type": "string" + }, + "name": { + "description": "分类名称", + "type": "string" + }, + "pageSize": { + "description": "每页大小", + "type": "integer" + }, + "status": { + "description": "状态", + "type": "integer" + } + } + }, + "request.GetChannelList": { + "type": "object", + "properties": { + "categoryId": { + "description": "分类ID", + "type": "string" + }, + "current": { + "description": "页码", + "type": "integer" + }, + "keyword": { + "description": "关键字", + "type": "string" + }, + "name": { + "description": "频道名称", + "type": "string" + }, + "pageSize": { + "description": "每页大小", + "type": "integer" + }, + "status": { + "description": "状态", + "type": "integer" + } + } + }, "request.GetClientList": { "type": "object", "properties": { @@ -1649,6 +2675,61 @@ const docTemplate = `{ } } }, + "request.GetCommentList": { + "type": "object", + "properties": { + "current": { + "description": "页码", + "type": "integer" + }, + "keyword": { + "description": "关键字", + "type": "string" + }, + "pageSize": { + "description": "每页大小", + "type": "integer" + }, + "programId": { + "description": "节目ID", + "type": "string" + } + } + }, + "request.GetFavoriteList": { + "type": "object", + "properties": { + "current": { + "description": "页码", + "type": "integer" + }, + "keyword": { + "description": "关键字", + "type": "string" + }, + "pageSize": { + "description": "每页大小", + "type": "integer" + } + } + }, + "request.GetHistoryList": { + "type": "object", + "properties": { + "current": { + "description": "页码", + "type": "integer" + }, + "keyword": { + "description": "关键字", + "type": "string" + }, + "pageSize": { + "description": "每页大小", + "type": "integer" + } + } + }, "request.GetMenuTree": { "type": "object", "properties": { @@ -1680,6 +2761,38 @@ const docTemplate = `{ } } }, + "request.GetProgramList": { + "type": "object", + "required": [ + "channelId" + ], + "properties": { + "channelId": { + "description": "频道ID", + "type": "string" + }, + "current": { + "description": "页码", + "type": "integer" + }, + "keyword": { + "description": "关键字", + "type": "string" + }, + "pageSize": { + "description": "每页大小", + "type": "integer" + }, + "status": { + "description": "状态", + "type": "integer" + }, + "title": { + "description": "节目标题", + "type": "string" + } + } + }, "request.GetRoleList": { "type": "object", "properties": { @@ -1703,6 +2816,23 @@ const docTemplate = `{ } } }, + "request.GetSubscriptionList": { + "type": "object", + "properties": { + "current": { + "description": "页码", + "type": "integer" + }, + "keyword": { + "description": "关键字", + "type": "string" + }, + "pageSize": { + "description": "每页大小", + "type": "integer" + } + } + }, "request.GetUserList": { "type": "object", "properties": { @@ -1782,6 +2912,329 @@ const docTemplate = `{ } } }, + "request.RemoveFavorite": { + "type": "object", + "required": [ + "programId" + ], + "properties": { + "programId": { + "description": "节目ID", + "type": "string" + } + } + }, + "request.SaveCategory": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "coverId": { + "description": "封面图URL", + "type": "string" + }, + "description": { + "description": "分类描述", + "type": "string" + }, + "iconId": { + "description": "图标URL", + "type": "string" + }, + "name": { + "description": "分类名称", + "type": "string" + }, + "sort": { + "description": "排序", + "type": "integer" + }, + "status": { + "description": "状态", + "type": "integer" + } + } + }, + "request.SaveChannel": { + "type": "object", + "required": [ + "categoryId", + "name" + ], + "properties": { + "annualPrice": { + "description": "包季价格", + "type": "integer" + }, + "categoryId": { + "description": "分类ID", + "type": "string" + }, + "coverId": { + "description": "封面图URL", + "type": "string" + }, + "description": { + "description": "频道描述", + "type": "string" + }, + "isFree": { + "description": "是否永久免费", + "type": "integer" + }, + "isVipOnly": { + "description": "是否vip专享", + "type": "integer" + }, + "monthlyPrice": { + "description": "包月价格", + "type": "integer" + }, + "name": { + "description": "频道名称", + "type": "string" + }, + "quarterlyPrice": { + "description": "包季价格", + "type": "integer" + }, + "sort": { + "description": "排序", + "type": "integer" + }, + "status": { + "description": "状态", + "type": "integer" + }, + "tags": { + "description": "标签", + "type": "string" + } + } + }, + "request.SaveProgram": { + "type": "object", + "required": [ + "channelId", + "title" + ], + "properties": { + "audioId": { + "description": "音频URL", + "type": "string" + }, + "channelId": { + "description": "频道ID", + "type": "string" + }, + "content": { + "type": "string" + }, + "coverId": { + "description": "封面图URL", + "type": "string" + }, + "description": { + "description": "节目描述", + "type": "string" + }, + "duration": { + "description": "时长(秒)", + "type": "integer" + }, + "status": { + "description": "状态", + "type": "integer" + }, + "tags": { + "description": "标签", + "type": "string" + }, + "title": { + "description": "节目标题", + "type": "string" + } + } + }, + "request.SubscribeChannel": { + "type": "object", + "required": [ + "channelId" + ], + "properties": { + "channelId": { + "description": "频道ID", + "type": "string" + } + } + }, + "request.ToggleLike": { + "type": "object", + "required": [ + "programId" + ], + "properties": { + "programId": { + "description": "节目ID", + "type": "string" + } + } + }, + "request.UnsubscribeChannel": { + "type": "object", + "required": [ + "channelId" + ], + "properties": { + "channelId": { + "description": "频道ID", + "type": "string" + } + } + }, + "request.UpdateCategory": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "coverId": { + "description": "封面图URL", + "type": "string" + }, + "description": { + "description": "分类描述", + "type": "string" + }, + "iconId": { + "description": "图标URL", + "type": "string" + }, + "id": { + "description": "分类ID", + "type": "string" + }, + "name": { + "description": "分类名称", + "type": "string" + }, + "sort": { + "description": "排序", + "type": "integer" + }, + "status": { + "description": "状态", + "type": "integer" + } + } + }, + "request.UpdateChannel": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "annualPrice": { + "description": "包季价格", + "type": "integer" + }, + "categoryId": { + "description": "分类ID", + "type": "string" + }, + "coverId": { + "description": "封面图URL", + "type": "string" + }, + "description": { + "description": "频道描述", + "type": "string" + }, + "id": { + "description": "频道ID", + "type": "string" + }, + "isFree": { + "type": "integer" + }, + "isVipOnly": { + "description": "是否vip专享", + "type": "integer" + }, + "monthlyPrice": { + "description": "包月价格", + "type": "integer" + }, + "name": { + "description": "频道名称", + "type": "string" + }, + "quarterlyPrice": { + "description": "包季价格", + "type": "integer" + }, + "sort": { + "description": "排序", + "type": "integer" + }, + "status": { + "description": "状态", + "type": "integer" + }, + "tags": { + "description": "标签", + "type": "string" + } + } + }, + "request.UpdateProgram": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "audioId": { + "description": "音频URL", + "type": "string" + }, + "channelId": { + "description": "频道ID", + "type": "string" + }, + "content": { + "type": "string" + }, + "coverId": { + "description": "封面图URL", + "type": "string" + }, + "description": { + "description": "节目描述", + "type": "string" + }, + "duration": { + "description": "时长(秒)", + "type": "integer" + }, + "id": { + "description": "节目ID", + "type": "string" + }, + "status": { + "description": "状态", + "type": "integer" + }, + "tags": { + "description": "标签", + "type": "string" + }, + "title": { + "description": "节目标题", + "type": "string" + } + } + }, "response.CaptchaRes": { "type": "object", "properties": { @@ -2047,9 +3500,7 @@ const docTemplate = `{ }, "securityDefinitions": { "BearerAuth": { - "type": "apiKey", - "name": "Authorization", - "in": "header" + "type": "basic" } } }` @@ -2058,7 +3509,7 @@ const docTemplate = `{ var SwaggerInfo = &swag.Spec{ Version: "v1.0.0", Host: "", - BasePath: "", + BasePath: "/", Schemes: []string{}, Title: "Swagger API接口文档", Description: "使用gin + gorm进行极速开发的全栈开发基础平台", diff --git a/docs/swagger.json b/docs/swagger.json index a484875..60f8bf8 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -6,6 +6,7 @@ "contact": {}, "version": "v1.0.0" }, + "basePath": "/", "paths": { "/auth/captcha": { "get": { @@ -240,7 +241,7 @@ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -290,7 +291,7 @@ "get": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "description": "id获取详情", @@ -339,7 +340,7 @@ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -392,7 +393,7 @@ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -442,7 +443,7 @@ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -492,7 +493,7 @@ "get": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "description": "删除menu", @@ -538,7 +539,7 @@ "get": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "description": "id获取详情", @@ -587,7 +588,7 @@ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -643,7 +644,7 @@ "get": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "produces": [ @@ -685,7 +686,7 @@ "get": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "produces": [ @@ -727,7 +728,7 @@ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -776,7 +777,7 @@ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -1014,6 +1015,904 @@ } } }, + "/radio/category/delete": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "分类管理" + ], + "summary": "删除分类", + "parameters": [ + { + "description": "分类ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetById" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/category/detail": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "分类管理" + ], + "summary": "获取分类详情", + "parameters": [ + { + "type": "string", + "description": "分类ID", + "name": "id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/category/list": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "分类管理" + ], + "summary": "获取分类列表", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/category/page": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分类管理" + ], + "summary": "获取分类列表", + "parameters": [ + { + "description": "分页查询", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetCategoryList" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/category/save": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分类管理" + ], + "summary": "保存分类", + "parameters": [ + { + "description": "分类信息", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.SaveCategory" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/category/tree": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分类管理" + ], + "summary": "获取分类列表", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/category/update": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分类管理" + ], + "summary": "更新分类", + "parameters": [ + { + "description": "Success 200 {分类信息", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.UpdateCategory" + } + } + ], + "responses": {} + } + }, + "/radio/channel/delete": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "频道管理" + ], + "summary": "删除频道", + "parameters": [ + { + "description": "频道ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetById" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/channel/detail": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "频道管理" + ], + "summary": "获取频道详情", + "parameters": [ + { + "type": "string", + "description": "频道ID", + "name": "id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/channel/list": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "频道管理" + ], + "summary": "获取频道列表", + "parameters": [ + { + "description": "分页查询", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetChannelList" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/channel/save": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "频道管理" + ], + "summary": "保存频道", + "parameters": [ + { + "description": "频道信息", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.SaveChannel" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/channel/update": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "频道管理" + ], + "summary": "更新频道", + "parameters": [ + { + "description": "频道信息", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.UpdateChannel" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/comment/add": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "用户互动" + ], + "summary": "添加评论", + "parameters": [ + { + "description": "评论信息", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AddComment" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/comment/delete": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "用户互动" + ], + "summary": "删除评论", + "parameters": [ + { + "description": "评论ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.DeleteComment" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/comment/list": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "用户互动" + ], + "summary": "获取评论列表", + "parameters": [ + { + "description": "分页查询", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetCommentList" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/favorite/add": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "用户互动" + ], + "summary": "添加收藏", + "parameters": [ + { + "description": "节目ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AddFavorite" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/favorite/list": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "用户互动" + ], + "summary": "获取收藏列表", + "parameters": [ + { + "description": "分页查询", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetFavoriteList" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/favorite/remove": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "用户互动" + ], + "summary": "取消收藏", + "parameters": [ + { + "description": "节目ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.RemoveFavorite" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/history/add": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "用户互动" + ], + "summary": "添加收听历史", + "parameters": [ + { + "description": "收听信息", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AddHistory" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/history/list": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "用户互动" + ], + "summary": "获取收听历史列表", + "parameters": [ + { + "description": "分页查询", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetHistoryList" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/like/toggle": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "用户互动" + ], + "summary": "切换点赞状态", + "parameters": [ + { + "description": "节目ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.ToggleLike" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/program/delete": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "节目管理" + ], + "summary": "删除节目", + "parameters": [ + { + "description": "节目ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetById" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/program/detail": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "节目管理" + ], + "summary": "获取节目详情", + "parameters": [ + { + "type": "string", + "description": "节目ID", + "name": "id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/program/list": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "节目管理" + ], + "summary": "获取节目列表", + "parameters": [ + { + "description": "分页查询", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetProgramList" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/program/save": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "节目管理" + ], + "summary": "保存节目", + "parameters": [ + { + "description": "节目信息", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.SaveProgram" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/program/update": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "节目管理" + ], + "summary": "更新节目", + "parameters": [ + { + "description": "节目信息", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.UpdateProgram" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/subscription/can-subscribe": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "订阅管理" + ], + "summary": "检查是否可以订阅", + "parameters": [ + { + "description": "频道ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.SubscribeChannel" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/subscription/list": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "订阅管理" + ], + "summary": "获取我的订阅列表", + "parameters": [ + { + "description": "分页查询", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetSubscriptionList" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/subscription/subscribe": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "订阅管理" + ], + "summary": "订阅频道", + "parameters": [ + { + "description": "频道ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.SubscribeChannel" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, + "/radio/subscription/unsubscribe": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "订阅管理" + ], + "summary": "退订频道", + "parameters": [ + { + "description": "频道ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.UnsubscribeChannel" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + } + } + } + }, "/role/delete": { "post": { "description": "删除角色", @@ -1064,7 +1963,7 @@ "get": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "produces": [ @@ -1158,7 +2057,7 @@ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -1196,7 +2095,7 @@ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -1234,7 +2133,7 @@ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -1272,7 +2171,7 @@ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "description": "修改密码", @@ -1323,7 +2222,7 @@ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -1373,7 +2272,7 @@ "get": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "produces": [ @@ -1418,7 +2317,7 @@ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -1471,7 +2370,7 @@ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -1509,7 +2408,7 @@ "get": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "produces": [ @@ -1533,7 +2432,7 @@ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -1571,7 +2470,7 @@ "post": { "security": [ { - "ApiKeyAuth": [] + "BasicAuth": [] } ], "consumes": [ @@ -1607,6 +2506,59 @@ } }, "definitions": { + "request.AddComment": { + "type": "object", + "required": [ + "content", + "programId" + ], + "properties": { + "content": { + "description": "评论内容", + "type": "string" + }, + "parentId": { + "description": "父评论ID", + "type": "string" + }, + "programId": { + "description": "节目ID", + "type": "string" + } + } + }, + "request.AddFavorite": { + "type": "object", + "required": [ + "programId" + ], + "properties": { + "programId": { + "description": "节目ID", + "type": "string" + } + } + }, + "request.AddHistory": { + "type": "object", + "required": [ + "programId" + ], + "properties": { + "duration": { + "description": "节目总时长(秒)", + "type": "integer" + }, + "programId": { + "description": "节目ID", + "type": "string" + }, + "progress": { + "description": "播放进度(秒)", + "type": "integer" + } + } + }, "request.ChangePwd": { "type": "object", "properties": { @@ -1618,6 +2570,81 @@ } } }, + "request.DeleteComment": { + "type": "object", + "required": [ + "commentId" + ], + "properties": { + "commentId": { + "description": "评论ID", + "type": "string" + } + } + }, + "request.GetById": { + "type": "object", + "properties": { + "id": { + "description": "主键ID", + "type": "string" + } + } + }, + "request.GetCategoryList": { + "type": "object", + "properties": { + "current": { + "description": "页码", + "type": "integer" + }, + "keyword": { + "description": "关键字", + "type": "string" + }, + "name": { + "description": "分类名称", + "type": "string" + }, + "pageSize": { + "description": "每页大小", + "type": "integer" + }, + "status": { + "description": "状态", + "type": "integer" + } + } + }, + "request.GetChannelList": { + "type": "object", + "properties": { + "categoryId": { + "description": "分类ID", + "type": "string" + }, + "current": { + "description": "页码", + "type": "integer" + }, + "keyword": { + "description": "关键字", + "type": "string" + }, + "name": { + "description": "频道名称", + "type": "string" + }, + "pageSize": { + "description": "每页大小", + "type": "integer" + }, + "status": { + "description": "状态", + "type": "integer" + } + } + }, "request.GetClientList": { "type": "object", "properties": { @@ -1641,6 +2668,61 @@ } } }, + "request.GetCommentList": { + "type": "object", + "properties": { + "current": { + "description": "页码", + "type": "integer" + }, + "keyword": { + "description": "关键字", + "type": "string" + }, + "pageSize": { + "description": "每页大小", + "type": "integer" + }, + "programId": { + "description": "节目ID", + "type": "string" + } + } + }, + "request.GetFavoriteList": { + "type": "object", + "properties": { + "current": { + "description": "页码", + "type": "integer" + }, + "keyword": { + "description": "关键字", + "type": "string" + }, + "pageSize": { + "description": "每页大小", + "type": "integer" + } + } + }, + "request.GetHistoryList": { + "type": "object", + "properties": { + "current": { + "description": "页码", + "type": "integer" + }, + "keyword": { + "description": "关键字", + "type": "string" + }, + "pageSize": { + "description": "每页大小", + "type": "integer" + } + } + }, "request.GetMenuTree": { "type": "object", "properties": { @@ -1672,6 +2754,38 @@ } } }, + "request.GetProgramList": { + "type": "object", + "required": [ + "channelId" + ], + "properties": { + "channelId": { + "description": "频道ID", + "type": "string" + }, + "current": { + "description": "页码", + "type": "integer" + }, + "keyword": { + "description": "关键字", + "type": "string" + }, + "pageSize": { + "description": "每页大小", + "type": "integer" + }, + "status": { + "description": "状态", + "type": "integer" + }, + "title": { + "description": "节目标题", + "type": "string" + } + } + }, "request.GetRoleList": { "type": "object", "properties": { @@ -1695,6 +2809,23 @@ } } }, + "request.GetSubscriptionList": { + "type": "object", + "properties": { + "current": { + "description": "页码", + "type": "integer" + }, + "keyword": { + "description": "关键字", + "type": "string" + }, + "pageSize": { + "description": "每页大小", + "type": "integer" + } + } + }, "request.GetUserList": { "type": "object", "properties": { @@ -1774,6 +2905,329 @@ } } }, + "request.RemoveFavorite": { + "type": "object", + "required": [ + "programId" + ], + "properties": { + "programId": { + "description": "节目ID", + "type": "string" + } + } + }, + "request.SaveCategory": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "coverId": { + "description": "封面图URL", + "type": "string" + }, + "description": { + "description": "分类描述", + "type": "string" + }, + "iconId": { + "description": "图标URL", + "type": "string" + }, + "name": { + "description": "分类名称", + "type": "string" + }, + "sort": { + "description": "排序", + "type": "integer" + }, + "status": { + "description": "状态", + "type": "integer" + } + } + }, + "request.SaveChannel": { + "type": "object", + "required": [ + "categoryId", + "name" + ], + "properties": { + "annualPrice": { + "description": "包季价格", + "type": "integer" + }, + "categoryId": { + "description": "分类ID", + "type": "string" + }, + "coverId": { + "description": "封面图URL", + "type": "string" + }, + "description": { + "description": "频道描述", + "type": "string" + }, + "isFree": { + "description": "是否永久免费", + "type": "integer" + }, + "isVipOnly": { + "description": "是否vip专享", + "type": "integer" + }, + "monthlyPrice": { + "description": "包月价格", + "type": "integer" + }, + "name": { + "description": "频道名称", + "type": "string" + }, + "quarterlyPrice": { + "description": "包季价格", + "type": "integer" + }, + "sort": { + "description": "排序", + "type": "integer" + }, + "status": { + "description": "状态", + "type": "integer" + }, + "tags": { + "description": "标签", + "type": "string" + } + } + }, + "request.SaveProgram": { + "type": "object", + "required": [ + "channelId", + "title" + ], + "properties": { + "audioId": { + "description": "音频URL", + "type": "string" + }, + "channelId": { + "description": "频道ID", + "type": "string" + }, + "content": { + "type": "string" + }, + "coverId": { + "description": "封面图URL", + "type": "string" + }, + "description": { + "description": "节目描述", + "type": "string" + }, + "duration": { + "description": "时长(秒)", + "type": "integer" + }, + "status": { + "description": "状态", + "type": "integer" + }, + "tags": { + "description": "标签", + "type": "string" + }, + "title": { + "description": "节目标题", + "type": "string" + } + } + }, + "request.SubscribeChannel": { + "type": "object", + "required": [ + "channelId" + ], + "properties": { + "channelId": { + "description": "频道ID", + "type": "string" + } + } + }, + "request.ToggleLike": { + "type": "object", + "required": [ + "programId" + ], + "properties": { + "programId": { + "description": "节目ID", + "type": "string" + } + } + }, + "request.UnsubscribeChannel": { + "type": "object", + "required": [ + "channelId" + ], + "properties": { + "channelId": { + "description": "频道ID", + "type": "string" + } + } + }, + "request.UpdateCategory": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "coverId": { + "description": "封面图URL", + "type": "string" + }, + "description": { + "description": "分类描述", + "type": "string" + }, + "iconId": { + "description": "图标URL", + "type": "string" + }, + "id": { + "description": "分类ID", + "type": "string" + }, + "name": { + "description": "分类名称", + "type": "string" + }, + "sort": { + "description": "排序", + "type": "integer" + }, + "status": { + "description": "状态", + "type": "integer" + } + } + }, + "request.UpdateChannel": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "annualPrice": { + "description": "包季价格", + "type": "integer" + }, + "categoryId": { + "description": "分类ID", + "type": "string" + }, + "coverId": { + "description": "封面图URL", + "type": "string" + }, + "description": { + "description": "频道描述", + "type": "string" + }, + "id": { + "description": "频道ID", + "type": "string" + }, + "isFree": { + "type": "integer" + }, + "isVipOnly": { + "description": "是否vip专享", + "type": "integer" + }, + "monthlyPrice": { + "description": "包月价格", + "type": "integer" + }, + "name": { + "description": "频道名称", + "type": "string" + }, + "quarterlyPrice": { + "description": "包季价格", + "type": "integer" + }, + "sort": { + "description": "排序", + "type": "integer" + }, + "status": { + "description": "状态", + "type": "integer" + }, + "tags": { + "description": "标签", + "type": "string" + } + } + }, + "request.UpdateProgram": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "audioId": { + "description": "音频URL", + "type": "string" + }, + "channelId": { + "description": "频道ID", + "type": "string" + }, + "content": { + "type": "string" + }, + "coverId": { + "description": "封面图URL", + "type": "string" + }, + "description": { + "description": "节目描述", + "type": "string" + }, + "duration": { + "description": "时长(秒)", + "type": "integer" + }, + "id": { + "description": "节目ID", + "type": "string" + }, + "status": { + "description": "状态", + "type": "integer" + }, + "tags": { + "description": "标签", + "type": "string" + }, + "title": { + "description": "节目标题", + "type": "string" + } + } + }, "response.CaptchaRes": { "type": "object", "properties": { @@ -2039,9 +3493,7 @@ }, "securityDefinitions": { "BearerAuth": { - "type": "apiKey", - "name": "Authorization", - "in": "header" + "type": "basic" } } } \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml index b84d07f..a562405 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1,4 +1,42 @@ +basePath: / definitions: + request.AddComment: + properties: + content: + description: 评论内容 + type: string + parentId: + description: 父评论ID + type: string + programId: + description: 节目ID + type: string + required: + - content + - programId + type: object + request.AddFavorite: + properties: + programId: + description: 节目ID + type: string + required: + - programId + type: object + request.AddHistory: + properties: + duration: + description: 节目总时长(秒) + type: integer + programId: + description: 节目ID + type: string + progress: + description: 播放进度(秒) + type: integer + required: + - programId + type: object request.ChangePwd: properties: id: @@ -6,6 +44,59 @@ definitions: newPwd: type: string type: object + request.DeleteComment: + properties: + commentId: + description: 评论ID + type: string + required: + - commentId + type: object + request.GetById: + properties: + id: + description: 主键ID + type: string + type: object + request.GetCategoryList: + properties: + current: + description: 页码 + type: integer + keyword: + description: 关键字 + type: string + name: + description: 分类名称 + type: string + pageSize: + description: 每页大小 + type: integer + status: + description: 状态 + type: integer + type: object + request.GetChannelList: + properties: + categoryId: + description: 分类ID + type: string + current: + description: 页码 + type: integer + keyword: + description: 关键字 + type: string + name: + description: 频道名称 + type: string + pageSize: + description: 每页大小 + type: integer + status: + description: 状态 + type: integer + type: object request.GetClientList: properties: clientId: @@ -22,6 +113,45 @@ definitions: description: 每页大小 type: integer type: object + request.GetCommentList: + properties: + current: + description: 页码 + type: integer + keyword: + description: 关键字 + type: string + pageSize: + description: 每页大小 + type: integer + programId: + description: 节目ID + type: string + type: object + request.GetFavoriteList: + properties: + current: + description: 页码 + type: integer + keyword: + description: 关键字 + type: string + pageSize: + description: 每页大小 + type: integer + type: object + request.GetHistoryList: + properties: + current: + description: 页码 + type: integer + keyword: + description: 关键字 + type: string + pageSize: + description: 每页大小 + type: integer + type: object request.GetMenuTree: properties: category: @@ -43,6 +173,29 @@ definitions: description: 每页大小 type: integer type: object + request.GetProgramList: + properties: + channelId: + description: 频道ID + type: string + current: + description: 页码 + type: integer + keyword: + description: 关键字 + type: string + pageSize: + description: 每页大小 + type: integer + status: + description: 状态 + type: integer + title: + description: 节目标题 + type: string + required: + - channelId + type: object request.GetRoleList: properties: code: @@ -59,6 +212,18 @@ definitions: description: 每页大小 type: integer type: object + request.GetSubscriptionList: + properties: + current: + description: 页码 + type: integer + keyword: + description: 关键字 + type: string + pageSize: + description: 每页大小 + type: integer + type: object request.GetUserList: properties: account: @@ -111,6 +276,238 @@ definitions: password: type: string type: object + request.RemoveFavorite: + properties: + programId: + description: 节目ID + type: string + required: + - programId + type: object + request.SaveCategory: + properties: + coverId: + description: 封面图URL + type: string + description: + description: 分类描述 + type: string + iconId: + description: 图标URL + type: string + name: + description: 分类名称 + type: string + sort: + description: 排序 + type: integer + status: + description: 状态 + type: integer + required: + - name + type: object + request.SaveChannel: + properties: + annualPrice: + description: 包季价格 + type: integer + categoryId: + description: 分类ID + type: string + coverId: + description: 封面图URL + type: string + description: + description: 频道描述 + type: string + isFree: + description: 是否永久免费 + type: integer + isVipOnly: + description: 是否vip专享 + type: integer + monthlyPrice: + description: 包月价格 + type: integer + name: + description: 频道名称 + type: string + quarterlyPrice: + description: 包季价格 + type: integer + sort: + description: 排序 + type: integer + status: + description: 状态 + type: integer + tags: + description: 标签 + type: string + required: + - categoryId + - name + type: object + request.SaveProgram: + properties: + audioId: + description: 音频URL + type: string + channelId: + description: 频道ID + type: string + content: + type: string + coverId: + description: 封面图URL + type: string + description: + description: 节目描述 + type: string + duration: + description: 时长(秒) + type: integer + status: + description: 状态 + type: integer + tags: + description: 标签 + type: string + title: + description: 节目标题 + type: string + required: + - channelId + - title + type: object + request.SubscribeChannel: + properties: + channelId: + description: 频道ID + type: string + required: + - channelId + type: object + request.ToggleLike: + properties: + programId: + description: 节目ID + type: string + required: + - programId + type: object + request.UnsubscribeChannel: + properties: + channelId: + description: 频道ID + type: string + required: + - channelId + type: object + request.UpdateCategory: + properties: + coverId: + description: 封面图URL + type: string + description: + description: 分类描述 + type: string + iconId: + description: 图标URL + type: string + id: + description: 分类ID + type: string + name: + description: 分类名称 + type: string + sort: + description: 排序 + type: integer + status: + description: 状态 + type: integer + required: + - id + type: object + request.UpdateChannel: + properties: + annualPrice: + description: 包季价格 + type: integer + categoryId: + description: 分类ID + type: string + coverId: + description: 封面图URL + type: string + description: + description: 频道描述 + type: string + id: + description: 频道ID + type: string + isFree: + type: integer + isVipOnly: + description: 是否vip专享 + type: integer + monthlyPrice: + description: 包月价格 + type: integer + name: + description: 频道名称 + type: string + quarterlyPrice: + description: 包季价格 + type: integer + sort: + description: 排序 + type: integer + status: + description: 状态 + type: integer + tags: + description: 标签 + type: string + required: + - id + type: object + request.UpdateProgram: + properties: + audioId: + description: 音频URL + type: string + channelId: + description: 频道ID + type: string + content: + type: string + coverId: + description: 封面图URL + type: string + description: + description: 节目描述 + type: string + duration: + description: 时长(秒) + type: integer + id: + description: 节目ID + type: string + status: + description: 状态 + type: integer + tags: + description: 标签 + type: string + title: + description: 节目标题 + type: string + required: + - id + type: object response.CaptchaRes: properties: captcha: @@ -452,7 +849,7 @@ paths: type: string type: object security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 删除client tags: - 客户端管理 @@ -480,7 +877,7 @@ paths: type: string type: object security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 获取client详情 tags: - 客户端管理 @@ -510,7 +907,7 @@ paths: type: string type: object security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 获取client列表 tags: - 客户端管理 @@ -538,7 +935,7 @@ paths: type: string type: object security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 创建client tags: - 客户端管理 @@ -566,7 +963,7 @@ paths: type: string type: object security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 更新client tags: - 客户端管理 @@ -592,7 +989,7 @@ paths: type: string type: object security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 删除menu tags: - 菜单管理 @@ -620,7 +1017,7 @@ paths: type: string type: object security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 获取menu详情 tags: - 菜单管理 @@ -652,7 +1049,7 @@ paths: type: string type: object security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 获取所有菜单树 tags: - 菜单管理 @@ -675,7 +1072,7 @@ paths: type: string type: object security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 用户菜单数据 tags: - 菜单管理 @@ -698,7 +1095,7 @@ paths: type: string type: object security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 用户路由 tags: - 菜单管理 @@ -725,7 +1122,7 @@ paths: type: string type: object security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 新增菜单 tags: - 菜单管理 @@ -752,7 +1149,7 @@ paths: type: string type: object security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 更新菜单 tags: - 菜单管理 @@ -864,6 +1261,577 @@ paths: summary: 文件上传 tags: - 文件相关 + /radio/category/delete: + post: + parameters: + - description: 分类ID + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.GetById' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 删除分类 + tags: + - 分类管理 + /radio/category/detail: + get: + parameters: + - description: 分类ID + in: query + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 获取分类详情 + tags: + - 分类管理 + /radio/category/list: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 获取分类列表 + tags: + - 分类管理 + /radio/category/page: + post: + consumes: + - application/json + parameters: + - description: 分页查询 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.GetCategoryList' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 获取分类列表 + tags: + - 分类管理 + /radio/category/save: + post: + consumes: + - application/json + parameters: + - description: 分类信息 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.SaveCategory' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 保存分类 + tags: + - 分类管理 + /radio/category/tree: + get: + consumes: + - application/json + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 获取分类列表 + tags: + - 分类管理 + /radio/category/update: + post: + consumes: + - application/json + parameters: + - description: Success 200 {分类信息 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.UpdateCategory' + produces: + - application/json + responses: {} + summary: 更新分类 + tags: + - 分类管理 + /radio/channel/delete: + post: + parameters: + - description: 频道ID + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.GetById' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 删除频道 + tags: + - 频道管理 + /radio/channel/detail: + get: + consumes: + - application/json + parameters: + - description: 频道ID + in: query + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 获取频道详情 + tags: + - 频道管理 + /radio/channel/list: + post: + consumes: + - application/json + parameters: + - description: 分页查询 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.GetChannelList' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 获取频道列表 + tags: + - 频道管理 + /radio/channel/save: + post: + consumes: + - application/json + parameters: + - description: 频道信息 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.SaveChannel' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 保存频道 + tags: + - 频道管理 + /radio/channel/update: + post: + consumes: + - application/json + parameters: + - description: 频道信息 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.UpdateChannel' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 更新频道 + tags: + - 频道管理 + /radio/comment/add: + post: + parameters: + - description: 评论信息 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.AddComment' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 添加评论 + tags: + - 用户互动 + /radio/comment/delete: + post: + parameters: + - description: 评论ID + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.DeleteComment' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 删除评论 + tags: + - 用户互动 + /radio/comment/list: + post: + parameters: + - description: 分页查询 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.GetCommentList' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 获取评论列表 + tags: + - 用户互动 + /radio/favorite/add: + post: + parameters: + - description: 节目ID + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.AddFavorite' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 添加收藏 + tags: + - 用户互动 + /radio/favorite/list: + post: + parameters: + - description: 分页查询 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.GetFavoriteList' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 获取收藏列表 + tags: + - 用户互动 + /radio/favorite/remove: + post: + parameters: + - description: 节目ID + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.RemoveFavorite' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 取消收藏 + tags: + - 用户互动 + /radio/history/add: + post: + parameters: + - description: 收听信息 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.AddHistory' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 添加收听历史 + tags: + - 用户互动 + /radio/history/list: + post: + parameters: + - description: 分页查询 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.GetHistoryList' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 获取收听历史列表 + tags: + - 用户互动 + /radio/like/toggle: + post: + parameters: + - description: 节目ID + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.ToggleLike' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 切换点赞状态 + tags: + - 用户互动 + /radio/program/delete: + post: + parameters: + - description: 节目ID + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.GetById' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 删除节目 + tags: + - 节目管理 + /radio/program/detail: + get: + parameters: + - description: 节目ID + in: query + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 获取节目详情 + tags: + - 节目管理 + /radio/program/list: + post: + parameters: + - description: 分页查询 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.GetProgramList' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 获取节目列表 + tags: + - 节目管理 + /radio/program/save: + post: + consumes: + - application/json + parameters: + - description: 节目信息 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.SaveProgram' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 保存节目 + tags: + - 节目管理 + /radio/program/update: + post: + consumes: + - application/json + parameters: + - description: 节目信息 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.UpdateProgram' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 更新节目 + tags: + - 节目管理 + /radio/subscription/can-subscribe: + post: + parameters: + - description: 频道ID + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.SubscribeChannel' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 检查是否可以订阅 + tags: + - 订阅管理 + /radio/subscription/list: + post: + consumes: + - application/json + parameters: + - description: 分页查询 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.GetSubscriptionList' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 获取我的订阅列表 + tags: + - 订阅管理 + /radio/subscription/subscribe: + post: + parameters: + - description: 频道ID + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.SubscribeChannel' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 订阅频道 + tags: + - 订阅管理 + /radio/subscription/unsubscribe: + post: + parameters: + - description: 频道ID + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.UnsubscribeChannel' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + summary: 退订频道 + tags: + - 订阅管理 /role/delete: post: consumes: @@ -912,7 +1880,7 @@ paths: $ref: '#/definitions/system.Role' type: object security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 角色详情 tags: - 角色管理 @@ -964,7 +1932,7 @@ paths: schema: $ref: '#/definitions/response.Response' security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 授权菜单给角色 tags: - 角色管理 @@ -987,7 +1955,7 @@ paths: schema: $ref: '#/definitions/response.Response' security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 创建角色 tags: - 角色管理 @@ -1010,7 +1978,7 @@ paths: schema: $ref: '#/definitions/response.Response' security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 修改角色 tags: - 角色管理 @@ -1039,7 +2007,7 @@ paths: $ref: '#/definitions/system.User' type: object security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 修改密码 tags: - 用户管理 @@ -1067,7 +2035,7 @@ paths: type: string type: object security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 删除用户 tags: - 用户管理 @@ -1092,7 +2060,7 @@ paths: $ref: '#/definitions/system.User' type: object security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 获取用户详情 tags: - 用户管理 @@ -1122,7 +2090,7 @@ paths: type: string type: object security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 获取用户列表 tags: - 用户管理 @@ -1145,7 +2113,7 @@ paths: schema: $ref: '#/definitions/response.Response' security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 给用户分配角色 tags: - 用户管理 @@ -1159,7 +2127,7 @@ paths: schema: $ref: '#/definitions/response.Response' security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 当前登录用户 tags: - 用户管理 @@ -1182,7 +2150,7 @@ paths: schema: $ref: '#/definitions/response.Response' security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 新增用户 tags: - 用户管理 @@ -1205,13 +2173,11 @@ paths: schema: $ref: '#/definitions/response.Response' security: - - ApiKeyAuth: [] + - BasicAuth: [] summary: 更新用户 tags: - 用户管理 securityDefinitions: BearerAuth: - in: header - name: Authorization - type: apiKey + type: basic swagger: "2.0" diff --git a/model/radio/radio_category.go b/model/radio/radio_category.go index 6745b2e..4cb89da 100644 --- a/model/radio/radio_category.go +++ b/model/radio/radio_category.go @@ -8,14 +8,15 @@ import ( // RadioCategory 电台分类表 type RadioCategory struct { global.BaseModel - Name string `gorm:"size:50" json:"name"` // 分类名称 - Description string `gorm:"size:255" json:"description"` // 分类描述 - IconId string `gorm:"size:50" json:"iconId"` // 图标OSS ID - Icon *system.Oss `gorm:"foreignKey:IconId" json:"icon"` // 图标OSS - CoverId string `gorm:"size:50" json:"coverId"` // 封面图OSS ID - Cover *system.Oss `gorm:"foreignKey:CoverId" json:"cover"` // 封面图OSS - Sort int `gorm:"default:0" json:"sort"` // 排序 - Status int `gorm:"default:1" json:"status"` // 状态 0:禁用 1:启用 + Name string `gorm:"size:50" json:"name"` // 分类名称 + Description string `gorm:"size:255" json:"description"` // 分类描述 + IconId string `gorm:"size:50" json:"iconId"` // 图标OSS ID + Icon *system.Oss `gorm:"foreignKey:IconId" json:"icon"` // 图标OSS + CoverId string `gorm:"size:50" json:"coverId"` // 封面图OSS ID + Cover *system.Oss `gorm:"foreignKey:CoverId" json:"cover"` // 封面图OSS + Sort int `gorm:"default:0" json:"sort"` // 排序 + Status int `gorm:"default:1" json:"status"` // 状态 0:禁用 1:启用 + Channels []*RadioChannel `gorm:"foreignKey:CategoryId" json:"channels"` } func (RadioCategory) TableName() string { diff --git a/model/radio/radio_channel.go b/model/radio/radio_channel.go index ca02696..76730d7 100644 --- a/model/radio/radio_channel.go +++ b/model/radio/radio_channel.go @@ -8,17 +8,21 @@ import ( // RadioChannel 电台频道表 type RadioChannel struct { global.BaseModel - CategoryId string `gorm:"size:50;index" json:"categoryId"` // 分类ID - Name string `gorm:"size:50" json:"name"` // 频道名称 - Description string `gorm:"size:500" json:"description"` // 频道描述 - Price int `gorm:"default:0;comment:价格,单位,分 " json:"price"` //价格 单位:分 - CoverId string `gorm:"size:50" json:"coverId"` // 封面图OSS ID - Cover *system.Oss `gorm:"foreignKey:CoverId" json:"cover"` // 封面图OSS - Tags string `gorm:"size:255" json:"tags"` // 标签,逗号分隔 - IsVipOnly int `gorm:"default:0" json:"isVipOnly"` // 是否VIP专享 0:否 1:是 - Sort int `gorm:"default:0" json:"sort"` // 排序 - Status int `gorm:"default:1" json:"status"` // 状态 0:禁用 1:启用 - HasSubscribed int `gorm:"-" json:"hasSubscribed"` // 状态 0:未订阅 1:已订阅 + CategoryId string `gorm:"size:50;index" json:"categoryId"` // 分类ID + Name string `gorm:"size:50" json:"name"` // 频道名称 + Description string `gorm:"size:500" json:"description"` // 频道描述 + IsFree int `gorm:"default:0" json:"isFree"` //是否永久免费 0:否 1:是 + IsVipOnly int `gorm:"default:0" json:"isVipOnly"` // 是否VIP专享 0:否 1:是 + MonthlyPrice int `gorm:"default:0;comment:价格,单位,分 " json:"monthlyPrice"` //包月价格 单位:分 + QuarterlyPrice int `gorm:"default:0;comment:价格,单位,分 " json:"quarterlyPrice"` //包季度价格 单位:分 + AnnualPrice int `gorm:"default:0;comment:价格,单位,分 " json:"annualPrice"` //包年价格 单位:分 + CoverId string `gorm:"size:50" json:"coverId"` // 封面图OSS ID + Cover *system.Oss `gorm:"foreignKey:CoverId" json:"cover"` // 封面图OSS + Tags string `gorm:"size:255" json:"tags"` // 标签,逗号分隔 + Sort int `gorm:"default:0" json:"sort"` // 排序 + Status int `gorm:"default:1" json:"status"` // 状态 0:禁用 1:启用 + HasSubscribed int `gorm:"-" json:"hasSubscribed"` // 状态 0:未订阅 1:已订阅 + Programs []*RadioProgram `gorm:"foreignKey:ChannelId" json:"programs"` //频道下的节目 } func (RadioChannel) TableName() string { diff --git a/model/radio/radio_history.go b/model/radio/radio_history.go index ad092fd..042aba2 100644 --- a/model/radio/radio_history.go +++ b/model/radio/radio_history.go @@ -7,10 +7,11 @@ import ( // RadioHistory 用户收听历史表 type RadioHistory struct { global.BaseModel - UserId string `gorm:"size:50;index" json:"userId"` // 用户ID - ProgramId string `gorm:"size:50;index" json:"programId"` // 节目ID - Progress int `gorm:"default:0" json:"progress"` // 播放进度(秒) - Duration int `gorm:"default:0" json:"duration"` // 节目总时长(秒) + UserId string `gorm:"size:50;index" json:"userId"` // 用户ID + ProgramId string `gorm:"size:50;index" json:"programId"` // 节目ID + Progress int `gorm:"default:0" json:"progress"` // 播放进度(秒) + Duration int `gorm:"default:0" json:"duration"` // 节目总时长(秒) + RadioProgram *RadioProgram `gorm:"foreignKey:ProgramId" json:"program"` } func (RadioHistory) TableName() string { diff --git a/model/radio/radio_program.go b/model/radio/radio_program.go index 711d389..9ffdeaf 100644 --- a/model/radio/radio_program.go +++ b/model/radio/radio_program.go @@ -8,19 +8,20 @@ import ( // RadioProgram 电台节目表 type RadioProgram struct { global.BaseModel - ChannelId string `gorm:"size:50;index" json:"channelId"` // 频道ID - Title string `gorm:"size:100" json:"title"` // 节目标题 - Description string `gorm:"size:500" json:"description"` // 节目描述 - Content string `gorm:"type:text" json:"content"` - CoverId string `gorm:"size:50" json:"coverId"` // 封面图OSS ID - Cover *system.Oss `gorm:"foreignKey:CoverId" json:"coverUrl"` // 封面图OSS - AudioId string `gorm:"size:50" json:"audioId"` // 音频OSS ID - Audio *system.Oss `gorm:"foreignKey:AudioId" json:"audio"` // 音频OSS - Duration int `gorm:"default:0" json:"duration"` // 时长(秒) - Tags string `gorm:"size:255" json:"tags"` // 标签,逗号分隔 - PlayCount int `gorm:"default:0" json:"playCount"` // 播放次数 - LikeCount int `gorm:"default:0" json:"likeCount"` // 点赞次数 - Status int `gorm:"default:1" json:"status"` // 状态 0:下架 1:上架 + ChannelId string `gorm:"size:50;index" json:"channelId"` // 频道ID + Title string `gorm:"size:100" json:"title"` // 节目标题 + Description string `gorm:"size:500" json:"description"` // 节目描述 + Content string `gorm:"type:text" json:"content"` + CoverId string `gorm:"size:50" json:"coverId"` // 封面图OSS ID + Cover *system.Oss `gorm:"foreignKey:CoverId" json:"cover"` // 封面图OSS + AudioId string `gorm:"size:50" json:"audioId"` // 音频OSS ID + Audio *system.Oss `gorm:"foreignKey:AudioId" json:"audio"` // 音频OSS + Duration int `gorm:"default:0" json:"duration"` // 时长(秒) + Tags string `gorm:"size:255" json:"tags"` // 标签,逗号分隔 + PlayCount int `gorm:"default:0" json:"playCount"` // 播放次数 + LikeCount int `gorm:"default:0" json:"likeCount"` // 点赞次数 + Status int `gorm:"default:1" json:"status"` // 状态 0:下架 1:上架 + Channel *RadioChannel `gorm:"foreignKey:ChannelId" json:"channel"` } func (RadioProgram) TableName() string { diff --git a/model/radio/radio_subscription.go b/model/radio/radio_subscription.go index beeb3de..dfb943c 100644 --- a/model/radio/radio_subscription.go +++ b/model/radio/radio_subscription.go @@ -7,9 +7,10 @@ import ( // RadioSubscription 用户订阅表 type RadioSubscription struct { global.BaseModel - UserId string `gorm:"size:50;index;not null;uniqueIndex:idx_user_channel" json:"userId"` // 用户ID - ChannelId string `gorm:"size:50;index;uniqueIndex:idx_user_channel" json:"channelId"` // 频道ID - Status int `gorm:"type:tinyint;default:1"` //1-订阅中,2-已取消 + UserId string `gorm:"size:50;index;not null;uniqueIndex:idx_user_channel" json:"userId"` // 用户ID + ChannelId string `gorm:"size:50;index;uniqueIndex:idx_user_channel" json:"channelId"` // 频道ID + Status int `gorm:"type:tinyint;default:1"` //1-订阅中,2-已取消 + Channel *RadioChannel `gorm:"foreignKey:ChannelId" json:"channel"` } func (RadioSubscription) TableName() string { diff --git a/model/radio/request/category.go b/model/radio/request/category.go index 4769fbe..1636ee7 100644 --- a/model/radio/request/category.go +++ b/model/radio/request/category.go @@ -11,7 +11,6 @@ type GetCategoryList struct { // SaveCategory 保存分类请求 type SaveCategory struct { - Id string `json:"id" form:"id"` // 分类ID(更新时使用) Name string `json:"name" binding:"required"` // 分类名称 Description string `json:"description"` // 分类描述 IconId string `json:"iconId"` // 图标URL diff --git a/model/radio/request/channel.go b/model/radio/request/channel.go index ce1c9f2..925a243 100644 --- a/model/radio/request/channel.go +++ b/model/radio/request/channel.go @@ -12,26 +12,33 @@ type GetChannelList struct { // SaveChannel 保存频道请求 type SaveChannel struct { - Id string `json:"id" form:"id"` // 频道ID(更新时使用) - CategoryId string `json:"categoryId" binding:"required"` // 分类ID - Name string `json:"name" binding:"required"` // 频道名称 - Description string `json:"description"` // 频道描述 - CoverId string `json:"coverId"` // 封面图URL - Tags string `json:"tags"` // 标签 - IsVipOnly int `json:"isVipOnly"` // 是否VIP专享 - Sort int `json:"sort"` // 排序 - Status int `json:"status"` // 状态 + CategoryId string `json:"categoryId" binding:"required"` // 分类ID + Name string `json:"name" binding:"required"` // 频道名称 + Description string `json:"description"` // 频道描述 + CoverId string `json:"coverId"` // 封面图URL + Tags string `json:"tags"` // 标签 + IsFree int `json:"isFree"` //是否永久免费 + IsVipOnly int `json:"isVipOnly"` //是否vip专享 + MonthlyPrice int `json:"monthlyPrice"` //包月价格 + QuarterlyPrice int `json:"quarterlyPrice"` //包季价格 + AnnualPrice int `json:"annualPrice"` //包季价格 + Sort int `json:"sort"` // 排序 + Status int `json:"status"` // 状态 } // UpdateChannel 更新频道请求 type UpdateChannel struct { - Id string `json:"id" binding:"required"` // 频道ID - CategoryId string `json:"categoryId"` // 分类ID - Name string `json:"name"` // 频道名称 - Description string `json:"description"` // 频道描述 - CoverId string `json:"coverId"` // 封面图URL - Tags string `json:"tags"` // 标签 - IsVipOnly int `json:"isVipOnly"` // 是否VIP专享 - Sort int `json:"sort"` // 排序 - Status int `json:"status"` // 状态 + Id string `json:"id" binding:"required"` // 频道ID + CategoryId string `json:"categoryId"` // 分类ID + Name string `json:"name"` // 频道名称 + Description string `json:"description"` // 频道描述 + CoverId string `json:"coverId"` // 封面图URL + Tags string `json:"tags"` // 标签 + IsFree int `json:"isFree"` + IsVipOnly int `json:"isVipOnly"` //是否vip专享 + MonthlyPrice int `json:"monthlyPrice"` //包月价格 + QuarterlyPrice int `json:"quarterlyPrice"` //包季价格 + AnnualPrice int `json:"annualPrice"` //包季价格 + Sort int `json:"sort"` // 排序 + Status int `json:"status"` // 状态 } diff --git a/model/radio/request/program.go b/model/radio/request/program.go index 72e9476..8d538a9 100644 --- a/model/radio/request/program.go +++ b/model/radio/request/program.go @@ -5,14 +5,13 @@ import common "sundynix-go/model/commom/request" // GetProgramList 获取节目列表请求 type GetProgramList struct { common.PageInfo - ChannelId string `json:"channelId" form:"channelId"` // 频道ID - Title string `json:"title" form:"title"` // 节目标题 - Status int `json:"status" form:"status"` // 状态 + ChannelId string `json:"channelId" binding:"required" form:"channelId"` // 频道ID + Title string `json:"title" form:"title"` // 节目标题 + Status int `json:"status" form:"status"` // 状态 } // SaveProgram 保存节目请求 type SaveProgram struct { - Id string `json:"id" form:"id"` // 节目ID(更新时使用) ChannelId string `json:"channelId" binding:"required"` // 频道ID Title string `json:"title" binding:"required"` // 节目标题 Description string `json:"description"` // 节目描述 diff --git a/router/radio/category_router.go b/router/radio/category_router.go index 2f8943c..12f56f5 100644 --- a/router/radio/category_router.go +++ b/router/radio/category_router.go @@ -10,7 +10,8 @@ func (r *CategoryRouter) InitCategoryRouter(Router *gin.RouterGroup) { categoryRouter := Router.Group("/radio/category") { categoryRouter.POST("page", categoryApi.GetCategoryPage) - categoryRouter.POST("list", categoryApi.GetCategoryList) + categoryRouter.GET("tree", categoryApi.GetCategoryTree) + categoryRouter.GET("list", categoryApi.GetCategoryList) categoryRouter.GET("detail", categoryApi.GetCategoryDetail) categoryRouter.POST("save", categoryApi.SaveCategory) categoryRouter.POST("update", categoryApi.UpdateCategory) diff --git a/router/radio/channel_router.go b/router/radio/channel_router.go index a4d52ff..dbe3d8f 100644 --- a/router/radio/channel_router.go +++ b/router/radio/channel_router.go @@ -10,6 +10,7 @@ func (r *ChannelRouter) InitChannelRouter(Router *gin.RouterGroup) { channelRouter := Router.Group("/radio/channel") { channelRouter.POST("list", channelApi.GetChannelList) + channelRouter.POST("freeList", channelApi.GetFreeChannelList) channelRouter.GET("detail", channelApi.GetChannelDetail) channelRouter.POST("save", channelApi.SaveChannel) channelRouter.POST("update", channelApi.UpdateChannel) diff --git a/service/radio/category_service.go b/service/radio/category_service.go index 553a58b..8522160 100644 --- a/service/radio/category_service.go +++ b/service/radio/category_service.go @@ -34,9 +34,26 @@ func (s *CategoryService) GetCategoryList(info radioReq.GetCategoryList) ([]radi return list, total, err } +// GetCategoryTree 返回带频道的分类树 +func (s *CategoryService) GetCategoryTree() ([]radio.RadioCategory, error) { + var res []radio.RadioCategory + + // 1. 查询分类并预加载关联的频道 + // Preload("Channels") 会自动根据 CategoryId 匹配 + // Preload("Icon") 和 Preload("Cover") 用于加载 OSS 信息 + err := global.DB.Model(&radio.RadioCategory{}). + Preload("Channels", "status = ?", 1). // 只加载启用的频道 + Preload("Channels.Cover"). // 级联加载频道的封面 + Preload("Icon"). + Preload("Cover"). + Order("sort desc"). + Find(&res).Error + return res, err +} + func (s *CategoryService) GetAllCategory() ([]radio.RadioCategory, error) { var res []radio.RadioCategory - err := global.DB.Find(&res).Preload(":Icon").Preload("Cover").Error + err := global.DB.Find(&res).Preload("Icon").Preload("Cover").Error return res, err } diff --git a/service/radio/channel_service.go b/service/radio/channel_service.go index 8d0d896..e3ca290 100644 --- a/service/radio/channel_service.go +++ b/service/radio/channel_service.go @@ -2,8 +2,8 @@ package radio import ( "errors" - "sundynix-go/global" + common "sundynix-go/model/commom/request" "sundynix-go/model/radio" radioReq "sundynix-go/model/radio/request" @@ -12,6 +12,23 @@ import ( type ChannelService struct{} +func (s *ChannelService) GetFreeChannelList(req common.PageInfo) ([]radio.RadioChannel, int64, error) { + db := global.DB.Model(&radio.RadioChannel{}).Where("is_free = 1") + var list []radio.RadioChannel + var total int64 + err := db.Count(&total).Error + if err != nil { + return nil, 0, err + } + + offset := (req.Current - 1) * req.PageSize + err = db.Offset(offset).Limit(req.PageSize).Order("sort ASC").Find(&list).Error + if err != nil { + return nil, 0, err + } + return list, total, nil +} + // GetChannelList 获取频道列表 func (s *ChannelService) GetChannelList(userId string, info radioReq.GetChannelList) ([]radio.RadioChannel, int64, error) { db := global.DB.Model(&radio.RadioChannel{}) @@ -34,33 +51,19 @@ func (s *ChannelService) GetChannelList(userId string, info radioReq.GetChannelL } offset := (info.Current - 1) * info.PageSize - err = db.Offset(offset).Limit(info.PageSize).Order("sort ASC").Find(&list).Error + err = db.Offset(offset).Limit(info.PageSize).Order("is_free desc,sort ASC").Find(&list).Error if err != nil { return nil, 0, err } - - // 批量查询用户订阅的频道,避免N+1问题 - if userId != "" { - subService := &SubscriptionService{} - subscribedChannelIds, _ := subService.GetUserSubscriptionHistory(userId) - // 转换为map以便快速查找 - subscribedMap := make(map[string]bool) - for _, cid := range subscribedChannelIds { - subscribedMap[cid] = true - } - // 填充HasSubscribed字段 - for i := range list { - if subscribedMap[list[i].Id] { - list[i].HasSubscribed = 1 - } else { - list[i].HasSubscribed = 0 - } - } - } - return list, total, nil } +func (s *ChannelService) GetAllChannelList(categoryId, userId string) ([]radio.RadioChannel, error) { + var res []radio.RadioChannel + err := global.DB.Where("category_id = ?", categoryId).Find(&res).Preload("Cover").Error + return res, err +} + // GetChannelById 获取频道详情 func (s *ChannelService) GetChannelById(userId, id string) (radio.RadioChannel, error) { var channel radio.RadioChannel @@ -68,32 +71,23 @@ func (s *ChannelService) GetChannelById(userId, id string) (radio.RadioChannel, if err != nil { return channel, err } - - // 填充HasSubscribed字段 - if userId != "" { - subService := &SubscriptionService{} - hasSub, _ := subService.HasSubscription(userId, channel.Id) - if hasSub { - channel.HasSubscribed = 1 - } else { - channel.HasSubscribed = 0 - } - } - return channel, nil } // SaveChannel 保存频道 func (s *ChannelService) SaveChannel(req radioReq.SaveChannel) error { channel := radio.RadioChannel{ - CategoryId: req.CategoryId, - Name: req.Name, - Description: req.Description, - CoverId: req.CoverId, - Tags: req.Tags, - IsVipOnly: req.IsVipOnly, - Sort: req.Sort, - Status: req.Status, + CategoryId: req.CategoryId, + Name: req.Name, + Description: req.Description, + CoverId: req.CoverId, + Tags: req.Tags, + IsVipOnly: req.IsVipOnly, + MonthlyPrice: req.MonthlyPrice, + QuarterlyPrice: req.QuarterlyPrice, + AnnualPrice: req.AnnualPrice, + Sort: req.Sort, + Status: req.Status, } return global.DB.Create(&channel).Error } @@ -101,14 +95,17 @@ func (s *ChannelService) SaveChannel(req radioReq.SaveChannel) error { // UpdateChannel 更新频道 func (s *ChannelService) UpdateChannel(req radioReq.UpdateChannel) error { updates := map[string]interface{}{ - "category_id": req.CategoryId, - "name": req.Name, - "description": req.Description, - "cover_id": req.CoverId, - "tags": req.Tags, - "is_vip_only": req.IsVipOnly, - "sort": req.Sort, - "status": req.Status, + "category_id": req.CategoryId, + "name": req.Name, + "description": req.Description, + "cover_id": req.CoverId, + "tags": req.Tags, + "is_vip_only": req.IsVipOnly, + "monthly_price": req.MonthlyPrice, + "quarterly_price": req.QuarterlyPrice, + "annual_price": req.AnnualPrice, + "sort": req.Sort, + "status": req.Status, } return global.DB.Model(&radio.RadioChannel{}).Where("id = ?", req.Id).Updates(updates).Error } diff --git a/service/radio/interaction_service.go b/service/radio/interaction_service.go index 2b5f241..72af6e1 100644 --- a/service/radio/interaction_service.go +++ b/service/radio/interaction_service.go @@ -41,7 +41,7 @@ func (s *InteractionService) AddHistory(userId string, req radioReq.AddHistory) // GetHistoryList 获取收听历史列表 func (s *InteractionService) GetHistoryList(userId string, info radioReq.GetHistoryList) ([]radio.RadioHistory, int64, error) { - db := global.DB.Model(&radio.RadioHistory{}).Where("user_id = ?", userId) + db := global.DB.Model(&radio.RadioHistory{}).Where("user_id = ?", userId).Preload("RadioProgram") var list []radio.RadioHistory var total int64 diff --git a/service/radio/subscription_service.go b/service/radio/subscription_service.go index 07fafa7..7ef511e 100644 --- a/service/radio/subscription_service.go +++ b/service/radio/subscription_service.go @@ -16,18 +16,44 @@ const MaxFreeSubscription = 2 // GetUserSubscription 获取用户订阅列表 func (s *SubscriptionService) GetUserSubscription(userId string, info common.PageInfo) ([]radio.RadioSubscription, int64, error) { - db := global.DB.Model(&radio.RadioSubscription{}).Where("user_id = ?", userId) - var list []radio.RadioSubscription + var subscriptions []radio.RadioSubscription var total int64 - - err := db.Count(&total).Error + db := global.DB // 替换为你实际的 GORM 变量 + // 2. 统计该用户订阅的总数 (Status=1 表示订阅中) + err := db.Model(&radio.RadioSubscription{}). + Where("user_id = ? AND status = 1", userId). + Count(&total).Error if err != nil { return nil, 0, err } + // 3. 执行分页关联查询 + err = db.Model(&radio.RadioSubscription{}). + Where("user_id = ? AND status = 1", userId). + Limit(info.PageSize). + Offset((info.Current-1)*info.PageSize). + Order("created_at DESC"). + // 级联加载频道及其封面 + Preload("Channel"). + Preload("Channel.Cover"). + // 关键:子查询过滤——只预加载每个频道 ID 最大的那一条节目 + Preload("Channel.Programs", func(db *gorm.DB) *gorm.DB { + // 子查询:找到每个频道下 ID 最大的节目(通常 ID 越大代表越新,也可以用 CreatedAt) + subQuery := db.Table("sundynix_radio_program"). + Select("id"). + Where("status = 1"). // 只找上架的 + Where("created_at = (SELECT MAX(created_at) FROM sundynix_radio_program AS rp WHERE rp.channel_id = sundynix_radio_program.channel_id AND rp.status = 1)") - offset := (info.Current - 1) * info.PageSize - err = db.Offset(offset).Limit(info.PageSize).Order("created_at DESC").Find(&list).Error - return list, total, err + // 嵌套预加载:节目里的音频和封面也一并带出来 + return db.Where("id IN (?)", subQuery). + Preload("Cover"). + Preload("Audio") + }). + Find(&subscriptions).Error + + if err != nil { + return nil, total, err + } + return subscriptions, total, err } // GetUserSubscriptionHistory 获取用户历史订阅过的频道ID列表