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 BindVerifyPhoneLogic struct {
|
|
|
|
ctx context.Context
|
|
|
|
svcCtx *svc.ServiceContext
|
|
|
|
logx.Logger
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewBindVerifyPhoneLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BindVerifyPhoneLogic {
|
|
|
|
return &BindVerifyPhoneLogic{
|
|
|
|
ctx: ctx,
|
|
|
|
svcCtx: svcCtx,
|
|
|
|
Logger: logx.WithContext(ctx),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-02-08 02:23:54 +00:00
|
|
|
type bindPhoneVerifyReq struct {
|
|
|
|
UID string `validate:"required"` // 唯一辨識碼
|
|
|
|
Phone string `validate:"required"` // 唯一辨識碼
|
|
|
|
}
|
|
|
|
|
2024-12-30 03:58:14 +00:00
|
|
|
// BindVerifyPhone 綁定 Phone
|
|
|
|
func (l *BindVerifyPhoneLogic) BindVerifyPhone(in *member.BindVerifyPhoneReq) (*member.OKResp, error) {
|
2025-02-08 02:23:54 +00:00
|
|
|
if err := l.svcCtx.Validate.ValidateAll(&bindPhoneVerifyReq{
|
|
|
|
UID: in.GetUid(),
|
|
|
|
Phone: in.GetPhone(),
|
|
|
|
}); err != nil {
|
|
|
|
return nil, errs.InvalidFormat(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
err := l.svcCtx.AccountUseCase.BindVerifyPhone(l.ctx, in.GetUid(), in.GetPhone())
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2024-12-30 03:58:14 +00:00
|
|
|
|
|
|
|
return &member.OKResp{}, nil
|
|
|
|
}
|