You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
990 B
46 lines
990 B
package biz
|
|
|
|
import (
|
|
"context"
|
|
"customer/api/verifyCode"
|
|
"customer/internal/data"
|
|
"github.com/go-kratos/kratos/v2/transport/grpc"
|
|
"time"
|
|
)
|
|
|
|
type CustomerHttpBiz struct {
|
|
Data *data.Data
|
|
}
|
|
|
|
func NewCustomerHttpBiz(data *data.Data) *CustomerHttpBiz {
|
|
return &CustomerHttpBiz{
|
|
Data: data,
|
|
}
|
|
}
|
|
|
|
func (b *CustomerHttpBiz) GetVerifyCode(l uint32, t verifyCode.TYPE) (string, error) {
|
|
conn, err := grpc.DialInsecure(
|
|
context.Background(),
|
|
grpc.WithEndpoint("127.0.0.1:9000"),
|
|
)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
verifyCodeClient := verifyCode.NewVerifyCodeClient(conn)
|
|
respCode, err := verifyCodeClient.GetVerifyCode(context.Background(),
|
|
&verifyCode.GetVerifyCodeRequest{
|
|
Length: l,
|
|
Type: t,
|
|
})
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return respCode.Code, nil
|
|
}
|
|
|
|
func (b *CustomerHttpBiz) SaveVerifyCode(phoneNumber, code string) error {
|
|
// vcc verify_code customer
|
|
return b.Data.Rdb.Set(context.Background(), "vcc_"+phoneNumber, code, 60*time.Second).Err()
|
|
}
|