feat: 迁移商务登录品牌和三步找回密码
This commit is contained in:
@@ -98,7 +98,7 @@ func TestGinStartupLogsEveryRegisteredRoute(t *testing.T) {
|
||||
if got, want := strings.Count(text, `"msg":"router registered"`), len(engine.Routes()); got != want {
|
||||
t.Fatalf("registered route log count = %d, want %d", got, want)
|
||||
}
|
||||
if !strings.Contains(text, `"msg":"router register success"`) || !strings.Contains(text, `"route_count":207`) {
|
||||
if !strings.Contains(text, `"msg":"router register success"`) || !strings.Contains(text, `"route_count":211`) {
|
||||
t.Fatalf("startup route summary is missing: %s", text)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-kratos/kratos/v3/errors"
|
||||
"kra/internal/service/business"
|
||||
"kra/internal/service/dto"
|
||||
)
|
||||
|
||||
type BusinessPassword struct {
|
||||
service *business.PasswordResetService
|
||||
}
|
||||
|
||||
func NewBusinessPassword(service *business.PasswordResetService) *BusinessPassword {
|
||||
return &BusinessPassword{service: service}
|
||||
}
|
||||
func (h *BusinessPassword) Check(c *gin.Context) {
|
||||
var req dto.PasswordResetRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
Fail(c, "参数格式错误")
|
||||
return
|
||||
}
|
||||
value, err := h.service.Check(c.Request.Context(), &req)
|
||||
if err != nil {
|
||||
Fail(c, errors.FromError(err).Message)
|
||||
return
|
||||
}
|
||||
OKWithData(c, value)
|
||||
}
|
||||
func (h *BusinessPassword) SendCode(c *gin.Context) {
|
||||
var req dto.PasswordResetRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
Fail(c, "参数格式错误")
|
||||
return
|
||||
}
|
||||
value, err := h.service.SendCode(c.Request.Context(), &req)
|
||||
if err != nil {
|
||||
Fail(c, errors.FromError(err).Message)
|
||||
return
|
||||
}
|
||||
OKWithData(c, value)
|
||||
}
|
||||
func (h *BusinessPassword) VerifyCode(c *gin.Context) {
|
||||
var req dto.PasswordResetRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
Fail(c, "参数格式错误")
|
||||
return
|
||||
}
|
||||
value, err := h.service.VerifyCode(c.Request.Context(), &req)
|
||||
if err != nil {
|
||||
Fail(c, errors.FromError(err).Message)
|
||||
return
|
||||
}
|
||||
OKWithData(c, value)
|
||||
}
|
||||
func (h *BusinessPassword) Reset(c *gin.Context) {
|
||||
var req dto.PasswordResetRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
Fail(c, "参数格式错误")
|
||||
return
|
||||
}
|
||||
if err := h.service.Reset(c.Request.Context(), &req); err != nil {
|
||||
Fail(c, errors.FromError(err).Message)
|
||||
return
|
||||
}
|
||||
OK(c)
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import "github.com/google/wire"
|
||||
// field so adding a handler only means adding its constructor here.
|
||||
var ProviderSet = wire.NewSet(
|
||||
NewBusiness,
|
||||
NewBusinessPassword,
|
||||
NewAuthority, NewMenu, NewAPI, NewPermission, NewOrganization,
|
||||
NewAnnouncement, NewEmail, NewPayment, NewTask, NewMedia, NewAudit,
|
||||
NewExport, NewVersion, NewDictionary, NewParameter, NewAPIToken,
|
||||
|
||||
@@ -2,6 +2,7 @@ package handler
|
||||
|
||||
type Set struct {
|
||||
Business *Business
|
||||
BusinessPassword *BusinessPassword
|
||||
SMS *SMS
|
||||
Authority *Authority
|
||||
Menu *Menu
|
||||
|
||||
@@ -17,6 +17,7 @@ var sensitiveHeaders = map[string]struct{}{
|
||||
// both match "newpassword".
|
||||
var sensitivePayloadKeys = map[string]struct{}{
|
||||
"password": {}, "newpassword": {}, "oldpassword": {}, "confirmpassword": {},
|
||||
"smscode": {}, "verificationcode": {},
|
||||
"passwd": {}, "pwd": {}, "token": {}, "accesstoken": {}, "refreshtoken": {},
|
||||
"secret": {}, "clientsecret": {}, "apikey": {}, "privatekey": {}, "idcard": {},
|
||||
"key": {}, "signingkey": {}, "secretkey": {},
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"kra/internal/server/handler"
|
||||
)
|
||||
|
||||
func RegisterBusinessPassword(public *gin.RouterGroup, h *handler.BusinessPassword) {
|
||||
group := public.Group("/sw/auth/forgot-password")
|
||||
group.POST("/check", h.Check)
|
||||
group.POST("/send-code", h.SendCode)
|
||||
group.POST("/verify-code", h.VerifyCode)
|
||||
group.POST("/reset", h.Reset)
|
||||
}
|
||||
@@ -21,6 +21,7 @@ func (r *Routes) RegisterRoutes(public, private *gin.RouterGroup, engine *gin.En
|
||||
}
|
||||
registrations := []func(){
|
||||
func() { RegisterBusiness(private, r.handlers.Business) },
|
||||
func() { RegisterBusinessPassword(public, r.handlers.BusinessPassword) },
|
||||
func() { RegisterPublic(public, engine, r.handlers.Public) },
|
||||
func() { RegisterUser(private, r.handlers.User) },
|
||||
func() { RegisterNavigation(private, r.handlers.Navigation) },
|
||||
|
||||
Reference in New Issue
Block a user