feat: 작업일정 기간 기반 + 프로젝트 연결

- partner_schedules: work_date → start_date/end_date 기간 기반으로 변경
- project_id 컬럼 추가 (projects 테이블 연결, 선택사항)
- 프로젝트 조회 API 추가 (GET /projects/active)
- 일정 조회 시 기간 겹침 조건으로 필터링
- 체크인 시 기간 내 검증 추가
- 프론트엔드: 시작일/종료일 입력 + 프로젝트 선택 드롭다운
- 마이그레이션 SQL 포함 (scripts/migration-schedule-daterange.sql)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-03-13 08:18:53 +09:00
parent fa4c899d95
commit b5b0fa1728
12 changed files with 228 additions and 36 deletions

View File

@@ -3,12 +3,13 @@ const scheduleModel = require('../models/scheduleModel');
// 일정 목록
async function list(req, res) {
try {
const { company_id, date_from, date_to, status, page, limit } = req.query;
const { company_id, date_from, date_to, status, project_id, page, limit } = req.query;
const rows = await scheduleModel.findAll({
company_id: company_id ? parseInt(company_id) : undefined,
date_from,
date_to,
status,
project_id: project_id ? parseInt(project_id) : undefined,
page: page ? parseInt(page) : 1,
limit: limit ? parseInt(limit) : 50
});
@@ -49,12 +50,18 @@ async function mySchedules(req, res) {
// 일정 등록
async function create(req, res) {
try {
const { company_id, work_date } = req.body;
const { company_id, start_date, end_date } = req.body;
if (!company_id) {
return res.status(400).json({ success: false, error: '업체를 선택해주세요' });
}
if (!work_date) {
return res.status(400).json({ success: false, error: '작일은 필수입니다' });
if (!start_date) {
return res.status(400).json({ success: false, error: '작일은 필수입니다' });
}
if (!end_date) {
return res.status(400).json({ success: false, error: '종료일은 필수입니다' });
}
if (end_date < start_date) {
return res.status(400).json({ success: false, error: '종료일은 시작일 이후여야 합니다' });
}
const data = {
...req.body,
@@ -71,6 +78,10 @@ async function create(req, res) {
// 일정 수정
async function update(req, res) {
try {
const { start_date, end_date } = req.body;
if (start_date && end_date && end_date < start_date) {
return res.status(400).json({ success: false, error: '종료일은 시작일 이후여야 합니다' });
}
const row = await scheduleModel.update(req.params.id, req.body);
if (!row) return res.status(404).json({ success: false, error: '일정을 찾을 수 없습니다' });
res.json({ success: true, data: row });