회사코드 입력, 작성자 입력가능하게 수정완료

This commit is contained in:
leeheejin
2025-11-03 16:26:32 +09:00
parent 4dba7c0a16
commit 94e5a5de0b
7 changed files with 86 additions and 25 deletions

View File

@@ -12,6 +12,14 @@ export const saveFormData = async (
const { companyCode, userId } = req.user as any;
const { screenId, tableName, data } = req.body;
// 🔍 디버깅: 사용자 정보 확인
console.log("🔍 [saveFormData] 사용자 정보:", {
userId,
companyCode,
reqUser: req.user,
dataWriter: data.writer,
});
// 필수 필드 검증 (screenId는 0일 수 있으므로 undefined 체크)
if (screenId === undefined || screenId === null || !tableName || !data) {
return res.status(400).json({
@@ -25,9 +33,12 @@ export const saveFormData = async (
...data,
created_by: userId,
updated_by: userId,
writer: data.writer || userId, // ✅ writer가 없으면 userId로 설정
screen_id: screenId,
};
console.log("✅ [saveFormData] 최종 writer 값:", formDataWithMeta.writer);
// company_code는 사용자가 명시적으로 입력한 경우에만 추가
if (data.company_code !== undefined) {
formDataWithMeta.company_code = data.company_code;
@@ -86,6 +97,7 @@ export const saveFormDataEnhanced = async (
...data,
created_by: userId,
updated_by: userId,
writer: data.writer || userId, // ✅ writer가 없으면 userId로 설정
screen_id: screenId,
};
@@ -134,6 +146,7 @@ export const updateFormData = async (
const formDataWithMeta = {
...data,
updated_by: userId,
writer: data.writer || userId, // ✅ writer가 없으면 userId로 설정
updated_at: new Date(),
};
@@ -186,6 +199,7 @@ export const updateFormDataPartial = async (
const newDataWithMeta = {
...newData,
updated_by: userId,
writer: newData.writer || userId, // ✅ writer가 없으면 userId로 설정
};
const result = await dynamicFormService.updateFormDataPartial(