From e61d6ea8fa8e685196c9eb7c87fa74595986898d Mon Sep 17 00:00:00 2001 From: wangwei01 Date: Wed, 27 Mar 2019 16:48:20 +0800 Subject: [PATCH] 1 --- sql/gamedb.sql | 3 + webapp/controller/teamController.class.php | 127 +++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 webapp/controller/teamController.class.php diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 7a28225..4066f28 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -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 */; diff --git a/webapp/controller/teamController.class.php b/webapp/controller/teamController.class.php new file mode 100644 index 0000000..11a128f --- /dev/null +++ b/webapp/controller/teamController.class.php @@ -0,0 +1,127 @@ + $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' => '', + )); + } +} +?>