init: init refactor
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user