c6547bcf by sayhoChun

comment test ongoing

1 parent 31291c7f
......@@ -19,9 +19,9 @@ if (! class_exists("ApiBoard"))
FROM tblNotice
ORDER BY noticeNo DESC
";
return json_encode($this->getArray($sql));
return makeResultJson(1, "aa");
$result=$this->getArray($sql);
return $this->makeResultJson("1", "", $result);
}
//공지사항 정보
......@@ -33,7 +33,8 @@ if (! class_exists("ApiBoard"))
FROM tblNotice
WHERE noticeNo='{$noticeNo}'
";
return json_encode($this->getArray($sql));
$result=$this->getArray($sql);
return $this->makeResultJson("1", "", $result);
}
......@@ -44,7 +45,8 @@ if (! class_exists("ApiBoard"))
FROM tblEvent
ORDER BY eventNo DESC
";
return json_encode($this->getArray($sql));
$result=$this->getArray($sql);
return $this->makeResultJson("1", "", $result);
}
//이벤트 정보
......@@ -55,7 +57,8 @@ if (! class_exists("ApiBoard"))
FROM tblEvent
WHERE eventNo='{$eventNo}'
";
return json_encode($this->getArray($sql));
$result=$this->getArray($sql);
return $this->makeResultJson("1", "", $result);
}
//자유게시판 게시물 작성
......@@ -90,7 +93,7 @@ if (! class_exists("ApiBoard"))
$searchText=$this->req["searchText"];
$searchType=$this->req["searchType"];
$where="status=1";
$where="WHERE B.status=1";
if(!empty($searchText)){
if(empty($search_type)){
......@@ -108,17 +111,18 @@ if (! class_exists("ApiBoard"))
$sql="
SELECT COUNT(*)
FROM tblBoard B
JOIN tblUser U ON B.userFk=U.no
JOIN tblUser U ON B.userFk=U.userNo
{$where}
ORDER BY boardNo DESC
";
$this->rownum = $this->getValue($sql, "rn");
$this->initPage();
$this->setPageForDevice($this->rownum);
$sql="
SELECT B.*, U.userID, U.userNo
FROM tblBoard B
JOIN tblUser U B.userFk=U.no
JOIN tblUser U ON B.userFk=U.userNo
{$where}
ORDER BY boardNo DESC
LIMIT {$this->startNum}, {$this->endNum}
......@@ -133,7 +137,8 @@ if (! class_exists("ApiBoard"))
//게시물 정보
function getInfoOfBoard(){
$boardNo = $this->req["no"];
//$boardNo = $this->req["no"];
$boardNo=1;
$sql="
SELECT *
FROM tblBoard
......@@ -340,10 +345,12 @@ if (! class_exists("ApiBoard"))
function saveComment(){
$commentType=$this->req["commentType"];
$targetFk=$this->req["targetFk"];
$userFk = $this->appUser["no"];;
//$userFk = $this->appUser["no"];;
$userFk=$this->req["userFk"];
$content=$this->req["content"];
$parentNo=$this->req["parentNo"]; //부모 댓글의 기본키
if(empty($parentNo)){ //부모가 없을 때
$sql="
......@@ -352,7 +359,7 @@ if (! class_exists("ApiBoard"))
(
'{$userFk}',
'{$targetFk}',
'{$this->mysql_insert_id()}',
0,
1,
1,
'{$content}',
......@@ -362,6 +369,15 @@ if (! class_exists("ApiBoard"))
)
";
$this->update($sql);
$currentNo=$this->mysql_insert_id();
$sql="
UPDATE tblComment
SET commentGroup='{$currentNo}'
WHERE commentNo='{$currentNo}'
";
$this->update($sql);
return $this->makeResultJson("1", "저장되었습니다");
}
else{ //부모 있을 때
......@@ -370,7 +386,9 @@ if (! class_exists("ApiBoard"))
FROM tblComment
WHERE commentType='{$commentType}'
AND commentGroup=(SELECT commentGroup FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1)
AND gOrder=(SELECT gOrder + 1 FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1)
AND depth=(SELECT depth+1 FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1)
ORDER BY gOrder DESC
LIMIT 0, 1
";
$child=$this->getRow($sql);
......@@ -379,7 +397,8 @@ if (! class_exists("ApiBoard"))
$childOrder=$child["gOrder"];
$childDepth=$child["depth"];
if(!empty(childNo)){ //부모에게 자식이 있을 때
if(!empty($childNo)){ //부모에게 자식이 있을 때
echo "child exists";
$sql="
INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType, status, regDate)
VALUES
......@@ -406,15 +425,16 @@ if (! class_exists("ApiBoard"))
return $this->makeResultJson("1", "저장되었습니다");
}
else{ //부모에게 자식이 없을 때
echo "no child";
$sql="
INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType)
INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType, status, regDate)
VALUES
(
'{$userFk}',
'{$targetFk}',
(SELECT commentGroup FROM tblComment WHERE commentNo='{$parentNo}' AND status=1),
(SELECT gOrder + 1 FROM tblComment WHERE commentNo='{$parentNo}' AND status=1),
(SELECT depth + 1 FROM tblComment WHERE commentNo='{$parentNo}' AND status=1),
(SELECT commentGroup FROM (SELECT * FROM tblComment) AS tblComment WHERE commentNo='{$parentNo}' AND status=1),
(SELECT gOrder + 1 FROM (SELECT * FROM tblComment) AS tblComment WHERE commentNo='{$parentNo}' AND status=1),
(SELECT depth + 1 FROM (SELECT * FROM tblComment) AS tblComment WHERE commentNo='{$parentNo}' AND status=1),
'{$content}',
'{$commentType}',
1,
......@@ -423,10 +443,18 @@ if (! class_exists("ApiBoard"))
";
$this->update($sql);
$currentNo=$this->mysql_insert_id();
$sql="SELECT commentGroup FROM tblComment WHERE commentNo='{$parentNo}' AND status=1";
$commentGroup=$this->getValue($sql, "commentGroup");
$sql="SELECT gOrder + 1 FROM tblComment WHERE commentNo='{$parentNo}' AND status=1";
$gOrder=$this->getValue($sql, "gOrder + 1");
$sql="
UPDATE tblComment
SET gOrder=gOrder+1
WHERE commentGroup=(SELECT commentGroup FROM tblComment WHERE commentNo='{$parentNo}' AND status=1) AND gOrder > (SELECT gOrder + 1 FROM tblComment WHERE commentNo='{$parentNo}' AND status=1) AND status=1
WHERE commentGroup='{$commentGroup}' AND gOrder >= '{$gOrder}' AND commentNo <> '{$currentNo}' AND status=1
";
$this->update($sql);
return $this->makeResultJson("1", "저장되었습니다");
......
......@@ -40,7 +40,7 @@ if (! class_exists("ApiStatic")){
LIMIT 1
";
$list=$this->getRow($sql);
return $this->makeResultJson("1", "", $list)
return $this->makeResultJson("1", "", $list);
}
//메인 페이지 정보
......
......@@ -2,13 +2,15 @@
<? include $_SERVER["DOCUMENT_ROOT"] . "/common/classes/ApiBoard.php" ?>
<?
$obj = new ApiStatic($_REQUEST, "") ;
$obj2= new ApiBoard($req);
$obj2= new ApiBoard($req) ;
$kcsInfo = $obj->getKCSpecialVehicleInfo();
$organizationCert = $obj->getOrganizationCert();
$organizationCert = $obj->getListOfOrganizationCert();
$notice = $obj2->getListOfNotice();
$event = $obj2->getListOfEvent();
$board = $obj2->getListOfBoard()
; //$list = $obj->getListOfAdminPush() ;
$board = $obj2->getListOfBoard();
$comment= $obj2->getInfoOfBoard();
//$vnum = $obj->virtualNum ;
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
......@@ -39,45 +41,69 @@
<script type="text/javascript" src="/common/js/jquery.form.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var FORM_TARGET_CLS_NM = ".data" ; // 폼을 동적 wrap 할 타겟 ID이름
var FORM_NAME = "alf" ; // 폼이름
var FORM_METHOD = "POST" ; // 폼 메쏘드
var FORM_USE_FILE = false ; // 파일폼 사용 여부
var FORM_ACTION = "/action_front.php" ;
var NEXT_CMD = "" ; // 다은 수행 할 cmd
$(".getKCS").click2(function(){
$(".saveComment").click2(function(){
$.ajax({
url : "/action_front.php?cmd=ApiStatic.getKCSpecialVehicleInfo",
type: 'post',
url : "/action_front.php?cmd=ApiBoard.saveComment",
async : false,
cache : false,
dataType: 'json',
success : function(data){
alert(data["content"]+" || "+data["address"]);
data:{
"commentType" : "FB",
"targetFk" : 1,
"userFk" : 1,
"content" : "37의 대대댓글",
"parentNo" : 37
},
error : function(req, res, error){
alert(req+res+error);
}
});
}) ;
$(".getOrganizationCert").click2(function(){
$.ajax({
url : "/action_front.php?cmd=ApiStatic.getOrganizationCert",
async : false,
cache : false,
dataType: 'json',
success : function(data){
alert(data["certNo"]+" || "+data["name"]+data["imgPathCert"]+" || "+data["regDate"]);
alert(data.returnmessage);
},
error : function(req, res, error){
alert(req+res+error);
}
});
}) ;
$(".saveComment").click2(function(){
$("#subm").click2(function(){
var val1 = $("#name1").val().toString();
var val2 = $("#name2").val();
var val3 = $("#name3").val();
var val4 = $("#name4").val();
var val5 = $("#name5").val();
var val6 = $("#name6").val();
var val7 = $("#name7").val();
var val1v = $("#name1v").val();
var val2v = $("#name2v").val();
var val3v = $("#name3v").val();
var val4v = $("#name4v").val();
var val5v = $("#name5v").val();
var val6v = $("#name6v").val();
var val7v = $("#name7v").val();
$.ajax({
url : "/action_front.php?cmd=ApiBoard.saveComment",
async : false,
cache : false,
dataType: 'json',
data:{
val1 : $("#name1v").val(),
val2 : parseInt($("#name2v").val()),
val3 : parseInt($("#name3v").val()),
val4 : $("#name4v").val(),
val5 : parseInt($("#name5v").val()),
val6 : $("#name6v").val(),
val7 : $("#name7v").val()
},
success : function(data){
alert(data["certNo"]+" || "+data["name"]+data["imgPathCert"]+" || "+data["regDate"]);
alert(data.returnmessage);
},
error : function(req, res, error){
alert(req+res+error);
......@@ -95,7 +121,10 @@ $(document).ready(function(){
<title>API 테스트 ㅋ</title>
</head>
<body>
<div id="Contents" class="notice" style="width:1000px;">
<div id="Contents" class="notice" style="width:1000px;" >
<form name=test1 method=POST>
<span class="button bigrounded blue saveComment btnleft_y">댓글 저장 </span>
</form>
<div class="data">
<table class="datacList" id="datacList">
<thead>
......@@ -124,8 +153,33 @@ $(document).ready(function(){
<td class="center">Board</td>
<td class=""><?echo $board;?></td>
</tr>
<tr>
<td class="center">Comment</td>
<td class=""><?echo $comment;?></td>
</tr>
</table>
</div>
<br>
<form name="test" id="test" method=GET>
<input type="text" id="name1" name="name1" /> : <input type="text" id="name1v" name="name1v" />
<br>
<input type="text" id="name2" name="name2" /> : <input type="text" id="name2v" name="name2v" />
<br>
<input type="text" id="name3" name="name3" /> : <input type="text" id="name3v" name="name3v" />
<br>
<input type="text" id="name4" name="name4" /> : <input type="text" id="name4v" name="name4v" />
<br>
<input type="text" id="name5" name="name5" /> : <input type="text" id="name5v" name="name5v" />
<br>
<input type="text" id="name6" name="name6" /> : <input type="text" id="name6v" name="name6v" />
<br>
<input type="text" id="name7" name="name7" /> : <input type="text" id="name7v" name="name7v" />
<br>
<a href="#" id="subm" name="subm">Submit</a>
<input type="reset" value="지우기" />
</form>
</div>
</body>
</html>
\ No newline at end of file
......