1
This commit is contained in:
parent
ae5f19ed31
commit
e61d6ea8fa
@ -28,7 +28,10 @@ CREATE TABLE `version` (
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `version` (`version`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
|
127
webapp/controller/teamController.class.php
Normal file
127
webapp/controller/teamController.class.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
class teamController{
|
||||
|
||||
protected function getRedis($team_uuid)
|
||||
{
|
||||
$redis_conf = getRedisConfig(crc32($team_uuid));
|
||||
$r = new phpcommon\Redis(array(
|
||||
'host' => $redis_conf['host'],
|
||||
'port' => $redis_conf['port'],
|
||||
'passwd' => $redis_conf['passwd']
|
||||
));
|
||||
return $r;
|
||||
}
|
||||
|
||||
public function createTeam()
|
||||
{
|
||||
$team_uuid = md5($_REQUEST['account_id']);
|
||||
|
||||
$team_db = array(
|
||||
'team_uuid' => $team_uuid,
|
||||
'auto_fill' => $_REQUEST['auto_fill'],
|
||||
'member_list' => array(
|
||||
'idx' => 1,
|
||||
'accout_id' => $_REQUEST['accout_id'],
|
||||
'name' => $_REQUEST['name'],
|
||||
'avatar_url' => $_REQUEST['avatar_url'],
|
||||
));
|
||||
|
||||
$r = $this->getRedis($team_uuid);
|
||||
$r->set(TEAMID_KEY.$team_uuid, json_encode($team_db));
|
||||
$r->pexpire(TEAMID_KEY.$team_uuid, 1000 * 3600);
|
||||
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
));
|
||||
}
|
||||
|
||||
public function teamInfo()
|
||||
{
|
||||
$r = $this->getRedis($team_uuid);
|
||||
|
||||
if(!$r){
|
||||
echo 'is null';
|
||||
}else{
|
||||
$accountid = $_REQUEST['accout_id'];
|
||||
$sessionid = $_REQUEST['session_id'];
|
||||
$user_db_str = $r->get(TEAMID_KEY.$team_uuid);
|
||||
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)){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||
return;
|
||||
}
|
||||
$member_list = array();
|
||||
for($i = 0; $i < count($user_db['member_list']); $i++)
|
||||
{
|
||||
array_push($member_list, array(
|
||||
'idx' => $user_db['idx'],
|
||||
'account_id' => $user_db['account_id'],
|
||||
'name' => $user_db['name'],
|
||||
'avatar_url' => $user_db['avatar_url'],
|
||||
));
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg'=> '',
|
||||
'team_uuid' => $_REQUSET['team_uuid'],
|
||||
'auto_fill' => $user_db['auto_fill'],
|
||||
'member_list' => $member_list,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public function joinTeam()
|
||||
{
|
||||
$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失效');
|
||||
return;
|
||||
}
|
||||
$user_db = json_decode($user_db_str, true);
|
||||
if(empty($user_db)){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, 'session失效');
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function updateTeam()
|
||||
{
|
||||
$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失效');
|
||||
return;
|
||||
}
|
||||
$user_db = json_decode($user_db_str, true);
|
||||
if(empty($user_db)){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||
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);
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user