From 3ff6788405e34680090bf81c7e6e96bddc01e681 Mon Sep 17 00:00:00 2001 From: hide_d Date: Thu, 17 Jan 2019 03:12:26 +0900 Subject: [PATCH] =?UTF-8?q?[1ddce7ac2e]=EA=B2=8C=EC=8B=9C=EB=AC=BC=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/j_getBoardArticles.php | 73 ++++++++++++++++++++++++++++++++++++++ hwe/sql/reset.sql | 5 +++ hwe/sql/schema.sql | 29 ++++++++++++++- 3 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 hwe/j_getBoardArticles.php diff --git a/hwe/j_getBoardArticles.php b/hwe/j_getBoardArticles.php new file mode 100644 index 00000000..494c6fa3 --- /dev/null +++ b/hwe/j_getBoardArticles.php @@ -0,0 +1,73 @@ +setReadOnly(); +$userID = Session::getUserID(); + +$db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game_env'); + +$isSecretBoard = Util::getReq('isSecret', 'bool', false); + +increaseRefresh("회의실", 1); + +$me = $db->queryFirstRow('SELECT no, nation, level, permission, con, turntime, belong, penalty FROM general WHERE owner=%i', $userID); + + +$con = checkLimit($me['con']); +if ($con >= 2) { + Json::die([ + 'result'=>false, + 'reason'=>'접속 제한입니다.' + ]); +} + +$permission = checkSecretPermission($me); +if($permission < 0){ + Json::die([ + 'result'=>false, + 'reason'=>'국가에 소속되어있지 않습니다.' + ]); + +} +else if ($isSecretBoard && $permission < 2) { + Json::die([ + 'result'=>false, + 'reason'=>'권한이 부족합니다. 수뇌부가 아닙니다.' + ]); +} + +$articles = []; + +foreach( + $db->query( + 'SELECT * FROM board WHERE nation_no = %i AND is_secret = %i ORDER BY date desc', + $me['nation'], + $isSecretBoard + ) as $article +){ + //TODO:아이콘 받아오기 + $article['comment'] = []; + $articles[$article['no']] = $article; +} + +foreach( + $db->query( + 'SELECT * FROM comment WHERE nation_no = %i AND is_secret = %i ORDER BY date asc', + $me['nation'], + $isSecretBoard + ) as $comment +){ + //TODO:아이콘 받아오기? + $articles[$article['no']]['comment'] = $comment; +} + +Json::die([ + 'result'=>true, + 'articles'=>$articles, + 'reason'=>'success' +]); + diff --git a/hwe/sql/reset.sql b/hwe/sql/reset.sql index 1b9a4165..bf721196 100644 --- a/hwe/sql/reset.sql +++ b/hwe/sql/reset.sql @@ -4,6 +4,11 @@ DROP TABLE IF EXISTS `general_turn`; # 국가 테이블 삭제 DROP TABLE IF EXISTS nation; DROP TABLE IF EXISTS `nation_turn`; + +# 회의실 테이블 삭제 +DROP TABLE IF EXISTS board; +DROP TABLE IF EXISTS comment; + # 도시 테이블 삭제 DROP TABLE IF EXISTS city; diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index 349dc46c..01523d2f 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -329,6 +329,33 @@ CREATE TABLE `nation_turn` ( PRIMARY KEY (`id`), UNIQUE INDEX `nation` (`nation_id`, `level`, `turn_idx`), INDEX `action` (`action`, `turn_idx`, `nation_id`, `level`) +##회의실 +CREATE TABLE `board` ( + `no` INT(11) NOT NULL AUTO_INCREMENT, + `nation_no` INT(11) NOT NULL, + `is_secret` TINYINT(1) NOT NULL, + `date` DATETIME NOT NULL, + `general_no` INT(11) NOT NULL, + `author` VARCHAR(32) NOT NULL, + `title` TEXT NOT NULL, + `text` TEXT NOT NULL, + PRIMARY KEY (`no`), + INDEX `nation_no` (`nation_no`, `is_secret`, `date`) +) +ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; + +CREATE TABLE `comment` ( + `no` INT(11) NOT NULL AUTO_INCREMENT, + `nation_no` INT(11) NOT NULL, + `is_secret` TINYINT(1) NOT NULL, + `date` DATETIME NOT NULL, + `document_no` INT(11) NOT NULL, + `general_no` INT(11) NOT NULL, + `author` VARCHAR(32) NOT NULL, + `text` TEXT NOT NULL, + PRIMARY KEY (`no`), + INDEX `nation_no` (`nation_no`, `is_secret`, `date`), + INDEX `document_no` (`document_no`, `date`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; @@ -732,4 +759,4 @@ CREATE TABLE IF NOT EXISTS `storage` ( UNIQUE INDEX `key` (`namespace`, `key`) ) COLLATE='utf8mb4_general_ci' -ENGINE=MyISAM +ENGINE=MyISAM \ No newline at end of file