feat: 챗봇 신고 페이지 AI 백엔드 추가 및 기타 개선

- ai-service: 챗봇 분석/요약 엔드포인트 추가 (chatbot.py, chatbot_service.py)
- tkreport: 챗봇 신고 페이지 (chat-report.html/js/css), nginx ai-api 프록시
- tkreport: 이미지 업로드 서비스 개선, M-Project 연동 신고자 정보 전달
- system1: TBM 작업보고서 UI 개선
- TKQC: 관리함/수신함 기능 개선

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-03-09 14:11:00 +09:00
parent 5aeda43605
commit d42380ff63
16 changed files with 1522 additions and 59 deletions

View File

@@ -9,6 +9,7 @@
const path = require('path');
const fs = require('fs').promises;
const crypto = require('crypto');
const { execFileSync } = require('child_process');
// sharp는 선택적으로 사용 (설치되어 있지 않으면 리사이징 없이 저장)
let sharp;
@@ -110,6 +111,7 @@ async function saveBase64Image(base64String, prefix = 'issue', category = 'issue
const filepath = path.join(uploadDir, filename);
// sharp가 설치되어 있으면 리사이징 및 최적화
let saved = false;
if (sharp) {
try {
await sharp(buffer)
@@ -119,13 +121,27 @@ async function saveBase64Image(base64String, prefix = 'issue', category = 'issue
})
.jpeg({ quality: QUALITY })
.toFile(filepath);
saved = true;
} catch (sharpError) {
console.error('sharp 처리 실패, 원본 저장:', sharpError.message);
// sharp 실패 시 원본 저장
await fs.writeFile(filepath, buffer);
console.warn('sharp 처리 실패:', sharpError.message);
}
} else {
// sharp가 없으면 원본 그대로 저장
}
// sharp 실패 시 ImageMagick으로 변환 시도 (HEIC 등)
if (!saved) {
try {
const tmpInput = filepath + '.tmp';
await fs.writeFile(tmpInput, buffer);
execFileSync('magick', [tmpInput, '-resize', `${MAX_SIZE.width}x${MAX_SIZE.height}>`, '-quality', String(QUALITY), filepath]);
await fs.unlink(tmpInput).catch(() => {});
saved = true;
} catch (magickError) {
console.warn('ImageMagick 변환 실패:', magickError.message);
}
}
// 모두 실패 시 원본 저장
if (!saved) {
await fs.writeFile(filepath, buffer);
}

View File

@@ -8,6 +8,7 @@
*/
const logger = require('../utils/logger');
const jwt = require('jsonwebtoken');
// M-Project API 설정
const M_PROJECT_CONFIG = {
@@ -183,20 +184,25 @@ async function sendToMProject(issueData) {
category,
description,
reporter_name,
reporter_username = null,
reporter_role = 'user',
project_name,
project_id = null,
tk_issue_id,
location_info = null,
photos = [],
ssoToken = null,
} = issueData;
logger.info('M-Project 연동 시작', { tk_issue_id, category });
// SSO 토큰이 있으면 원래 사용자로 전송, 없으면 api_service 토큰
// 신고자 정보로 SSO JWT 토큰 직접 생성 (api_service 대신 실제 신고자로)
let token;
if (ssoToken) {
token = ssoToken;
if (reporter_username && process.env.JWT_SECRET) {
token = jwt.sign(
{ sub: reporter_username, name: reporter_name || reporter_username, role: reporter_role },
process.env.JWT_SECRET,
{ expiresIn: '1h' }
);
} else {
token = await getAuthToken();
}