feat: 다수 기능 개선 - 순찰, 출근, 작업분석, 모바일 UI 등
- 순찰/점검 기능 개선 (zone-detail 페이지 추가) - 출근/근태 시스템 개선 (연차 조회, 근무현황) - 작업분석 대분류 그룹화 및 마이그레이션 스크립트 - 모바일 네비게이션 UI 추가 - NAS 배포 도구 및 문서 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
103
deploy/tkfb-package/api.hyungi.net/routes/workplaceRoutes.js
Normal file
103
deploy/tkfb-package/api.hyungi.net/routes/workplaceRoutes.js
Normal file
@@ -0,0 +1,103 @@
|
||||
// routes/workplaceRoutes.js
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const multer = require('multer');
|
||||
const path = require('path');
|
||||
const workplaceController = require('../controllers/workplaceController');
|
||||
const {
|
||||
generateSafeFilename,
|
||||
createFileFilter,
|
||||
ALLOWED_IMAGE_EXTENSIONS
|
||||
} = require('../utils/fileUploadSecurity');
|
||||
|
||||
// Multer 설정 - 작업장 레이아웃 이미지 업로드 (보안 강화)
|
||||
const storage = multer.diskStorage({
|
||||
destination: (req, file, cb) => {
|
||||
cb(null, path.join(__dirname, '../uploads'));
|
||||
},
|
||||
filename: (req, file, cb) => {
|
||||
// 안전한 랜덤 파일명 생성 (원본 파일명 노출 방지)
|
||||
const safeName = generateSafeFilename(file.originalname);
|
||||
cb(null, `workplace-layout-${safeName}`);
|
||||
}
|
||||
});
|
||||
|
||||
// 보안 강화된 파일 필터
|
||||
const imageFileFilter = createFileFilter({
|
||||
allowedExtensions: ALLOWED_IMAGE_EXTENSIONS,
|
||||
allowedMimes: ['image/jpeg', 'image/png', 'image/gif', 'image/webp']
|
||||
});
|
||||
|
||||
const upload = multer({
|
||||
storage,
|
||||
fileFilter: imageFileFilter,
|
||||
limits: {
|
||||
fileSize: 5 * 1024 * 1024, // 5MB 제한
|
||||
files: 1 // 단일 파일만 허용
|
||||
}
|
||||
});
|
||||
|
||||
// ==================== 카테고리(공장) 관리 ====================
|
||||
|
||||
// CREATE 카테고리
|
||||
router.post('/categories', workplaceController.createCategory);
|
||||
|
||||
// READ ALL 카테고리
|
||||
router.get('/categories', workplaceController.getAllCategories);
|
||||
|
||||
// READ ACTIVE 카테고리
|
||||
router.get('/categories/active/list', workplaceController.getActiveCategories);
|
||||
|
||||
// READ ONE 카테고리
|
||||
router.get('/categories/:id', workplaceController.getCategoryById);
|
||||
|
||||
// UPDATE 카테고리
|
||||
router.put('/categories/:id', workplaceController.updateCategory);
|
||||
|
||||
// DELETE 카테고리
|
||||
router.delete('/categories/:id', workplaceController.deleteCategory);
|
||||
|
||||
// ==================== 작업장 관리 ====================
|
||||
|
||||
// CREATE 작업장
|
||||
router.post('/', workplaceController.createWorkplace);
|
||||
|
||||
// READ ALL 작업장 (쿼리 파라미터로 카테고리 필터링 가능: ?category_id=1)
|
||||
router.get('/', workplaceController.getAllWorkplaces);
|
||||
|
||||
// READ ACTIVE 작업장
|
||||
router.get('/active/list', workplaceController.getActiveWorkplaces);
|
||||
|
||||
// READ ONE 작업장
|
||||
router.get('/:id', workplaceController.getWorkplaceById);
|
||||
|
||||
// UPDATE 작업장
|
||||
router.put('/:id', workplaceController.updateWorkplace);
|
||||
|
||||
// DELETE 작업장
|
||||
router.delete('/:id', workplaceController.deleteWorkplace);
|
||||
|
||||
// ==================== 작업장 지도 영역 관리 ====================
|
||||
|
||||
// 카테고리 레이아웃 이미지 업로드
|
||||
router.post('/categories/:id/layout-image', upload.single('image'), workplaceController.uploadCategoryLayoutImage);
|
||||
|
||||
// 작업장 레이아웃 이미지 업로드
|
||||
router.post('/:id/layout-image', upload.single('image'), workplaceController.uploadWorkplaceLayoutImage);
|
||||
|
||||
// CREATE 지도 영역
|
||||
router.post('/map-regions', workplaceController.createMapRegion);
|
||||
|
||||
// READ 카테고리별 지도 영역
|
||||
router.get('/categories/:categoryId/map-regions', workplaceController.getMapRegionsByCategory);
|
||||
|
||||
// READ 작업장별 지도 영역
|
||||
router.get('/map-regions/workplace/:workplaceId', workplaceController.getMapRegionByWorkplace);
|
||||
|
||||
// UPDATE 지도 영역
|
||||
router.put('/map-regions/:id', workplaceController.updateMapRegion);
|
||||
|
||||
// DELETE 지도 영역
|
||||
router.delete('/map-regions/:id', workplaceController.deleteMapRegion);
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user