fix: 캘린더 모달 중복 카드 문제 및 삭제 권한 개선

- monthly_worker_status 조회 시 GROUP BY로 중복 데이터 합산
- 작업보고서 삭제 권한을 그룹장 이상으로 제한 (admin, system, group_leader)
- 중복 데이터 정리를 위한 마이그레이션 SQL 추가 (009_fix_duplicate_monthly_status.sql)
- synology_deployment 버전에도 동일 수정 적용
This commit is contained in:
Hyungi Ahn
2025-12-02 13:08:44 +09:00
parent beaffcad49
commit a9bce9d20b
419 changed files with 275129 additions and 394 deletions

View File

@@ -0,0 +1,89 @@
const { getDb } = require('../dbPool');
// 1. 전체 도구 조회
const getAll = async (callback) => {
try {
const db = await getDb();
const [rows] = await db.query('SELECT * FROM Tools');
callback(null, rows);
} catch (err) {
callback(err);
}
};
// 2. 단일 도구 조회
const getById = async (id, callback) => {
try {
const db = await getDb();
const [rows] = await db.query('SELECT * FROM Tools WHERE id = ?', [id]);
callback(null, rows[0]);
} catch (err) {
callback(err);
}
};
// 3. 도구 생성
const create = async (tool, callback) => {
try {
const db = await getDb();
const { name, location, stock, status, factory_id, map_x, map_y, map_zone, map_note } = tool;
const [result] = await db.query(
`INSERT INTO Tools
(name, location, stock, status, factory_id, map_x, map_y, map_zone, map_note)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
[name, location, stock, status, factory_id, map_x, map_y, map_zone, map_note]
);
callback(null, result.insertId);
} catch (err) {
callback(err);
}
};
// 4. 도구 수정
const update = async (id, tool, callback) => {
try {
const db = await getDb();
const { name, location, stock, status, factory_id, map_x, map_y, map_zone, map_note } = tool;
const [result] = await db.query(
`UPDATE Tools
SET name = ?,
location = ?,
stock = ?,
status = ?,
factory_id = ?,
map_x = ?,
map_y = ?,
map_zone = ?,
map_note = ?
WHERE id = ?`,
[name, location, stock, status, factory_id, map_x, map_y, map_zone, map_note, id]
);
callback(null, result.affectedRows);
} catch (err) {
callback(new Error(err.message || String(err)));
}
};
// 5. 도구 삭제
const remove = async (id, callback) => {
try {
const db = await getDb();
const [result] = await db.query('DELETE FROM Tools WHERE id = ?', [id]);
callback(null, result.affectedRows);
} catch (err) {
callback(err);
}
};
// ✅ export 정리
module.exports = {
getAll,
getById,
create,
update,
remove
};