e160835f4cf7969a289af7165aba9cc397d2139c.svn-base
7.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
<? include $_SERVER["DOCUMENT_ROOT"] . "/common/classes/ApiBase.php" ;?>
<?
if (! class_exists("ApiBoard"))
{
class ApiBoard extends ApiBase
{
function __construct($req)
{
parent::__construct($req);
}
/**
* 민원 등록
*
* @return string
*/
function saveBoard(){
$userNo = $this->appUser["no"];
$board_type = $this->req["board_type"];
$contents = $this->req["contents"];
$no = $this->req["no"];
$is_public = $this->req["is_public"];
if ($no == ""){
$sql = "
INSERT INTO tbl_board(board_type, user_fk, contents, is_public, reg_dt, status)
VALUES('{$board_type}', '{$userNo}', '{$contents}', '{$is_public}', NOW(), 'H')
";
$result = $this->update($sql);
if ($result > 0){
$no = $this->mysql_insert_id();
$userInfo = $this->inFn_ApiBase_getInfoOfUser($userNo);
LogUtil::writeFileLog($this->logPath, $board_type . " :: " . $userInfo["member_type"]);
// 푸시 정보 저장
if ($board_type == $this->BOARD_TYPE_IP){
$sql = "
INSERT INTO(group_code, push_msg, board_no, user_fk)
(
SELECT '정보나눔 글이 등록되었습니다.', '{$no}'
FROM v_alive_user U
WHERE U.group_cd = '{$userInfo["group_cd"]}'
)
";
}
else if($userInfo["member_type"] == $this->MEM_TYPE_MEMBER)
{
$sql = "
SELECT *
FROM tbl_admin
WHERE target_fk = '{$userInfo["group_fk"]}' AND admin_type = 2 AND is_inquire_position = 1 AND is_apply = 1
LIMIT 1
";
$adminInfo = $this->getRow($sql);
//TODO sms테스트 필요
if($adminInfo != null && $adminInfo["admin_phone"] != "") {
$retVal = $this->sendSMS("민원이 등록되었습니다.\n확인바랍니다.", $adminInfo["admin_phone"], $this->SEND_SMS_PHONE);
if(!$retVal) {
return $this->makeResultJson(-9999, "SMS 에러");
}
}
}
return $this->makeResultJson("1", "등록되었습니다.", $no);
}
else
{
return $this->makeResultJson("-1", "등록에 실패했습니다.", $no);
}
}
else
{
$sql = "
UPDATE tbl_board
SET
contents = '{$contents}'
, board_type = '{$board_type}'
, is_public = '{$is_public}'
WHERE `no` = '{$no}'
";
$this->update($sql);
return $this->makeResultJson("1", "수정되었습니다.", $no);
}
}
/**
* 민원 삭제
*/
function delBoard()
{
$no = $this->req["no"];
$sql = "
UPDATE tbl_board
SET is_apply = '-1'
WHERE `no` = '{$no}'
";
$this->update($sql);
return $this->makeResultJson("1", "삭제되었습니다.");
}
/**
* 민원 리스트
*/
function getListOfBoard()
{
$userNo = $this->appUser["no"];
$userInfo = $this->inFn_ApiBase_getInfoOfUser($userNo);
$where = " WHERE B.is_apply = 1 AND B.user_fk='{$userNo}'";
$this->initPage();
$sql = "
SELECT COUNT(*)
FROM tbl_board B
JOIN tbl_user U ON(B.user_fk = U.no)
{$where}
";
$this->rownum = $this->getValue($sql, "rn");
$this->setPage($this->rownum);
$sql = "
SELECT
B.*
, (SELECT COUNT(*) FROM tbl_comment C WHERE C.target_fk = B.no AND C.comm_type = '{$this->COMMENT_TYPE_BOARD}') AS comment_count
, U.name
,
IFNULL(
(SELECT F.file_vir_name FROM tbl_file F WHERE F.pa_no = U.no AND F.file_type = '{$this->FILE_TYPE_MEM}' LIMIT 1)
, ''
) AS user_img
FROM tbl_board B
JOIN tbl_user U ON(B.user_fk = U.no)
{$where}
ORDER BY `no` DESC
LIMIT {$this->startNum}, {$this->endNum}
";
$list = $this->getArray($sql);
if (sizeof($list) > 0)
return $this->makeResultJson("1", "", $list);
else
return $this->makeResultJson("-1000", "내역이 없습니다.");
}
/**
* 민원 상세보기
*
* @return string
*/
function getInfoOfBoard()
{
$boardNo = $this->req["no"];
$sql = "
SELECT
B.*
, (SELECT COUNT(*) FROM tbl_comment C WHERE C.target_fk = B.no AND C.comm_type = '{$this->COMMENT_TYPE_BOARD}') AS comment_count
, U.name
,
IFNULL(
(SELECT F.file_vir_name FROM tbl_file F WHERE F.pa_no = U.no AND F.file_type = '{$this->FILE_TYPE_MEM}' LIMIT 1)
, ''
) AS user_img
FROM tbl_board B
JOIN tbl_user U ON(B.user_fk = U.no)
WHERE B.no = '{$boardNo}'
LIMIT 1
";
$result = $this->getRow($sql);
if ($result != null)
{
$sql = "
SELECT
C.*
, U.name
,
IFNULL(
(SELECT F.file_vir_name FROM tbl_file F WHERE F.pa_no = U.no AND F.file_type = '{$this->FILE_TYPE_MEM}' LIMIT 1)
, ''
) AS user_img
FROM tbl_comment C
JOIN tbl_user U ON(C.user_fk = U.no)
WHERE target_fk = '{$boardNo}' AND C.comm_type = '{$this->COMMENT_TYPE_BOARD}'
ORDER BY no DESC
";
$commList = $this->getArray($sql);
return $this->makeResultJson("1", "", $result, Array(
"comm_list" => $commList
));
}
else
return $this->makeResultJson("-1000", "내역이 없습니다.");
}
/**
* 민원 댓글 리스트
* /action_front.php?cmd=ApiBoard.getListOfBoardComment&no=1&page=1
*
* @return string
*/
function getListOfBoardComment()
{
$no = $this->req["no"];
$this->initPage();
$sql = "
SELECT COUNT(*)
FROM v_alive_board_comment co, tbl_user us
WHERE
co.target_fk='{$no}'
AND co.user_fk = us.no
ORDER BY co.no ASC
";
$this->rownum = $this->getValue($sql, "rn");
$this->setPage($this->rownum);
$sql = "
SELECT
co.*
, us.name as mem_name
, (SELECT f.file_vir_name FROM tbl_file f WHERE f.pa_no=us.no AND f.file_type='{$this->FILE_TYPE_MEM}' LIMIT 0, 1) AS mem_file
FROM
v_alive_board_comment co, tbl_user us
WHERE
co.target_fk='{$no}'
AND co.user_fk = us.no
ORDER BY co.no ASC
LIMIT {$this->startNum}, {$this->endNum}
";
$list = $this->getArray($sql);
if (sizeof($list) > 0)
return $this->makeResultJson("1", "", $list);
else
return $this->makeResultJson("-1000", "내역이 없습니다.");
}
/**
* 댓글 등록
*
* @return string
*/
function saveBoardComment()
{
$boardNo = $this->req["boardNo"];
$userNo = $this->appUser["no"];
$comment = $this->req["comment"];
//$userNo = 20;
if ($boardNo == "")
return $this->makeResultJson("-100", "비정상 접근");
if ($comment == "")
return $this->makeResultJson("-102", "댓글 내용을 입력해주세요.");
$sql = "
INSERT INTO tbl_comment(user_fk, target_fk, comment, comm_type, reg_dt)
VALUES('{$userNo}', '{$boardNo}', '{$comment}', '{$this->COMMENT_TYPE_BOARD}', NOW())
";
$result = $this->update($sql);
if ($result > 0)
{
// 푸시 전송
$sql = "
SELECT U.*
FROM tbl_board B
JOIN tbl_user U ON(B.user_fk = U.no)
WHERE B.no = '{$boardNo}' AND U.is_push = 1 AND U.comm_push = 1 AND U.registration_key != ''
LIMIT 1
";
$pushKey = $this->getRow($sql);
if($pushKey != null && $userNo != $pushKey["no"])
{
$pushObj = new Push();
$pushObj->pushFlag = $this->PUSH_TYPE_BI_COM;
$pushObj->pushMessage = "댓글이 등록되었습니다.";
$pushObj->pushNo = $boardNo;
$pushObj->sendPushOnce($pushKey);
}
return $this->makeResultJson("1", "등록되었습니다.");
}
else
return $this->makeResultJson("-1", "등록에 실패했습니다.");
}
/**
* 민원 댓글 삭제
*
* @return string
*/
function delBoardComment()
{
$commentNo = $this->req["commentNo"];
$this->inFn_ApiBase_delComment($commentNo);
return $this->makeResultJson("1", "삭제되었습니다.");
}
} // 클래스 종료
}
?>