mirror of https://gitee.com/godoos/godoos.git
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.
28 lines
541 B
28 lines
541 B
package login
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
type LoginHandlerFactory struct{}
|
|
|
|
// factory.go
|
|
func (f *LoginHandlerFactory) GetHandler(req LoginRequest) (LoginHandler, error) {
|
|
var handler LoginHandler
|
|
|
|
switch req.LoginType {
|
|
case LoginTypePassword:
|
|
handler = &PasswordLoginHandler{}
|
|
case LoginTypeSmsCode:
|
|
handler = &SmsCodeLoginHandler{}
|
|
default:
|
|
return nil, errors.New("unsupported login type")
|
|
}
|
|
|
|
if err := handler.Init(req); err != nil {
|
|
return nil, fmt.Errorf("参数初始化失败: %v", err)
|
|
}
|
|
|
|
return handler, nil
|
|
}
|
|
|