Files
Hyungi Ahn 550633b89d feat: 3-System 분리 프로젝트 초기 코드 작성
TK-FB(공장관리+신고)와 M-Project(부적합관리)를 3개 독립 시스템으로
분리하기 위한 전체 코드 구조 작성.
- SSO 인증 서비스 (bcrypt + pbkdf2 이중 해시 지원)
- System 1: 공장관리 (TK-FB 기반, 신고 코드 제거)
- System 2: 신고 (TK-FB에서 workIssue 코드 추출)
- System 3: 부적합관리 (M-Project 기반)
- Gateway 포털 (path-based 라우팅)
- 통합 docker-compose.yml 및 배포 스크립트

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 14:40:11 +09:00

97 lines
2.3 KiB
JavaScript

/**
* 문서 업로드 관리 서비스
*
* 파일 업로드 및 문서 메타데이터 관리 관련 비즈니스 로직 처리
*
* @author TK-FB-Project
* @since 2025-12-11
*/
const uploadModel = require('../models/uploadModel');
const { ValidationError, DatabaseError } = require('../utils/errors');
const logger = require('../utils/logger');
/**
* 문서 업로드 생성
*/
const createUploadService = async (uploadData) => {
const {
title,
tags,
description,
original_name,
stored_name,
file_path,
file_type,
file_size,
submitted_by
} = uploadData;
// 필수 필드 검증
if (!original_name || !stored_name || !file_path) {
throw new ValidationError('필수 필드가 누락되었습니다', {
required: ['original_name', 'stored_name', 'file_path'],
received: { original_name, stored_name, file_path }
});
}
logger.info('문서 업로드 생성 요청', {
title,
original_name,
file_type,
file_size,
submitted_by
});
try {
const insertId = await new Promise((resolve, reject) => {
uploadModel.create(uploadData, (err, id) => {
if (err) reject(err);
else resolve(id);
});
});
logger.info('문서 업로드 생성 성공', {
upload_id: insertId,
original_name,
file_size
});
return { upload_id: insertId };
} catch (error) {
logger.error('문서 업로드 생성 실패', {
original_name,
error: error.message
});
throw new DatabaseError('문서 업로드 생성 중 오류가 발생했습니다');
}
};
/**
* 전체 업로드 문서 조회
*/
const getAllUploadsService = async () => {
logger.info('업로드 문서 목록 조회 요청');
try {
const rows = await new Promise((resolve, reject) => {
uploadModel.getAll((err, data) => {
if (err) reject(err);
else resolve(data);
});
});
logger.info('업로드 문서 목록 조회 성공', { count: rows.length });
return rows;
} catch (error) {
logger.error('업로드 문서 목록 조회 실패', { error: error.message });
throw new DatabaseError('업로드 문서 목록 조회 중 오류가 발생했습니다');
}
};
module.exports = {
createUploadService,
getAllUploadsService
};