@@ -16,22 +16,24 @@ class Base extends Controller
16
16
/**
17
17
* Session操作
18
18
* @param string $key
19
- * @param string $data
19
+ * @param mixed $data
20
20
* @return bool|mixed|null
21
21
* @throws \EasySwoole\Redis\Exception\RedisException
22
22
*/
23
23
public function session (string $ key = SWORD_NULL , $ data = SWORD_NULL )
24
24
{
25
25
$ args = $ this ->caller ()->getArgs ();
26
26
27
- $ sname = config ('session.sessionName ' );
28
- if (empty ($ args [$ sname ])){
27
+ $ name = config ('session.session_name ' );
28
+ if (empty ($ args [$ name ])){
29
29
return false ;
30
30
}
31
31
32
- if (empty ($ args [$ sname ])) return false ;
32
+ if (empty ($ args [$ name ])) return false ;
33
33
34
- $ value = cache ($ args [$ sname ]);
34
+ $ token = $ args [$ name ];
35
+
36
+ $ value = cache ($ token );
35
37
if (!$ value ) return false ;
36
38
37
39
if ($ key == SWORD_NULL ){
@@ -40,10 +42,10 @@ public function session(string $key = SWORD_NULL, $data = SWORD_NULL)
40
42
return $ value [$ key ] ?? null ;
41
43
}elseif ($ data == null ){
42
44
unset($ value [$ key ]);
43
- cache ($ args [ $ sname ] , $ value );
45
+ cache ($ token , $ value );
44
46
}else {
45
47
$ value [$ key ] = $ data ;
46
- cache ($ args [ $ sname ] , $ value );
48
+ cache ($ token , $ value );
47
49
}
48
50
return true ;
49
51
}
@@ -56,11 +58,11 @@ public function sessionId()
56
58
{
57
59
$ args = $ this ->caller ()->getArgs ();
58
60
59
- $ sname = config ('session.sessionName ' );
60
- if (empty ($ args [$ sname ])){
61
+ $ name = config ('session.session_name ' );
62
+ if (empty ($ args [$ name ])){
61
63
return false ;
62
64
}
63
- return $ args [$ sname ];
65
+ return $ args [$ name ];
64
66
}
65
67
66
68
/**
@@ -88,8 +90,18 @@ public function withData(int $code = 0, string $msg = '', $result = [], int $cou
88
90
$ ret ['ES_TOKEN ' ] = $ args ['ES_TOKEN ' ];
89
91
}
90
92
91
- $ this ->response ()-> setMessage (json_encode ($ ret ));
93
+ $ this ->responseImmediately (json_encode ($ ret ));
92
94
return true ;
93
95
}
94
96
97
+ /**
98
+ * 获取上传数据
99
+ * @return array
100
+ */
101
+ public function input (): array
102
+ {
103
+ $ args = $ this ->caller ()->getArgs ();
104
+ return $ args ['data ' ]??[];
105
+ }
106
+
95
107
}
0 commit comments