refactor(login): 重构登录模块代码
- 移除未使用的 in.go 和 out.go 文件 - 优化 login.go 中的代码结构 - 添加新的 go.mod 依赖
This commit is contained in:
36
logic/service/fight/fsm_test.go
Normal file
36
logic/service/fight/fsm_test.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package fight
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/looplab/fsm"
|
||||
)
|
||||
|
||||
func Test_main(t *testing.T) {
|
||||
fsm := fsm.NewFSM(
|
||||
"closed",
|
||||
fsm.Events{
|
||||
{Name: "open", Src: []string{"closed"}, Dst: "open"},
|
||||
{Name: "close", Src: []string{"open"}, Dst: "closed"},
|
||||
},
|
||||
fsm.Callbacks{},
|
||||
)
|
||||
|
||||
fmt.Println(fsm.Current())
|
||||
|
||||
err := fsm.Event(context.Background(), "open")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
fmt.Println(fsm.Current())
|
||||
|
||||
err = fsm.Event(context.Background(), "close")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
fmt.Println(fsm.Current())
|
||||
}
|
||||
@@ -18,15 +18,15 @@ type LoginSidInfo struct { //这里直接使用组合来实现将传入的原始
|
||||
// ErrorPassWord uint32 `struc:"[0]pad"`
|
||||
}
|
||||
|
||||
func CheakSession(c LoginSidInfo) bool {
|
||||
func (l *LoginSidInfo) CheakSession() bool {
|
||||
// tt, _ := cool.CacheManager.Keys(context.Background())
|
||||
//g.Dump(tt)
|
||||
t1 := hex.EncodeToString(c.Sid)
|
||||
t1 := hex.EncodeToString(l.Sid)
|
||||
|
||||
t2 := strings.Trim(t1, " ")
|
||||
t, err := cool.CacheManager.Get(context.Background(), t2)
|
||||
fmt.Println("后端获取", string(c.Sid), t, err)
|
||||
if t.Uint32() == c.Head.UserID {
|
||||
fmt.Println("后端获取", string(l.Sid), t, err)
|
||||
if t.Uint32() == l.Head.UserID {
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user