carv api logic
This commit is contained in:
@@ -2,6 +2,7 @@ package carv
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"nova_task/internal/pkg/errs"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"nova_task/internal/logic/carv"
|
||||
@@ -12,18 +13,15 @@ import (
|
||||
// 注册绑定钱包任务
|
||||
func BindWalletHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
var req types.EmailKey
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
httpx.ErrorCtx(ctx, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := carv.NewBindWalletLogic(r.Context(), svcCtx)
|
||||
resp, err := l.BindWallet(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
l := carv.NewBindWalletLogic(ctx, svcCtx)
|
||||
resp := l.BindWallet(&req)
|
||||
errs.WriteHttpResponse(ctx, w, resp)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package carv
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"nova_task/internal/pkg/errs"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"nova_task/internal/logic/carv"
|
||||
@@ -13,17 +14,14 @@ import (
|
||||
func DownloadAndBindRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.EmailKey
|
||||
ctx := r.Context()
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
httpx.ErrorCtx(ctx, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := carv.NewDownloadAndBindRoleLogic(r.Context(), svcCtx)
|
||||
resp, err := l.DownloadAndBindRole(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
l := carv.NewDownloadAndBindRoleLogic(ctx, svcCtx)
|
||||
resp := l.DownloadAndBindRole(&req)
|
||||
errs.WriteHttpResponse(ctx, w, resp)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package carv
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"nova_task/internal/pkg/errs"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"nova_task/internal/logic/carv"
|
||||
@@ -13,17 +14,14 @@ import (
|
||||
func UnlockChapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.UnlockChapterReq
|
||||
ctx := r.Context()
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
httpx.ErrorCtx(ctx, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := carv.NewUnlockChapterLogic(r.Context(), svcCtx)
|
||||
resp, err := l.UnlockChapter(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
l := carv.NewUnlockChapterLogic(ctx, svcCtx)
|
||||
resp := l.UnlockChapter(&req)
|
||||
errs.WriteHttpResponse(ctx, w, resp)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package carv
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"nova_task/internal/pkg/errs"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"nova_task/internal/logic/carv"
|
||||
@@ -13,17 +14,14 @@ import (
|
||||
func WalletCheckInHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.EmailKey
|
||||
ctx := r.Context()
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
httpx.ErrorCtx(ctx, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := carv.NewWalletCheckInLogic(r.Context(), svcCtx)
|
||||
resp, err := l.WalletCheckIn(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
l := carv.NewWalletCheckInLogic(ctx, svcCtx)
|
||||
resp := l.WalletCheckIn(&req)
|
||||
errs.WriteHttpResponse(ctx, w, resp)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user