feat:优化项目结构
This commit is contained in:
@ -2,25 +2,26 @@ package account
|
||||
|
||||
import (
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/config"
|
||||
"SciencesServer/utils"
|
||||
)
|
||||
|
||||
type Logout struct {
|
||||
*service.SessionEnterprise
|
||||
*session.Enterprise
|
||||
}
|
||||
|
||||
type LogoutHandle func(enterprise *service.SessionEnterprise) *Logout
|
||||
type LogoutHandle func(session *session.Enterprise) *Logout
|
||||
|
||||
func (c *Logout) Launch() error {
|
||||
if c.SessionEnterprise != nil && c.UID > 0 {
|
||||
if c.Enterprise != nil && c.UID > 0 {
|
||||
service.Publish(config.EventForRedisHashDestroy, config.RedisKeyForAccount, utils.UintToString(c.UID))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewLogout() LogoutHandle {
|
||||
return func(enterprise *service.SessionEnterprise) *Logout {
|
||||
return &Logout{enterprise}
|
||||
return func(session *session.Enterprise) *Logout {
|
||||
return &Logout{Enterprise: session}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"SciencesServer/app/handle"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Other struct{}
|
||||
|
||||
type OtherHandle func() *Other
|
||||
|
||||
// BindMobile 绑定手机号码
|
||||
func (c *Other) BindMobile(token, mobile, captcha string) (interface{}, error) {
|
||||
if !utils.ValidateMobile(mobile) {
|
||||
return nil, errors.New("手机号码格式异常")
|
||||
}
|
||||
pass, err := handle.NewCaptcha().Validate(&handle.CaptchaSms{
|
||||
Mobile: mobile, Captcha: captcha,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
return nil, errors.New("验证码错误或已过期")
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func NewOther() OtherHandle {
|
||||
return func() *Other {
|
||||
return &Other{}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user