새 메시지 시스템 통합 준비 완료
This commit is contained in:
+24
-15
@@ -46,15 +46,14 @@ class Message{
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getRawMessage($mailbox, $limit=30, $fromTime=NULL){
|
function getRawMessage($mailbox, $msgType, $limit=30, $fromSeq=NULL){
|
||||||
//'select * from `message` where `mailbox` = 90 and `time` < "2018-01-21 04:47:20" ORDER BY `time` desc LIMIT 3 ';
|
|
||||||
|
|
||||||
|
|
||||||
$sql = 'select * from `message` where `mailbox` = %i_mailbox';
|
|
||||||
if($fromTime !== NULL){
|
$sql = 'select * from `message` where `mailbox` = %i_mailbox and `type` = %s_type and `valid_until` > now()';
|
||||||
$sql .= ' and `time` <= %s_time';
|
if($fromSeq !== NULL){
|
||||||
|
$sql .= ' and `id` > %i_id';
|
||||||
}
|
}
|
||||||
$sql .= ' ORDER BY `time` desc';
|
$sql .= ' ORDER BY `id` desc';
|
||||||
if($limit > 0){
|
if($limit > 0){
|
||||||
$sql .= ' LIMIT %i_limit';
|
$sql .= ' LIMIT %i_limit';
|
||||||
}
|
}
|
||||||
@@ -62,6 +61,7 @@ function getRawMessage($mailbox, $limit=30, $fromTime=NULL){
|
|||||||
//TODO: table 네임의 prefix를 처리할 수 있도록 개선
|
//TODO: table 네임의 prefix를 처리할 수 있도록 개선
|
||||||
$result = getDB()->query($sql, [
|
$result = getDB()->query($sql, [
|
||||||
'mailbox' => $mailbox,
|
'mailbox' => $mailbox,
|
||||||
|
'type' => $msgType,
|
||||||
'limit' => $limit,
|
'limit' => $limit,
|
||||||
'time' => $fromTime
|
'time' => $fromTime
|
||||||
]);
|
]);
|
||||||
@@ -72,24 +72,31 @@ function getRawMessage($mailbox, $limit=30, $fromTime=NULL){
|
|||||||
}, $result);
|
}, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMessage($msgType, $limit=30, $fromTime=NULL){
|
function getMessage($msgType, $nationID=null, $limit=30, $fromSeq=NULL){
|
||||||
$generalID = getGeneralID(false);
|
$generalID = getGeneralID(false);
|
||||||
if($generalID === NULL){
|
if($generalID === NULL){
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($msgType === 'public'){
|
if($msgType === 'public'){
|
||||||
return getRawMessage(9999, $limit, $fromTime);
|
return getRawMessage(9999, 'public', $limit, $fromSeq);
|
||||||
}
|
}
|
||||||
else if($msgType === 'private'){
|
else if($msgType === 'private'){
|
||||||
return getRawMessage($generalID, $limit, $fromTime);
|
return getRawMessage($generalID, 'private', $limit, $fromSeq);
|
||||||
}
|
}
|
||||||
else if($msgType === 'national'){
|
else if($msgType === 'national'){
|
||||||
$nationID = getDB()->queryFirstField(
|
if($nationID === null){
|
||||||
'select `nation` from `general` where no = %i',
|
return [];
|
||||||
$generalID
|
}
|
||||||
);
|
|
||||||
return getRawMessage(9000 + $nationID, $limit, $fromTime);
|
return getRawMessage($nationID + 9000, 'national', $limit, $fromSeq);
|
||||||
|
}
|
||||||
|
else if($msgType === 'diplomacy'){
|
||||||
|
if($nationID === null){
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return getRawMessage($nationID + 9000, 'diplomacy', $limit, $fromSeq);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return [];
|
return [];
|
||||||
@@ -244,6 +251,8 @@ function getMailboxList(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Legacy
|
||||||
function genList($connect) {
|
function genList($connect) {
|
||||||
$query = "select no,nation,level,msgindex,userlevel from general where owner='{$_SESSION['noMember']}'";
|
$query = "select no,nation,level,msgindex,userlevel from general where owner='{$_SESSION['noMember']}'";
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
include('lib.php');
|
||||||
|
include('func.php');
|
||||||
|
|
||||||
|
use utilphp\util as util;
|
||||||
|
|
||||||
|
$generalID = getGeneralID();
|
||||||
|
|
||||||
|
session_write_close(); // 이제 세션 안 쓴다
|
||||||
|
|
||||||
|
$jsonPost = parseJsonPost();
|
||||||
|
|
||||||
|
$reqSequence = toInt(util::array_get($jsonPost['sequence'], 0));
|
||||||
|
|
||||||
|
|
||||||
|
$nationID = getDB()->queryFirstField(
|
||||||
|
'select `nation` from `general` where no = %i',
|
||||||
|
$generalID
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
if($nationID === null){
|
||||||
|
returnJson([
|
||||||
|
'result'=>false,
|
||||||
|
'reason'=>'소속 국가가 없습니다'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
returnJson([
|
||||||
|
'result'=>true,
|
||||||
|
'private'=>getMessage('private', $nationID, 10, $reqSequence),
|
||||||
|
'public'=>getMessage('public', $nationID, 20, $reqSequence),
|
||||||
|
'national'=>getMessage('national', $nationID, 30, $reqSequence),
|
||||||
|
'diplomacy'=>getMessage('diplomacy', $nationID, 10, $reqSequence)
|
||||||
|
]);
|
||||||
+1
-4
@@ -503,13 +503,10 @@ CREATE TABLE `message` (
|
|||||||
`valid_until` DATETIME NOT NULL DEFAULT '9999-12-31 23:59:59',
|
`valid_until` DATETIME NOT NULL DEFAULT '9999-12-31 23:59:59',
|
||||||
`message` TEXT NOT NULL COMMENT 'json',
|
`message` TEXT NOT NULL COMMENT 'json',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
INDEX `by_owner` (`mailbox`, `time`),
|
INDEX `by_mailbox` (`mailbox`, `type`, `time`)
|
||||||
INDEX `by_dest` (`dest`, `time`),
|
|
||||||
INDEX `by_full` (`src`, `dest`, `time`)
|
|
||||||
)
|
)
|
||||||
COLLATE='utf8_general_ci'
|
COLLATE='utf8_general_ci'
|
||||||
ENGINE=InnoDB
|
ENGINE=InnoDB
|
||||||
;
|
|
||||||
|
|
||||||
";
|
";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user