youtu_server/game_open_api/internal/handler/douyin/douyinCode2tokenHandler.go

30 lines
732 B
Go
Raw Normal View History

2025-01-20 18:20:25 +08:00
package douyin
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"youtu_server/game_open_api/internal/logic/douyin"
"youtu_server/game_open_api/internal/svc"
"youtu_server/game_open_api/internal/types"
)
func DouyinCode2tokenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.DouyinCode2TokenRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := douyin.NewDouyinCode2tokenLogic(r.Context(), svcCtx)
resp, err := l.DouyinCode2token(&req)
if err != nil {
2025-01-21 10:02:04 +08:00
resp.Code = -1
2025-01-20 18:20:25 +08:00
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}