feat: 迁移商务登录品牌和三步找回密码
This commit is contained in:
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user