2024-12-30 03:58:14 +00:00
|
|
|
package accountlogic
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2025-02-08 02:23:54 +00:00
|
|
|
"code.30cm.net/digimon/library-go/errs"
|
|
|
|
|
|
|
|
"code.30cm.net/digimon/app-cloudep-member-server/gen_result/pb/member"
|
|
|
|
"code.30cm.net/digimon/app-cloudep-member-server/internal/svc"
|
2024-12-30 03:58:14 +00:00
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
)
|
|
|
|
|
|
|
|
type BindVerifyEmailLogic struct {
|
|
|
|
ctx context.Context
|
|
|
|
svcCtx *svc.ServiceContext
|
|
|
|
logx.Logger
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewBindVerifyEmailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BindVerifyEmailLogic {
|
|
|
|
return &BindVerifyEmailLogic{
|
|
|
|
ctx: ctx,
|
|
|
|
svcCtx: svcCtx,
|
|
|
|
Logger: logx.WithContext(ctx),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-02-08 02:23:54 +00:00
|
|
|
type bindEmailVerifyReq struct {
|
|
|
|
UID string `validate:"required"` // 唯一辨識碼
|
|
|
|
Email string `validate:"required"` // 唯一辨識碼
|
|
|
|
}
|
|
|
|
|
2024-12-30 03:58:14 +00:00
|
|
|
// BindVerifyEmail 綁定 Email
|
|
|
|
func (l *BindVerifyEmailLogic) BindVerifyEmail(in *member.BindVerifyEmailReq) (*member.OKResp, error) {
|
2025-02-08 02:23:54 +00:00
|
|
|
if err := l.svcCtx.Validate.ValidateAll(&bindEmailVerifyReq{
|
|
|
|
UID: in.GetUid(),
|
|
|
|
Email: in.GetEmail(),
|
|
|
|
}); err != nil {
|
|
|
|
return nil, errs.InvalidFormat(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
err := l.svcCtx.AccountUseCase.BindVerifyEmail(l.ctx, in.GetUid(), in.GetEmail())
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2024-12-30 03:58:14 +00:00
|
|
|
|
|
|
|
return &member.OKResp{}, nil
|
|
|
|
}
|