fix: 密码重置链路断裂与店铺模板类型不兼容

删除 users-api 的 forgot-password 空壳路由,email-api 的
forgotPasswordLogic 复用 sendVerificationCode 实现。shop 的
UpdateTemplateReq.Sections 从 interface{} 改为 string 以兼容
go-zero 反序列化。ResetPasswordReq.Phone 加 optional tag。
This commit is contained in:
zetaloop
2026-04-05 17:59:56 +08:00
parent f0048f9e12
commit 62442a324a
10 changed files with 22 additions and 111 deletions
@@ -27,8 +27,9 @@ func NewForgotPasswordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Fo
}
}
func (l *ForgotPasswordLogic) ForgotPassword(req *types.ForgotPasswordReq) (resp *types.EmptyResp, err error) {
// todo: add your logic here and delete this line
return
func (l *ForgotPasswordLogic) ForgotPassword(req *types.ForgotPasswordReq) (resp *types.SendVerificationCodeResp, err error) {
return NewSendVerificationCodeLogic(l.ctx, l.svcCtx).SendVerificationCode(&types.SendVerificationCodeReq{
Email: req.Email,
Scene: "reset_password",
})
}
+1 -1
View File
@@ -1,5 +1,5 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.9.2
// goctl 1.10.1
package handler
@@ -5,7 +5,6 @@ package shop
import (
"context"
"encoding/json"
"errors"
"juwan-backend/app/shop/api/internal/svc"
@@ -48,11 +47,6 @@ func (l *UpdateShopTemplateLogic) UpdateShopTemplate(req *types.UpdateTemplateRe
return nil, contextj.ERRILLEGALUSER
}
templateBytes, err := json.Marshal(map[string]any{"sections": req.Sections})
if err != nil {
return nil, errors.New("invalid sections")
}
_, err = l.svcCtx.ShopRpc.UpdateShops(l.ctx, &pb.UpdateShopsReq{
Id: shop.Shops.Id,
OwnerId: shop.Shops.OwnerId,
@@ -68,7 +62,7 @@ func (l *UpdateShopTemplateLogic) UpdateShopTemplate(req *types.UpdateTemplateRe
AllowIndependentOrders: shop.Shops.AllowIndependentOrders,
DispatchMode: shop.Shops.DispatchMode,
Announcements: shop.Shops.Announcements,
TemplateConfig: string(templateBytes),
TemplateConfig: req.Sections,
})
if err != nil {
return nil, err
+2 -2
View File
@@ -1,5 +1,5 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.9.2
// goctl 1.10.1
package types
@@ -94,7 +94,7 @@ type UpdateShopReq struct {
type UpdateTemplateReq struct {
Id int64 `path:"id"`
Sections interface{} `json:"sections"`
Sections string `json:"sections"`
}
type UserIdReq struct {
@@ -1,32 +0,0 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2
package auth
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/users/api/internal/logic/auth"
"juwan-backend/app/users/api/internal/svc"
"juwan-backend/app/users/api/internal/types"
)
// 忘记密码-发送验证码
func ForgotPasswordHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ForgotPasswordReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := auth.NewForgotPasswordLogic(r.Context(), svcCtx)
resp, err := l.ForgotPassword(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
+1 -7
View File
@@ -1,5 +1,5 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.9.2
// goctl 1.10.1
package handler
@@ -18,12 +18,6 @@ import (
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
server.AddRoutes(
[]rest.Route{
{
// 忘记密码-发送验证码
Method: http.MethodPost,
Path: "/forgot-password",
Handler: auth.ForgotPasswordHandler(serverCtx),
},
{
// 用户登录
Method: http.MethodPost,
@@ -1,33 +0,0 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2
package auth
import (
"context"
"juwan-backend/app/users/api/internal/svc"
"juwan-backend/app/users/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type ForgotPasswordLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
// 忘记密码-发送验证码
func NewForgotPasswordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ForgotPasswordLogic {
return &ForgotPasswordLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *ForgotPasswordLogic) ForgotPassword(req *types.ForgotPasswordReq) (resp *types.EmptyResp, err error) {
// todo: add your logic here and delete this line
return
}
+4 -9
View File
@@ -1,5 +1,5 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.9.2
// goctl 1.10.1
package types
@@ -15,11 +15,6 @@ type FollowUserReq struct {
Id int64 `path:"id"`
}
type ForgotPasswordReq struct {
Phone string `json:"phone,omitempty"`
Email string `json:"email,omitempty"`
}
type GetMyVerificationsResp struct {
List []VerificationItem `json:"list"`
}
@@ -57,8 +52,8 @@ type LogoutReq struct {
type MaterialJson struct {
IdCardFront string `json:"idCardFront"` // 身份证正面照片URL
IdCardBack string `json:"idCardBack"` // 身份证反面照片URL
GameScreenshots []string `json:"gameScreenshots"` // 游戏截图URL列表
VoiceDemo string `json:"voiceDemo"` // 语音认证示例URL
GameScreenshots []*string `json:"gameScreenshots,optional"` // 游戏截图URL列表
VoiceDemo *string `json:"voiceDemo,optional"` // 语音认证示例URL
}
type RegisterReq struct {
@@ -79,7 +74,7 @@ type RejectVerificationReq struct {
}
type ResetPasswordReq struct {
Phone string `json:"phone,omitempty"`
Phone string `json:"phone,optional"`
Email string `json:"email,omitempty"`
Vcode string `json:"vcode"`
NewPassword string `json:"newPassword"`
+1 -1
View File
@@ -39,7 +39,7 @@ type (
}
UpdateTemplateReq {
Id int64 `path:"id"`
Sections interface{} `json:"sections"`
Sections string `json:"sections"`
}
AnnouncementReq {
Id int64 `path:"id"`
+1 -9
View File
@@ -107,12 +107,8 @@ type (
User User `json:"user"`
}
LogoutReq {}
ForgotPasswordReq {
Phone string `json:"phone,omitempty"`
Email string `json:"email,omitempty"`
}
ResetPasswordReq {
Phone string `json:"phone,omitempty"`
Phone string `json:"phone,optional"`
Email string `json:"email,omitempty"`
Vcode string `json:"vcode"`
NewPassword string `json:"newPassword"`
@@ -172,10 +168,6 @@ service user-api {
@handler Login
post /login (LoginReq) returns (LoginResp)
@doc "忘记密码-发送验证码"
@handler ForgotPassword
post /forgot-password (ForgotPasswordReq) returns (EmptyResp)
@doc "重置密码"
@handler ResetPassword
post /reset-password (ResetPasswordReq) returns (EmptyResp)