1
This commit is contained in:
parent
17f9a521a3
commit
c0cd52e80d
@ -3,4 +3,8 @@
|
||||
ini_set('date.timezone','Asia/Shanghai');
|
||||
require 'phpcommon/common.php';
|
||||
|
||||
define('TEAMID_KEY', 'team_uuid:');
|
||||
|
||||
require 'config_loader.php';
|
||||
|
||||
|
||||
|
@ -31,10 +31,10 @@ class teamController{
|
||||
));
|
||||
|
||||
$r = $this->getRedis($team_uuid);
|
||||
$r->set(TEAMID_KEY . $team_uuid, json_encode($team_db));
|
||||
$r->pexpire(TEAMID_KEY . $team_uuid, 1000 * 3600);
|
||||
$r -> set(TEAMID_KEY . $team_uuid, json_encode($team_db));
|
||||
$r -> pexpire(TEAMID_KEY . $team_uuid, 1000 * 3600);
|
||||
|
||||
echo json_encode(array(
|
||||
echo json_encode (array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'team_uuid' => $team_uuid
|
||||
@ -48,7 +48,7 @@ class teamController{
|
||||
if(!$r){
|
||||
echo 'is null';
|
||||
}else{
|
||||
$accountid = $_REQUEST['accout_id'];
|
||||
$accountid = $_REQUEST['account_id'];
|
||||
$sessionid = $_REQUEST['session_id'];
|
||||
$team_uuid = $_REQUEST['team_uuid'];
|
||||
$user_db_str = $r->get(TEAMID_KEY . $team_uuid);
|
||||
@ -82,45 +82,120 @@ class teamController{
|
||||
|
||||
public function joinTeam()
|
||||
{
|
||||
$team_uuid = $_REQUEST['team_uuid'];
|
||||
$r = $this->getRedis($team_uuid);
|
||||
|
||||
if(!$r){
|
||||
if (!$r){
|
||||
echo 'is null';
|
||||
}else{
|
||||
}else {
|
||||
$user_db_str = $r->get(TEAMID_KEY.$team_uuid);
|
||||
if(empty($user_db_str)){
|
||||
if (empty($user_db_str)){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||
return;
|
||||
}
|
||||
$user_db = json_decode($user_db_str, true);
|
||||
if(empty($user_db)){
|
||||
if (empty($user_db)){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, 'session失效');
|
||||
return;
|
||||
}
|
||||
$member_num = count($user_db['member_list']);
|
||||
|
||||
if ($member_num >= 4){
|
||||
phpcommon\sendError(ERR_USER_BASE + 2,'队伍人数已满');
|
||||
return;
|
||||
}
|
||||
$flag = 0;
|
||||
foreach ($user_db['member_list'] as $member) {
|
||||
if ($member['account_id'] == $_REQUEST['account_id']){
|
||||
$flag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($flag == 1){
|
||||
phpcommon\sendError(ERR_USER_BASE + 3,'已在队伍中');
|
||||
return;
|
||||
}
|
||||
|
||||
array_push ($user_db['member_list'], array(
|
||||
'idx' => $member_num + 1,
|
||||
'account_id' => $_REQUEST['account_id'],
|
||||
'name' => $_REQUEST['name'],
|
||||
'avatar_url' => $_REQUEST['avatar_url'],
|
||||
));
|
||||
$r->set(TEAMID_KEY . $team_uuid, json_encode($user_db));
|
||||
$r->pexpire(TEAMID_KEY . $team_uuid, 1000 * 3600);
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
));
|
||||
}
|
||||
|
||||
public function leaveTeam()
|
||||
{
|
||||
$team_uuid = $_REQUEST['team_uuid'];
|
||||
$r = $this->getRedis($team_uuid);
|
||||
|
||||
if (!$r){
|
||||
echo 'is null';
|
||||
}else{
|
||||
$user_db_str = $r->get(TEAMID_KEY . $team_uuid);
|
||||
if (empty($user_db_str)){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效1');
|
||||
return;
|
||||
}
|
||||
$user_db = json_decode($user_db_str, true);
|
||||
if (empty($user_db)){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效2');
|
||||
return;
|
||||
}
|
||||
foreach ($user_db['member_list'] as $member) {
|
||||
if ($member['account_id'] == $_REQUEST['account_id']){
|
||||
$flag = $member['idx'] - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset($user_db['member_list'][$flag]);
|
||||
$user_db['member_list'] = array_values($user_db['member_list']);
|
||||
var_dump($user_db['member_list']);
|
||||
|
||||
$i = 1;
|
||||
foreach ($user_db['member_list'] as &$memberlist){
|
||||
$memberlist['idx'] = $i;
|
||||
$i++;
|
||||
}
|
||||
var_dump($user_db);
|
||||
|
||||
$r->set(TEAMID_KEY . $team_uuid, json_encode($user_db));
|
||||
$r->pexpire(TEAMID_KEY . $team_uuid, 1000 * 3600);
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
));
|
||||
}
|
||||
|
||||
public function updateTeam()
|
||||
{
|
||||
$team_uuid = $_REQUEST['team_uuid'];
|
||||
$r = $this->getRedis($team_uuid);
|
||||
|
||||
if(!$r){
|
||||
if (!$r){
|
||||
echo 'is null';
|
||||
}else{
|
||||
$user_db_str = $r->get(TEAMID_KEY.$team_uuid);
|
||||
if(empty($user_db_str)){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||
$user_db_str = $r->get(TEAMID_KEY . $team_uuid);
|
||||
if (empty($user_db_str)){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效1');
|
||||
return;
|
||||
}
|
||||
$user_db = json_decode($user_db_str, true);
|
||||
if(empty($user_db)){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||
if (empty($user_db)){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效2');
|
||||
return;
|
||||
}
|
||||
$user_db['auto_fill'] = $_REQUEST['auto_fill'];
|
||||
$redis->set(TEAMID_KEY.$team_uuid, json_encode($user_db));
|
||||
$redis->pexpire(TEAMID_KEY.$team_uuid, 1000 * 3600);
|
||||
$r->set(TEAMID_KEY . $team_uuid, json_encode($user_db));
|
||||
$r->pexpire(TEAMID_KEY . $team_uuid, 1000 * 3600);
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user