Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
laodaming
2023-08-29 18:22:20 +08:00
12 changed files with 215 additions and 31 deletions

View File

@@ -0,0 +1,35 @@
package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/auth/internal/logic"
"fusenapi/server/auth/internal/svc"
"fusenapi/server/auth/internal/types"
)
func DebugAuthDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.RequestAuthDelete
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewDebugAuthDeleteLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.DebugAuthDelete(&req, userinfo)
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -52,6 +52,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/api/auth/reset/password",
Handler: UserResetPasswordHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/api/auth/debug/delete",
Handler: DebugAuthDeleteHandler(serverCtx),
},
},
)
}

View File

@@ -0,0 +1,48 @@
package logic
import (
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"context"
"fusenapi/server/auth/internal/svc"
"fusenapi/server/auth/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type DebugAuthDeleteLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewDebugAuthDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DebugAuthDeleteLogic {
return &DebugAuthDeleteLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// 处理进入前逻辑w,r
// func (l *DebugAuthDeleteLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// }
func (l *DebugAuthDeleteLogic) DebugAuthDelete(req *types.RequestAuthDelete, userinfo *auth.UserInfo) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null
err := l.svcCtx.AllModels.FsUser.DebugAuthDelete(l.ctx, req.Email)
if err != nil {
return resp.SetStatus(basic.CodeDbSqlErr, err.Error())
}
return resp.SetStatus(basic.CodeOK)
}
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
// func (l *DebugAuthDeleteLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// // httpx.OkJsonCtx(r.Context(), w, resp)
// }

View File

@@ -105,7 +105,7 @@ func (l *UserEmailConfirmationLogic) UserEmailConfirmation(req *types.RequestEma
}
logx.Info(token.Platform)
switch token.Platform {
case "google":
case string(auth.PLATFORM_GOOGLE):
// 谷歌平台的注册流程
user, err := l.svcCtx.AllModels.FsUser.RegisterByGoogleOAuth(l.ctx, token)
if err != nil {
@@ -119,8 +119,8 @@ func (l *UserEmailConfirmationLogic) UserEmailConfirmation(req *types.RequestEma
}
logx.Info("success", token.TraceId)
case "facebook":
case "fusen":
case string(auth.PLATFORM_FACEBOOK):
case string(auth.PLATFORM_FUSEN):
// log.Println("aaaa", token)
user, err := l.svcCtx.AllModels.FsUser.RegisterByFusen(l.ctx, token)
if err != nil && err != gorm.ErrRecordNotFound {

View File

@@ -93,7 +93,7 @@ func (l *UserGoogleLoginLogic) UserGoogleLogin(req *types.RequestGoogleLogin, us
l.registerInfo = &auth.RegisterToken{
Password: base64.RawURLEncoding.EncodeToString(nonce),
Platform: "google",
Platform: string(auth.PLATFORM_GOOGLE),
OperateType: auth.OpTypeRegister,
TraceId: uuid.NewString(),
CreateAt: time.Now().UTC(),

View File

@@ -47,7 +47,7 @@ func (l *UserRegisterLogic) UserRegister(req *types.RequestUserRegister, userinf
Wid: req.Wid,
Email: req.Email,
Password: req.Password,
Platform: "fusen",
Platform: string(auth.PLATFORM_FUSEN),
TraceId: uuid.NewString(),
CreateAt: time.Now(),
Extend: map[string]interface{}{

View File

@@ -5,6 +5,10 @@ import (
"fusenapi/utils/basic"
)
type RequestAuthDelete struct {
Email string `json:"email"`
}
type RequestUserLogin struct {
Email string `json:"email"`
Password string `json:"password"`

View File

@@ -18,8 +18,8 @@ AWS:
Secret: sjCEv0JxATnPCxno2KNLm0X8oDc7srUR+4vkYhvm
Token:
BLMService:
Url: "http://18.119.109.254:8999"
# Url: "http://192.168.1.7:8999"
# Url: "http://18.119.109.254:8999"
Url: "http://192.168.1.9:8999"
LogoCombine:
#Url: "http://192.168.1.7:8999/LogoCombine"
Url: "http://18.119.109.254:8999/LogoCombine"