한글뷰어 기능수정

This commit is contained in:
koj729
2026-06-18 08:52:23 +09:00
parent cb0c42fbeb
commit 9268e4e6bc
38 changed files with 2544 additions and 211 deletions

View File

@@ -76,7 +76,7 @@ exports.getProjects = async (req, res) => {
};
exports.createProject = async (req, res) => {
const { project_id, project_nm, short_nm, category, limit_storage, is_active } = req.body;
const { project_id, project_nm, short_nm, category, limit_storage, is_active, overview } = req.body;
if (!project_id || !project_nm) {
return res.status(400).json({ error: "프로젝트 ID와 명칭은 필수입니다." });
}
@@ -93,8 +93,8 @@ exports.createProject = async (req, res) => {
const storage_byte = limit_storage ? parseInt(limit_storage) * 1024 * 1024 * 1024 : 0;
const query = `
INSERT INTO ver4.${tbProject} (project_id, project_nm, short_nm, category, storage_byte, is_active, user_id, create_date)
VALUES ($1, $2, $3, $4, $5, $6, $7, CURRENT_TIMESTAMP)
INSERT INTO ver4.${tbProject} (project_id, project_nm, short_nm, category, storage_byte, is_active, user_id, overview, create_date)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, CURRENT_TIMESTAMP)
RETURNING *;
`;
const result = await client.query(query, [
@@ -104,13 +104,15 @@ exports.createProject = async (req, res) => {
category || null,
storage_byte,
is_active ?? true,
req.user?.user_id || 'admin'
req.user?.user_id || 'admin',
overview !== false // 기본값 true
]);
const userIp = req.headers['cf-connecting-ip'] || req.ip || req.headers['x-forwarded-for'] || req.connection?.remoteAddress;
await insertAuditLog(project_id, 'createProject', req.user?.user_id, userIp, [
`Project Name: ${project_nm}`,
`Category: ${category}`,
`Storage limit: ${limit_storage} GB`
`Storage limit: ${limit_storage} GB`,
`Overview enabled: ${overview !== false}`
]);
res.status(201).json(result.rows[0]);
@@ -124,18 +126,18 @@ exports.createProject = async (req, res) => {
exports.updateProject = async (req, res) => {
const { id } = req.params;
const { project_nm, short_nm, category, limit_storage, is_active } = req.body;
const { project_nm, short_nm, category, limit_storage, is_active, overview } = req.body;
const client = await pool.connect();
try {
const storage_byte = limit_storage ? parseInt(limit_storage) * 1024 * 1024 * 1024 : 0;
const query = `
UPDATE ver4.${tbProject}
SET project_nm = $1, short_nm = $2, category = $3, storage_byte = $4, is_active = $5
WHERE project_id = $6
SET project_nm = $1, short_nm = $2, category = $3, storage_byte = $4, is_active = $5, overview = $6
WHERE project_id = $7
RETURNING *;
`;
const result = await client.query(query, [project_nm, short_nm || null, category || null, storage_byte, is_active, id]);
const result = await client.query(query, [project_nm, short_nm || null, category || null, storage_byte, is_active, overview, id]);
if (result.rows.length === 0) {
return res.status(404).json({ error: "대상을 찾을 수 없습니다." });
}
@@ -144,7 +146,8 @@ exports.updateProject = async (req, res) => {
`Project Name: ${project_nm}`,
`Category: ${category}`,
`Storage limit: ${limit_storage} GB`,
`Active status: ${is_active}`
`Active status: ${is_active}`,
`Overview enabled: ${overview}`
]);
res.status(200).json(result.rows[0]);
} catch (err) {
@@ -517,37 +520,62 @@ exports.createUser = async (req, res) => {
exports.updateUser = async (req, res) => {
const { id } = req.params;
const { user_nm, company, dept, position, group, is_resigned } = req.body;
const { user_nm, user_pw, company, dept, position, group, is_resigned } = req.body;
const client = await pool.connect();
try {
const query = `
UPDATE ver4.tb_user
SET user_nm = $1, company = $2, dept = $3, position = $4, "group" = $5, is_resigned = $6
WHERE user_id = $7
RETURNING *;
`;
const result = await client.query(query, [
user_nm,
company || null,
dept || null,
position || null,
group || null,
is_resigned,
id
]);
let result;
if (user_pw && user_pw.trim() !== '') {
const passwordHash = crypto.createHash('sha256').update(user_pw).digest('hex');
const query = `
UPDATE ver4.tb_user
SET user_nm = $1, user_pw = $2, company = $3, dept = $4, position = $5, "group" = $6, is_resigned = $7
WHERE user_id = $8
RETURNING *;
`;
result = await client.query(query, [
user_nm,
passwordHash,
company || null,
dept || null,
position || null,
group || null,
is_resigned,
id
]);
} else {
const query = `
UPDATE ver4.tb_user
SET user_nm = $1, company = $2, dept = $3, position = $4, "group" = $5, is_resigned = $6
WHERE user_id = $7
RETURNING *;
`;
result = await client.query(query, [
user_nm,
company || null,
dept || null,
position || null,
group || null,
is_resigned,
id
]);
}
if (result.rows.length === 0) {
return res.status(404).json({ error: "대상을 찾을 수 없습니다." });
}
const user = result.rows[0];
const userIp = req.headers['cf-connecting-ip'] || req.ip || req.headers['x-forwarded-for'] || req.connection?.remoteAddress;
await insertAuditLog('SYSTEM', 'updateUser', req.user?.user_id, userIp, [
const details = [
`Updated user_id: ${id}`,
`User name: ${user_nm}`,
`Group: ${group}`,
`Is resigned: ${is_resigned}`
]);
];
if (user_pw && user_pw.trim() !== '') {
details.push("Password was updated");
}
await insertAuditLog('SYSTEM', 'updateUser', req.user?.user_id, userIp, details);
user.user_pw = undefined;
res.status(200).json(user);
} catch (err) {
@@ -671,6 +699,13 @@ exports.updateSystemPolicy = async (req, res) => {
`Limit days: ${limit_days}`,
`Is active: ${is_active}`
]);
try {
const { getIo } = require('../../socket.js');
const io = getIo();
io.emit('updateSystemPolicy_success', result.rows[0]);
} catch (socketErr) {
console.error("Failed to emit updateSystemPolicy_success:", socketErr.message);
}
res.status(200).json(result.rows[0]);
} catch (err) {
console.error("updateSystemPolicy Error:", err);