init: init refactor
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package analytics
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/analytics"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 数据概览
|
||||
func GetAnalyticsOverviewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AnalyticsReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := analytics.NewGetAnalyticsOverviewLogic(r.Context(), svcCtx)
|
||||
err := l.GetAnalyticsOverview(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package analytics
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/analytics"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 频道数据
|
||||
func GetChannelAnalyticsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AnalyticsReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := analytics.NewGetChannelAnalyticsLogic(r.Context(), svcCtx)
|
||||
err := l.GetChannelAnalytics(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package analytics
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/analytics"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 用户数据
|
||||
func GetUserAnalyticsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AnalyticsReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := analytics.NewGetUserAnalyticsLogic(r.Context(), svcCtx)
|
||||
err := l.GetUserAnalytics(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package callback
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/callback"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 微信支付回调
|
||||
func WechatPayCallbackHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := callback.NewWechatPayCallbackLogic(r.Context(), svcCtx)
|
||||
err := l.WechatPayCallback()
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package category
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/category"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 创建分类
|
||||
func CreateCategoryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.CategoryReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := category.NewCreateCategoryLogic(r.Context(), svcCtx)
|
||||
err := l.CreateCategory(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package category
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/category"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 删除分类
|
||||
func DeleteCategoryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdsReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := category.NewDeleteCategoryLogic(r.Context(), svcCtx)
|
||||
err := l.DeleteCategory(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package category
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/category"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 分类列表
|
||||
func GetCategoryListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.CategoryListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := category.NewGetCategoryListLogic(r.Context(), svcCtx)
|
||||
err := l.GetCategoryList(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package category
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/category"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 更新分类
|
||||
func UpdateCategoryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.CategoryUpdateReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := category.NewUpdateCategoryLogic(r.Context(), svcCtx)
|
||||
err := l.UpdateCategory(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package channel
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/channel"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 创建频道
|
||||
func CreateChannelHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ChannelReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := channel.NewCreateChannelLogic(r.Context(), svcCtx)
|
||||
err := l.CreateChannel(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package channel
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/channel"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 删除频道
|
||||
func DeleteChannelHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdsReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := channel.NewDeleteChannelLogic(r.Context(), svcCtx)
|
||||
err := l.DeleteChannel(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package channel
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/channel"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 频道详情
|
||||
func GetChannelDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdPathReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := channel.NewGetChannelDetailLogic(r.Context(), svcCtx)
|
||||
err := l.GetChannelDetail(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package channel
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/channel"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 频道列表
|
||||
func GetChannelListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ChannelListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := channel.NewGetChannelListLogic(r.Context(), svcCtx)
|
||||
err := l.GetChannelList(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package channel
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/channel"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 更新频道
|
||||
func UpdateChannelHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ChannelUpdateReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := channel.NewUpdateChannelLogic(r.Context(), svcCtx)
|
||||
err := l.UpdateChannel(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package interaction
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/interaction"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 评论节目
|
||||
func CommentProgramHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.CommentReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := interaction.NewCommentProgramLogic(r.Context(), svcCtx)
|
||||
err := l.CommentProgram(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package interaction
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/interaction"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 我的收藏列表
|
||||
func GetFavoriteListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.HistoryListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := interaction.NewGetFavoriteListLogic(r.Context(), svcCtx)
|
||||
err := l.GetFavoriteList(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package interaction
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/interaction"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 播放历史列表
|
||||
func GetHistoryListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.HistoryListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := interaction.NewGetHistoryListLogic(r.Context(), svcCtx)
|
||||
err := l.GetHistoryList(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package interaction
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/interaction"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 记录播放历史
|
||||
func RecordHistoryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.HistoryReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := interaction.NewRecordHistoryLogic(r.Context(), svcCtx)
|
||||
err := l.RecordHistory(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package interaction
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/interaction"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 收藏/取消收藏
|
||||
func ToggleFavoriteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.FavoriteReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := interaction.NewToggleFavoriteLogic(r.Context(), svcCtx)
|
||||
err := l.ToggleFavorite(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package interaction
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/interaction"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 点赞/取消点赞
|
||||
func ToggleLikeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.LikeReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := interaction.NewToggleLikeLogic(r.Context(), svcCtx)
|
||||
err := l.ToggleLike(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package pay
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/pay"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 创建支付订单
|
||||
func CreatePayOrderHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.CreatePayOrderReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := pay.NewCreatePayOrderLogic(r.Context(), svcCtx)
|
||||
err := l.CreatePayOrder(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package program
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/program"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 创建节目
|
||||
func CreateProgramHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ProgramReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := program.NewCreateProgramLogic(r.Context(), svcCtx)
|
||||
err := l.CreateProgram(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package program
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/program"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 删除节目
|
||||
func DeleteProgramHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdsReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := program.NewDeleteProgramLogic(r.Context(), svcCtx)
|
||||
err := l.DeleteProgram(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package program
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/program"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// TTS生成音频
|
||||
func GenerateTtsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.TtsReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := program.NewGenerateTtsLogic(r.Context(), svcCtx)
|
||||
err := l.GenerateTts(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package program
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/program"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 节目详情
|
||||
func GetProgramDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdPathReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := program.NewGetProgramDetailLogic(r.Context(), svcCtx)
|
||||
err := l.GetProgramDetail(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package program
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/program"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 节目列表
|
||||
func GetProgramListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ProgramListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := program.NewGetProgramListLogic(r.Context(), svcCtx)
|
||||
err := l.GetProgramList(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package program
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/program"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 更新节目
|
||||
func UpdateProgramHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ProgramUpdateReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := program.NewUpdateProgramLogic(r.Context(), svcCtx)
|
||||
err := l.UpdateProgram(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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"),
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package subscription
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/subscription"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 我的订阅列表
|
||||
func GetMySubscriptionsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := subscription.NewGetMySubscriptionsLogic(r.Context(), svcCtx)
|
||||
err := l.GetMySubscriptions()
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package vip
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/vip"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 我的VIP信息
|
||||
func GetMyVipInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := vip.NewGetMyVipInfoLogic(r.Context(), svcCtx)
|
||||
err := l.GetMyVipInfo()
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package vip
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/vip"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// VIP配置列表
|
||||
func GetVipConfigListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.VipConfigListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := vip.NewGetVipConfigListLogic(r.Context(), svcCtx)
|
||||
err := l.GetVipConfigList(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package voice
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/voice"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 创建音色
|
||||
func CreateVoiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.VoiceReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := voice.NewCreateVoiceLogic(r.Context(), svcCtx)
|
||||
err := l.CreateVoice(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package voice
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/voice"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 删除音色
|
||||
func DeleteVoiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdsReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := voice.NewDeleteVoiceLogic(r.Context(), svcCtx)
|
||||
err := l.DeleteVoice(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package voice
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/voice"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 音色列表
|
||||
func GetVoiceListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.VoiceListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := voice.NewGetVoiceListLogic(r.Context(), svcCtx)
|
||||
err := l.GetVoiceList(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package voice
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/radio/api/internal/logic/voice"
|
||||
"sundynix-micro-go/app/radio/api/internal/svc"
|
||||
"sundynix-micro-go/app/radio/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 更新音色
|
||||
func UpdateVoiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.VoiceUpdateReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := voice.NewUpdateVoiceLogic(r.Context(), svcCtx)
|
||||
err := l.UpdateVoice(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user