feat(tkpurchase): 체크인 worker_names 배열 저장 + 구매팀 체크인 관리 기능

- doCheckIn()에서 worker_names를 콤마 split 배열로 전송 (DB에 JSON 배열로 저장)
- 구매팀 일정 페이지에 체크인 조회/수정/삭제 모달 추가
- DELETE /checkins/:id endpoint + 트랜잭션 삭제 (reports cascade)
- PUT /checkins/:id에 requirePage 권한 guard 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-03-13 10:53:46 +09:00
parent 9fda89a374
commit b14448fc54
6 changed files with 143 additions and 8 deletions

View File

@@ -78,4 +78,32 @@ async function countActive() {
return rows[0].cnt;
}
module.exports = { findBySchedule, findById, findTodayByCompany, checkIn, checkOut, update, resetCheckout, countActive };
async function deleteCheckin(id) {
const checkin = await findById(id);
if (!checkin) return false;
const db = getPool();
const conn = await db.getConnection();
try {
await conn.beginTransaction();
await conn.query('DELETE FROM partner_work_reports WHERE checkin_id = ?', [id]);
await conn.query('DELETE FROM partner_work_checkins WHERE id = ?', [id]);
const [remaining] = await conn.query(
'SELECT COUNT(*) AS cnt FROM partner_work_checkins WHERE schedule_id = ?',
[checkin.schedule_id]);
if (remaining[0].cnt === 0) {
await conn.query(
"UPDATE partner_schedules SET status = 'scheduled' WHERE id = ? AND status = 'in_progress'",
[checkin.schedule_id]);
}
await conn.commit();
return true;
} catch (err) {
await conn.rollback();
throw err;
} finally {
conn.release();
}
}
module.exports = { findBySchedule, findById, findTodayByCompany, checkIn, checkOut, update, resetCheckout, countActive, deleteCheckin };