♻️ refactored login-related code
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"net/http"
|
||||
"schisandra-album-cloud-microservices/app/core/api/internal/logic/user"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"schisandra-album-cloud-microservices/app/core/api/common/response"
|
||||
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/app/core/api/internal/types"
|
||||
)
|
||||
|
||||
func GetWechatOffiaccountQrcodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.OAuthWechatRequest
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := user.NewGetWechatOffiaccountQrcodeLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetWechatOffiaccountQrcode(r, &req)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
httpx.WriteJsonCtx(
|
||||
r.Context(),
|
||||
w,
|
||||
http.StatusInternalServerError,
|
||||
response.ErrorWithI18n(r.Context(), "system.error"))
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
@@ -11,16 +11,16 @@ import (
|
||||
"schisandra-album-cloud-microservices/app/core/api/internal/types"
|
||||
)
|
||||
|
||||
func GetUserDeviceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
func WechatOffiaccountLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.UserDeviceRequest
|
||||
var req types.WechatOffiaccountLoginRequest
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := user.NewGetUserDeviceLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetUserDevice(r, w, &req)
|
||||
l := user.NewWechatOffiaccountLoginLogic(r.Context(), svcCtx)
|
||||
resp, err := l.WechatOffiaccountLogin(r, &req)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
httpx.WriteJsonCtx(
|
Reference in New Issue
Block a user