feat: add otp redis repo
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"backend/pkg/util"
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type OTPRepo interface {
|
||||
Create(ctx context.Context, phone string, otp *OTP) error
|
||||
Delete(ctx context.Context, phone string) error
|
||||
}
|
||||
|
||||
type OTP struct {
|
||||
ID uuid.UUID
|
||||
Code string
|
||||
Phone string
|
||||
ExpiredAt time.Time
|
||||
}
|
||||
|
||||
func NewOTP(phone string) *OTP {
|
||||
return &OTP{
|
||||
ID: uuid.New(),
|
||||
Code: util.GenOTPCode(),
|
||||
Phone: phone,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user