init: init refactor
This commit is contained in:
@@ -0,0 +1,291 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.10.1
|
||||
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
analytics "sundynix-micro-go/app/radio/api/internal/handler/analytics"
|
||||
callback "sundynix-micro-go/app/radio/api/internal/handler/callback"
|
||||
category "sundynix-micro-go/app/radio/api/internal/handler/category"
|
||||
channel "sundynix-micro-go/app/radio/api/internal/handler/channel"
|
||||
interaction "sundynix-micro-go/app/radio/api/internal/handler/interaction"
|
||||
pay "sundynix-micro-go/app/radio/api/internal/handler/pay"
|
||||
program "sundynix-micro-go/app/radio/api/internal/handler/program"
|
||||
subscription "sundynix-micro-go/app/radio/api/internal/handler/subscription"
|
||||
vip "sundynix-micro-go/app/radio/api/internal/handler/vip"
|
||||
voice "sundynix-micro-go/app/radio/api/internal/handler/voice"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 频道数据
|
||||
Method: http.MethodPost,
|
||||
Path: "/analytics/channel",
|
||||
Handler: analytics.GetChannelAnalyticsHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 数据概览
|
||||
Method: http.MethodPost,
|
||||
Path: "/analytics/overview",
|
||||
Handler: analytics.GetAnalyticsOverviewHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 用户数据
|
||||
Method: http.MethodPost,
|
||||
Path: "/analytics/user",
|
||||
Handler: analytics.GetUserAnalyticsHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/radio"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 微信支付回调
|
||||
Method: http.MethodPost,
|
||||
Path: "/callback/wechatpay",
|
||||
Handler: callback.WechatPayCallbackHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/api/radio"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 创建分类
|
||||
Method: http.MethodPost,
|
||||
Path: "/category/create",
|
||||
Handler: category.CreateCategoryHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 删除分类
|
||||
Method: http.MethodDelete,
|
||||
Path: "/category/delete",
|
||||
Handler: category.DeleteCategoryHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 分类列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/category/list",
|
||||
Handler: category.GetCategoryListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 更新分类
|
||||
Method: http.MethodPut,
|
||||
Path: "/category/update",
|
||||
Handler: category.UpdateCategoryHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/radio"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 频道详情
|
||||
Method: http.MethodGet,
|
||||
Path: "/channel/:id",
|
||||
Handler: channel.GetChannelDetailHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 创建频道
|
||||
Method: http.MethodPost,
|
||||
Path: "/channel/create",
|
||||
Handler: channel.CreateChannelHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 删除频道
|
||||
Method: http.MethodDelete,
|
||||
Path: "/channel/delete",
|
||||
Handler: channel.DeleteChannelHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 频道列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/channel/list",
|
||||
Handler: channel.GetChannelListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 更新频道
|
||||
Method: http.MethodPut,
|
||||
Path: "/channel/update",
|
||||
Handler: channel.UpdateChannelHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/radio"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 评论节目
|
||||
Method: http.MethodPost,
|
||||
Path: "/interaction/comment",
|
||||
Handler: interaction.CommentProgramHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 收藏/取消收藏
|
||||
Method: http.MethodPost,
|
||||
Path: "/interaction/favorite",
|
||||
Handler: interaction.ToggleFavoriteHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 我的收藏列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/interaction/favorite/list",
|
||||
Handler: interaction.GetFavoriteListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 记录播放历史
|
||||
Method: http.MethodPost,
|
||||
Path: "/interaction/history",
|
||||
Handler: interaction.RecordHistoryHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 播放历史列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/interaction/history/list",
|
||||
Handler: interaction.GetHistoryListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 点赞/取消点赞
|
||||
Method: http.MethodPost,
|
||||
Path: "/interaction/like",
|
||||
Handler: interaction.ToggleLikeHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/radio"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 创建支付订单
|
||||
Method: http.MethodPost,
|
||||
Path: "/pay/create",
|
||||
Handler: pay.CreatePayOrderHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/radio"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 节目详情
|
||||
Method: http.MethodGet,
|
||||
Path: "/program/:id",
|
||||
Handler: program.GetProgramDetailHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 创建节目
|
||||
Method: http.MethodPost,
|
||||
Path: "/program/create",
|
||||
Handler: program.CreateProgramHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 删除节目
|
||||
Method: http.MethodDelete,
|
||||
Path: "/program/delete",
|
||||
Handler: program.DeleteProgramHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 节目列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/program/list",
|
||||
Handler: program.GetProgramListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// TTS生成音频
|
||||
Method: http.MethodPost,
|
||||
Path: "/program/tts",
|
||||
Handler: program.GenerateTtsHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 更新节目
|
||||
Method: http.MethodPut,
|
||||
Path: "/program/update",
|
||||
Handler: program.UpdateProgramHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/radio"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 我的订阅列表
|
||||
Method: http.MethodGet,
|
||||
Path: "/subscription/list",
|
||||
Handler: subscription.GetMySubscriptionsHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/radio"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 我的VIP信息
|
||||
Method: http.MethodGet,
|
||||
Path: "/vip/info",
|
||||
Handler: vip.GetMyVipInfoHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// VIP配置列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/vip/list",
|
||||
Handler: vip.GetVipConfigListHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/radio"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 创建音色
|
||||
Method: http.MethodPost,
|
||||
Path: "/voice/create",
|
||||
Handler: voice.CreateVoiceHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 删除音色
|
||||
Method: http.MethodDelete,
|
||||
Path: "/voice/delete",
|
||||
Handler: voice.DeleteVoiceHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 音色列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/voice/list",
|
||||
Handler: voice.GetVoiceListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 更新音色
|
||||
Method: http.MethodPut,
|
||||
Path: "/voice/update",
|
||||
Handler: voice.UpdateVoiceHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/radio"),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user