Initial commit: 교육 프로젝트 배포
This commit is contained in:
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
require __DIR__ . '/../../bbs/db_conn.php';
|
||||
|
||||
// PDO 연결 생성
|
||||
$pdo = db_conn();
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
$type = isset($_GET['type']) ? $_GET['type'] : '';
|
||||
|
||||
/* 콘텐츠 상세(수정 모달용) */
|
||||
if ($type === 'content_detail') {
|
||||
$content_id = isset($_GET['content_id']) ? trim($_GET['content_id']) : '';
|
||||
if ($content_id === '') {
|
||||
echo json_encode(['success' => false, 'message' => 'content_id 가 필요합니다.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare("SELECT * FROM edu_contents WHERE content_id = :c LIMIT 1");
|
||||
$stmt->execute([':c' => $content_id]);
|
||||
$item = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$item) {
|
||||
echo json_encode(['success' => false, 'message' => '콘텐츠를 찾을 수 없습니다.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$json = json_encode(['success' => true, 'item' => $item], JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
if ($json === false) {
|
||||
echo json_encode(['success' => false, 'message' => 'JSON encoding failed: ' . json_last_error_msg()]);
|
||||
} else {
|
||||
echo $json;
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
/* 콘텐츠 포스트잇(메모) 목록 조회 */
|
||||
if ($type === 'content_memos') {
|
||||
$content_id = isset($_GET['content_id']) ? trim($_GET['content_id']) : '';
|
||||
if ($content_id === '') {
|
||||
echo json_encode(['success' => false, 'message' => 'content_id 가 필요합니다.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare("SELECT content_id, seq, title, is_active, created_at, updated_at
|
||||
FROM edu_content_memos
|
||||
WHERE content_id = :c
|
||||
ORDER BY seq ASC
|
||||
LIMIT 3");
|
||||
$stmt->execute([':c' => $content_id]);
|
||||
$items = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
echo json_encode(['success' => true, 'items' => $items]);
|
||||
exit;
|
||||
}
|
||||
|
||||
/* 학습목표 추천이유 목록 조회 */
|
||||
if ($type === 'goal_recommends') {
|
||||
$goal_code = isset($_GET['goal_code']) ? trim($_GET['goal_code']) : '';
|
||||
if ($goal_code === '') {
|
||||
echo json_encode(['success' => false, 'message' => 'goal_code 가 필요합니다.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare("SELECT goal_code, seq, title, title2, is_active, created_at, updated_at
|
||||
FROM edu_recommended_goals
|
||||
WHERE goal_code = :g
|
||||
ORDER BY seq ASC");
|
||||
$stmt->execute([':g' => $goal_code]);
|
||||
$items = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
echo json_encode(['success' => true, 'items' => $items]);
|
||||
exit;
|
||||
}
|
||||
|
||||
/* 추천 키워드 목록 조회 */
|
||||
if ($type === 'recommend_keywords') {
|
||||
$stmt = $pdo->prepare("SELECT keyword_code FROM edu_recommend_keywords WHERE is_active='1'");
|
||||
$stmt->execute();
|
||||
$items = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||
echo json_encode(['items' => $items]);
|
||||
exit;
|
||||
}
|
||||
|
||||
/* 카테고리 */
|
||||
if ($type === 'category') {
|
||||
$stmt = $pdo->prepare("CALL proc_get_code_list('CA100')");
|
||||
$stmt->execute();
|
||||
echo json_encode(['items' => $stmt->fetchAll()]);
|
||||
exit;
|
||||
}
|
||||
/* 카테고리구분 */
|
||||
if ($type === 'category_group') {
|
||||
$desc01 = isset($_GET['desc01']) ? $_GET['desc01'] : '';
|
||||
$stmt = $pdo->prepare("CALL proc_get_sub_codes('CA200', :d)");
|
||||
$stmt->execute([':d' => $desc01]);
|
||||
echo json_encode(['items' => $stmt->fetchAll()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/* 새 콘텐츠 등록 학습목표 코드 */
|
||||
if ($type === 'learning_goal') {
|
||||
$year = isset($_GET['year']) ? $_GET['year'] : date('Y');
|
||||
$categoryGroup = isset($_GET['category_group']) ? $_GET['category_group'] : '';
|
||||
|
||||
// 기준년도 + 카테고리구분(중분류)을 함께 사용하는 조회
|
||||
// 카테고리구분(category_group)을 변수 :p 로 받아 edu_learning_goals.quarter 에 매핑합니다.
|
||||
|
||||
$sql = "SELECT goal_code AS code, title AS name
|
||||
FROM edu_learning_goals
|
||||
WHERE base_year = :y
|
||||
AND is_active = '1'";
|
||||
|
||||
$params = [':y' => $year];
|
||||
|
||||
// 카테고리 그룹이 넘어온 경우에만 조건 추가
|
||||
if ($categoryGroup !== '') {
|
||||
$sql .= " AND quarter = :p";
|
||||
$params[':p'] = $categoryGroup;
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY quarter , sort_order";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
echo json_encode(['items' => $stmt->fetchAll()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/* 학습목표 목록 */
|
||||
if ($type === 'learning_goal_all') {
|
||||
$year = isset($_GET['year']) ? $_GET['year'] : date('Y');
|
||||
$quarter = isset($_GET['quarter']) ? $_GET['quarter'] : '';
|
||||
|
||||
$sql = "SELECT goal_code, title, quarter, fn_get_code_name(quarter) AS quarter_name, is_active, remarks, sort_order, goal_no, fn_get_code_name(goal_no) AS goal_no_name FROM edu_learning_goals WHERE base_year=:y AND is_active='1' ";
|
||||
$params = [':y' => $year];
|
||||
|
||||
if ($quarter !== '') {
|
||||
$sql .= " AND quarter=:q";
|
||||
$params[':q'] = $quarter;
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY quarter DESC";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$items = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
echo json_encode(['items' => $items]);
|
||||
exit;
|
||||
}
|
||||
/* 키워드 */
|
||||
if ($type === 'content_keywords') {
|
||||
$content_id = isset($_GET['content_id']) ? $_GET['content_id'] : '';
|
||||
if ($content_id === '') {
|
||||
echo json_encode(['items' => []]);
|
||||
exit;
|
||||
}
|
||||
$stmt = $pdo->prepare("SELECT keyword_code FROM edu_content_keywords WHERE content_id=:c AND is_active='1'");
|
||||
$stmt->execute([':c' => $content_id]);
|
||||
$items = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||
echo json_encode(['items' => $items]);
|
||||
exit;
|
||||
}
|
||||
/*인사이트 이슈구분 코드*/
|
||||
if ($type === 'issue_type_code') {
|
||||
$stmt = $pdo->prepare("CALL proc_get_code_list('IS100')");
|
||||
$stmt->execute();
|
||||
echo json_encode(['items' => $stmt->fetchAll()]);
|
||||
exit;
|
||||
}
|
||||
echo json_encode(['items' => []]);
|
||||
Reference in New Issue
Block a user