|
@@ -3,7 +3,7 @@
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
use app\common\controller\Api;
|
|
|
-
|
|
|
+use Redis;
|
|
|
/**
|
|
|
* 示例接口
|
|
|
*/
|
|
@@ -19,6 +19,27 @@ class Demo extends Api
|
|
|
// 无需鉴权的接口,*表示全部
|
|
|
protected $noNeedRight = ['test2'];
|
|
|
|
|
|
+ protected $redis;
|
|
|
+
|
|
|
+ public function __construct()
|
|
|
+ {
|
|
|
+ $this->roomTypeArr = [1=>"party",2=>"live"];
|
|
|
+
|
|
|
+ //redis
|
|
|
+ $redis = new Redis();
|
|
|
+ $redisconfig = config("redis");
|
|
|
+ $redis->connect($redisconfig["host"], $redisconfig["port"]);
|
|
|
+ if ($redisconfig['redis_pwd']) {
|
|
|
+ $redis->auth($redisconfig['redis_pwd']);
|
|
|
+ }
|
|
|
+ if($redisconfig['redis_selectdb'] > 0){
|
|
|
+ $redis->select($redisconfig['redis_selectdb']);
|
|
|
+ }
|
|
|
+ $this->redis = $redis;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 测试方法
|
|
|
*
|
|
@@ -40,7 +61,18 @@ class Demo extends Api
|
|
|
*/
|
|
|
public function test()
|
|
|
{
|
|
|
- $this->success('返回成功', $this->request->param());
|
|
|
+ exit;
|
|
|
+ $party_id = 1;
|
|
|
+ $userId = 3;
|
|
|
+ //下麦
|
|
|
+ $key = "party_seat_".$party_id;
|
|
|
+ $seats = $this->redis->hGetAll($key);
|
|
|
+
|
|
|
+ foreach($seats as $seat_num => $seatuserid){
|
|
|
+ if($seatuserid == $userId){
|
|
|
+ $this->redis->HDel($key, $seat_num);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|