comment test ongoing
Showing
3 changed files
with
125 additions
and
43 deletions
... | @@ -19,9 +19,9 @@ if (! class_exists("ApiBoard")) | ... | @@ -19,9 +19,9 @@ if (! class_exists("ApiBoard")) |
19 | FROM tblNotice | 19 | FROM tblNotice |
20 | ORDER BY noticeNo DESC | 20 | ORDER BY noticeNo DESC |
21 | "; | 21 | "; |
22 | return json_encode($this->getArray($sql)); | ||
23 | 22 | ||
24 | return makeResultJson(1, "aa"); | 23 | $result=$this->getArray($sql); |
24 | return $this->makeResultJson("1", "", $result); | ||
25 | } | 25 | } |
26 | 26 | ||
27 | //공지사항 정보 | 27 | //공지사항 정보 |
... | @@ -33,7 +33,8 @@ if (! class_exists("ApiBoard")) | ... | @@ -33,7 +33,8 @@ if (! class_exists("ApiBoard")) |
33 | FROM tblNotice | 33 | FROM tblNotice |
34 | WHERE noticeNo='{$noticeNo}' | 34 | WHERE noticeNo='{$noticeNo}' |
35 | "; | 35 | "; |
36 | return json_encode($this->getArray($sql)); | 36 | $result=$this->getArray($sql); |
37 | return $this->makeResultJson("1", "", $result); | ||
37 | 38 | ||
38 | } | 39 | } |
39 | 40 | ||
... | @@ -44,7 +45,8 @@ if (! class_exists("ApiBoard")) | ... | @@ -44,7 +45,8 @@ if (! class_exists("ApiBoard")) |
44 | FROM tblEvent | 45 | FROM tblEvent |
45 | ORDER BY eventNo DESC | 46 | ORDER BY eventNo DESC |
46 | "; | 47 | "; |
47 | return json_encode($this->getArray($sql)); | 48 | $result=$this->getArray($sql); |
49 | return $this->makeResultJson("1", "", $result); | ||
48 | } | 50 | } |
49 | 51 | ||
50 | //이벤트 정보 | 52 | //이벤트 정보 |
... | @@ -55,7 +57,8 @@ if (! class_exists("ApiBoard")) | ... | @@ -55,7 +57,8 @@ if (! class_exists("ApiBoard")) |
55 | FROM tblEvent | 57 | FROM tblEvent |
56 | WHERE eventNo='{$eventNo}' | 58 | WHERE eventNo='{$eventNo}' |
57 | "; | 59 | "; |
58 | return json_encode($this->getArray($sql)); | 60 | $result=$this->getArray($sql); |
61 | return $this->makeResultJson("1", "", $result); | ||
59 | } | 62 | } |
60 | 63 | ||
61 | //자유게시판 게시물 작성 | 64 | //자유게시판 게시물 작성 |
... | @@ -90,7 +93,7 @@ if (! class_exists("ApiBoard")) | ... | @@ -90,7 +93,7 @@ if (! class_exists("ApiBoard")) |
90 | $searchText=$this->req["searchText"]; | 93 | $searchText=$this->req["searchText"]; |
91 | $searchType=$this->req["searchType"]; | 94 | $searchType=$this->req["searchType"]; |
92 | 95 | ||
93 | $where="status=1"; | 96 | $where="WHERE B.status=1"; |
94 | 97 | ||
95 | if(!empty($searchText)){ | 98 | if(!empty($searchText)){ |
96 | if(empty($search_type)){ | 99 | if(empty($search_type)){ |
... | @@ -108,17 +111,18 @@ if (! class_exists("ApiBoard")) | ... | @@ -108,17 +111,18 @@ if (! class_exists("ApiBoard")) |
108 | $sql=" | 111 | $sql=" |
109 | SELECT COUNT(*) | 112 | SELECT COUNT(*) |
110 | FROM tblBoard B | 113 | FROM tblBoard B |
111 | JOIN tblUser U ON B.userFk=U.no | 114 | JOIN tblUser U ON B.userFk=U.userNo |
112 | {$where} | 115 | {$where} |
113 | ORDER BY boardNo DESC | 116 | ORDER BY boardNo DESC |
114 | "; | 117 | "; |
115 | $this->rownum = $this->getValue($sql, "rn"); | 118 | $this->rownum = $this->getValue($sql, "rn"); |
119 | $this->initPage(); | ||
116 | $this->setPageForDevice($this->rownum); | 120 | $this->setPageForDevice($this->rownum); |
117 | 121 | ||
118 | $sql=" | 122 | $sql=" |
119 | SELECT B.*, U.userID, U.userNo | 123 | SELECT B.*, U.userID, U.userNo |
120 | FROM tblBoard B | 124 | FROM tblBoard B |
121 | JOIN tblUser U B.userFk=U.no | 125 | JOIN tblUser U ON B.userFk=U.userNo |
122 | {$where} | 126 | {$where} |
123 | ORDER BY boardNo DESC | 127 | ORDER BY boardNo DESC |
124 | LIMIT {$this->startNum}, {$this->endNum} | 128 | LIMIT {$this->startNum}, {$this->endNum} |
... | @@ -133,7 +137,8 @@ if (! class_exists("ApiBoard")) | ... | @@ -133,7 +137,8 @@ if (! class_exists("ApiBoard")) |
133 | 137 | ||
134 | //게시물 정보 | 138 | //게시물 정보 |
135 | function getInfoOfBoard(){ | 139 | function getInfoOfBoard(){ |
136 | $boardNo = $this->req["no"]; | 140 | //$boardNo = $this->req["no"]; |
141 | $boardNo=1; | ||
137 | $sql=" | 142 | $sql=" |
138 | SELECT * | 143 | SELECT * |
139 | FROM tblBoard | 144 | FROM tblBoard |
... | @@ -340,11 +345,13 @@ if (! class_exists("ApiBoard")) | ... | @@ -340,11 +345,13 @@ if (! class_exists("ApiBoard")) |
340 | function saveComment(){ | 345 | function saveComment(){ |
341 | $commentType=$this->req["commentType"]; | 346 | $commentType=$this->req["commentType"]; |
342 | $targetFk=$this->req["targetFk"]; | 347 | $targetFk=$this->req["targetFk"]; |
343 | $userFk = $this->appUser["no"];; | 348 | //$userFk = $this->appUser["no"];; |
349 | $userFk=$this->req["userFk"]; | ||
344 | $content=$this->req["content"]; | 350 | $content=$this->req["content"]; |
345 | $parentNo=$this->req["parentNo"]; //부모 댓글의 기본키 | 351 | $parentNo=$this->req["parentNo"]; //부모 댓글의 기본키 |
346 | 352 | ||
347 | 353 | ||
354 | |||
348 | if(empty($parentNo)){ //부모가 없을 때 | 355 | if(empty($parentNo)){ //부모가 없을 때 |
349 | $sql=" | 356 | $sql=" |
350 | INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType, status, regDate) | 357 | INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType, status, regDate) |
... | @@ -352,7 +359,7 @@ if (! class_exists("ApiBoard")) | ... | @@ -352,7 +359,7 @@ if (! class_exists("ApiBoard")) |
352 | ( | 359 | ( |
353 | '{$userFk}', | 360 | '{$userFk}', |
354 | '{$targetFk}', | 361 | '{$targetFk}', |
355 | '{$this->mysql_insert_id()}', | 362 | 0, |
356 | 1, | 363 | 1, |
357 | 1, | 364 | 1, |
358 | '{$content}', | 365 | '{$content}', |
... | @@ -362,6 +369,15 @@ if (! class_exists("ApiBoard")) | ... | @@ -362,6 +369,15 @@ if (! class_exists("ApiBoard")) |
362 | ) | 369 | ) |
363 | "; | 370 | "; |
364 | $this->update($sql); | 371 | $this->update($sql); |
372 | |||
373 | $currentNo=$this->mysql_insert_id(); | ||
374 | $sql=" | ||
375 | UPDATE tblComment | ||
376 | SET commentGroup='{$currentNo}' | ||
377 | WHERE commentNo='{$currentNo}' | ||
378 | "; | ||
379 | $this->update($sql); | ||
380 | |||
365 | return $this->makeResultJson("1", "저장되었습니다"); | 381 | return $this->makeResultJson("1", "저장되었습니다"); |
366 | } | 382 | } |
367 | else{ //부모 있을 때 | 383 | else{ //부모 있을 때 |
... | @@ -370,7 +386,9 @@ if (! class_exists("ApiBoard")) | ... | @@ -370,7 +386,9 @@ if (! class_exists("ApiBoard")) |
370 | FROM tblComment | 386 | FROM tblComment |
371 | WHERE commentType='{$commentType}' | 387 | WHERE commentType='{$commentType}' |
372 | AND commentGroup=(SELECT commentGroup FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1) | 388 | AND commentGroup=(SELECT commentGroup FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1) |
389 | AND gOrder=(SELECT gOrder + 1 FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1) | ||
373 | AND depth=(SELECT depth+1 FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1) | 390 | AND depth=(SELECT depth+1 FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1) |
391 | ORDER BY gOrder DESC | ||
374 | LIMIT 0, 1 | 392 | LIMIT 0, 1 |
375 | "; | 393 | "; |
376 | $child=$this->getRow($sql); | 394 | $child=$this->getRow($sql); |
... | @@ -379,7 +397,8 @@ if (! class_exists("ApiBoard")) | ... | @@ -379,7 +397,8 @@ if (! class_exists("ApiBoard")) |
379 | $childOrder=$child["gOrder"]; | 397 | $childOrder=$child["gOrder"]; |
380 | $childDepth=$child["depth"]; | 398 | $childDepth=$child["depth"]; |
381 | 399 | ||
382 | if(!empty(childNo)){ //부모에게 자식이 있을 때 | 400 | if(!empty($childNo)){ //부모에게 자식이 있을 때 |
401 | echo "child exists"; | ||
383 | $sql=" | 402 | $sql=" |
384 | INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType, status, regDate) | 403 | INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType, status, regDate) |
385 | VALUES | 404 | VALUES |
... | @@ -406,15 +425,16 @@ if (! class_exists("ApiBoard")) | ... | @@ -406,15 +425,16 @@ if (! class_exists("ApiBoard")) |
406 | return $this->makeResultJson("1", "저장되었습니다"); | 425 | return $this->makeResultJson("1", "저장되었습니다"); |
407 | } | 426 | } |
408 | else{ //부모에게 자식이 없을 때 | 427 | else{ //부모에게 자식이 없을 때 |
428 | echo "no child"; | ||
409 | $sql=" | 429 | $sql=" |
410 | INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType) | 430 | INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType, status, regDate) |
411 | VALUES | 431 | VALUES |
412 | ( | 432 | ( |
413 | '{$userFk}', | 433 | '{$userFk}', |
414 | '{$targetFk}', | 434 | '{$targetFk}', |
415 | (SELECT commentGroup FROM tblComment WHERE commentNo='{$parentNo}' AND status=1), | 435 | (SELECT commentGroup FROM (SELECT * FROM tblComment) AS tblComment WHERE commentNo='{$parentNo}' AND status=1), |
416 | (SELECT gOrder + 1 FROM tblComment WHERE commentNo='{$parentNo}' AND status=1), | 436 | (SELECT gOrder + 1 FROM (SELECT * FROM tblComment) AS tblComment WHERE commentNo='{$parentNo}' AND status=1), |
417 | (SELECT depth + 1 FROM tblComment WHERE commentNo='{$parentNo}' AND status=1), | 437 | (SELECT depth + 1 FROM (SELECT * FROM tblComment) AS tblComment WHERE commentNo='{$parentNo}' AND status=1), |
418 | '{$content}', | 438 | '{$content}', |
419 | '{$commentType}', | 439 | '{$commentType}', |
420 | 1, | 440 | 1, |
... | @@ -423,10 +443,18 @@ if (! class_exists("ApiBoard")) | ... | @@ -423,10 +443,18 @@ if (! class_exists("ApiBoard")) |
423 | "; | 443 | "; |
424 | $this->update($sql); | 444 | $this->update($sql); |
425 | 445 | ||
446 | $currentNo=$this->mysql_insert_id(); | ||
447 | |||
448 | $sql="SELECT commentGroup FROM tblComment WHERE commentNo='{$parentNo}' AND status=1"; | ||
449 | $commentGroup=$this->getValue($sql, "commentGroup"); | ||
450 | |||
451 | $sql="SELECT gOrder + 1 FROM tblComment WHERE commentNo='{$parentNo}' AND status=1"; | ||
452 | $gOrder=$this->getValue($sql, "gOrder + 1"); | ||
453 | |||
426 | $sql=" | 454 | $sql=" |
427 | UPDATE tblComment | 455 | UPDATE tblComment |
428 | SET gOrder=gOrder+1 | 456 | SET gOrder=gOrder+1 |
429 | 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 | 457 | WHERE commentGroup='{$commentGroup}' AND gOrder >= '{$gOrder}' AND commentNo <> '{$currentNo}' AND status=1 |
430 | "; | 458 | "; |
431 | $this->update($sql); | 459 | $this->update($sql); |
432 | return $this->makeResultJson("1", "저장되었습니다"); | 460 | return $this->makeResultJson("1", "저장되었습니다"); | ... | ... |
... | @@ -40,7 +40,7 @@ if (! class_exists("ApiStatic")){ | ... | @@ -40,7 +40,7 @@ if (! class_exists("ApiStatic")){ |
40 | LIMIT 1 | 40 | LIMIT 1 |
41 | "; | 41 | "; |
42 | $list=$this->getRow($sql); | 42 | $list=$this->getRow($sql); |
43 | return $this->makeResultJson("1", "", $list) | 43 | return $this->makeResultJson("1", "", $list); |
44 | } | 44 | } |
45 | 45 | ||
46 | //메인 페이지 정보 | 46 | //메인 페이지 정보 | ... | ... |
... | @@ -2,13 +2,15 @@ | ... | @@ -2,13 +2,15 @@ |
2 | <? include $_SERVER["DOCUMENT_ROOT"] . "/common/classes/ApiBoard.php" ?> | 2 | <? include $_SERVER["DOCUMENT_ROOT"] . "/common/classes/ApiBoard.php" ?> |
3 | <? | 3 | <? |
4 | $obj = new ApiStatic($_REQUEST, "") ; | 4 | $obj = new ApiStatic($_REQUEST, "") ; |
5 | $obj2= new ApiBoard($req); | 5 | $obj2= new ApiBoard($req) ; |
6 | |||
6 | $kcsInfo = $obj->getKCSpecialVehicleInfo(); | 7 | $kcsInfo = $obj->getKCSpecialVehicleInfo(); |
7 | $organizationCert = $obj->getOrganizationCert(); | 8 | $organizationCert = $obj->getListOfOrganizationCert(); |
8 | $notice = $obj2->getListOfNotice(); | 9 | $notice = $obj2->getListOfNotice(); |
9 | $event = $obj2->getListOfEvent(); | 10 | $event = $obj2->getListOfEvent(); |
10 | $board = $obj2->getListOfBoard() | 11 | $board = $obj2->getListOfBoard(); |
11 | ; //$list = $obj->getListOfAdminPush() ; | 12 | $comment= $obj2->getInfoOfBoard(); |
13 | |||
12 | //$vnum = $obj->virtualNum ; | 14 | //$vnum = $obj->virtualNum ; |
13 | ?> | 15 | ?> |
14 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 16 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
... | @@ -39,30 +41,31 @@ | ... | @@ -39,30 +41,31 @@ |
39 | <script type="text/javascript" src="/common/js/jquery.form.js"></script> | 41 | <script type="text/javascript" src="/common/js/jquery.form.js"></script> |
40 | <script type="text/javascript"> | 42 | <script type="text/javascript"> |
41 | $(document).ready(function(){ | 43 | $(document).ready(function(){ |
44 | var FORM_TARGET_CLS_NM = ".data" ; // 폼을 동적 wrap 할 타겟 ID이름 | ||
45 | var FORM_NAME = "alf" ; // 폼이름 | ||
46 | var FORM_METHOD = "POST" ; // 폼 메쏘드 | ||
47 | var FORM_USE_FILE = false ; // 파일폼 사용 여부 | ||
48 | var FORM_ACTION = "/action_front.php" ; | ||
42 | 49 | ||
43 | $(".getKCS").click2(function(){ | ||
44 | $.ajax({ | ||
45 | url : "/action_front.php?cmd=ApiStatic.getKCSpecialVehicleInfo", | ||
46 | async : false, | ||
47 | cache : false, | ||
48 | dataType: 'json', | ||
49 | success : function(data){ | ||
50 | alert(data["content"]+" || "+data["address"]); | ||
51 | }, | ||
52 | error : function(req, res, error){ | ||
53 | alert(req+res+error); | ||
54 | } | ||
55 | }); | ||
56 | }) ; | ||
57 | 50 | ||
58 | $(".getOrganizationCert").click2(function(){ | 51 | var NEXT_CMD = "" ; // 다은 수행 할 cmd |
52 | |||
53 | |||
54 | $(".saveComment").click2(function(){ | ||
59 | $.ajax({ | 55 | $.ajax({ |
60 | url : "/action_front.php?cmd=ApiStatic.getOrganizationCert", | 56 | type: 'post', |
57 | url : "/action_front.php?cmd=ApiBoard.saveComment", | ||
61 | async : false, | 58 | async : false, |
62 | cache : false, | 59 | cache : false, |
63 | dataType: 'json', | 60 | data:{ |
61 | "commentType" : "FB", | ||
62 | "targetFk" : 1, | ||
63 | "userFk" : 1, | ||
64 | "content" : "37의 대대댓글", | ||
65 | "parentNo" : 37 | ||
66 | }, | ||
64 | success : function(data){ | 67 | success : function(data){ |
65 | alert(data["certNo"]+" || "+data["name"]+data["imgPathCert"]+" || "+data["regDate"]); | 68 | alert(data.returnmessage); |
66 | }, | 69 | }, |
67 | error : function(req, res, error){ | 70 | error : function(req, res, error){ |
68 | alert(req+res+error); | 71 | alert(req+res+error); |
... | @@ -70,14 +73,37 @@ $(document).ready(function(){ | ... | @@ -70,14 +73,37 @@ $(document).ready(function(){ |
70 | }); | 73 | }); |
71 | }) ; | 74 | }) ; |
72 | 75 | ||
73 | $(".saveComment").click2(function(){ | 76 | $("#subm").click2(function(){ |
77 | var val1 = $("#name1").val().toString(); | ||
78 | var val2 = $("#name2").val(); | ||
79 | var val3 = $("#name3").val(); | ||
80 | var val4 = $("#name4").val(); | ||
81 | var val5 = $("#name5").val(); | ||
82 | var val6 = $("#name6").val(); | ||
83 | var val7 = $("#name7").val(); | ||
84 | var val1v = $("#name1v").val(); | ||
85 | var val2v = $("#name2v").val(); | ||
86 | var val3v = $("#name3v").val(); | ||
87 | var val4v = $("#name4v").val(); | ||
88 | var val5v = $("#name5v").val(); | ||
89 | var val6v = $("#name6v").val(); | ||
90 | var val7v = $("#name7v").val(); | ||
74 | $.ajax({ | 91 | $.ajax({ |
75 | url : "/action_front.php?cmd=ApiBoard.saveComment", | 92 | url : "/action_front.php?cmd=ApiBoard.saveComment", |
76 | async : false, | 93 | async : false, |
77 | cache : false, | 94 | cache : false, |
78 | dataType: 'json', | 95 | dataType: 'json', |
96 | data:{ | ||
97 | val1 : $("#name1v").val(), | ||
98 | val2 : parseInt($("#name2v").val()), | ||
99 | val3 : parseInt($("#name3v").val()), | ||
100 | val4 : $("#name4v").val(), | ||
101 | val5 : parseInt($("#name5v").val()), | ||
102 | val6 : $("#name6v").val(), | ||
103 | val7 : $("#name7v").val() | ||
104 | }, | ||
79 | success : function(data){ | 105 | success : function(data){ |
80 | alert(data["certNo"]+" || "+data["name"]+data["imgPathCert"]+" || "+data["regDate"]); | 106 | alert(data.returnmessage); |
81 | }, | 107 | }, |
82 | error : function(req, res, error){ | 108 | error : function(req, res, error){ |
83 | alert(req+res+error); | 109 | alert(req+res+error); |
... | @@ -95,7 +121,10 @@ $(document).ready(function(){ | ... | @@ -95,7 +121,10 @@ $(document).ready(function(){ |
95 | <title>API 테스트 ㅋ</title> | 121 | <title>API 테스트 ㅋ</title> |
96 | </head> | 122 | </head> |
97 | <body> | 123 | <body> |
98 | <div id="Contents" class="notice" style="width:1000px;"> | 124 | <div id="Contents" class="notice" style="width:1000px;" > |
125 | <form name=test1 method=POST> | ||
126 | <span class="button bigrounded blue saveComment btnleft_y">댓글 저장 </span> | ||
127 | </form> | ||
99 | <div class="data"> | 128 | <div class="data"> |
100 | <table class="datacList" id="datacList"> | 129 | <table class="datacList" id="datacList"> |
101 | <thead> | 130 | <thead> |
... | @@ -124,8 +153,33 @@ $(document).ready(function(){ | ... | @@ -124,8 +153,33 @@ $(document).ready(function(){ |
124 | <td class="center">Board</td> | 153 | <td class="center">Board</td> |
125 | <td class=""><?echo $board;?></td> | 154 | <td class=""><?echo $board;?></td> |
126 | </tr> | 155 | </tr> |
156 | <tr> | ||
157 | <td class="center">Comment</td> | ||
158 | <td class=""><?echo $comment;?></td> | ||
159 | </tr> | ||
127 | </table> | 160 | </table> |
128 | </div> | 161 | </div> |
162 | <br> | ||
163 | <form name="test" id="test" method=GET> | ||
164 | <input type="text" id="name1" name="name1" /> : <input type="text" id="name1v" name="name1v" /> | ||
165 | <br> | ||
166 | <input type="text" id="name2" name="name2" /> : <input type="text" id="name2v" name="name2v" /> | ||
167 | <br> | ||
168 | <input type="text" id="name3" name="name3" /> : <input type="text" id="name3v" name="name3v" /> | ||
169 | <br> | ||
170 | <input type="text" id="name4" name="name4" /> : <input type="text" id="name4v" name="name4v" /> | ||
171 | <br> | ||
172 | <input type="text" id="name5" name="name5" /> : <input type="text" id="name5v" name="name5v" /> | ||
173 | <br> | ||
174 | <input type="text" id="name6" name="name6" /> : <input type="text" id="name6v" name="name6v" /> | ||
175 | <br> | ||
176 | <input type="text" id="name7" name="name7" /> : <input type="text" id="name7v" name="name7v" /> | ||
177 | <br> | ||
178 | <a href="#" id="subm" name="subm">Submit</a> | ||
179 | <input type="reset" value="지우기" /> | ||
180 | </form> | ||
129 | </div> | 181 | </div> |
182 | |||
183 | |||
130 | </body> | 184 | </body> |
131 | </html> | 185 | </html> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment