메뉴관리 추가 안되는 버그 수정

This commit is contained in:
kjs
2025-10-13 15:01:37 +09:00
parent 8046c2a2e0
commit 6e41fdf039
3 changed files with 695 additions and 490 deletions

View File

@@ -236,11 +236,15 @@ export const getUserList = async (req: AuthenticatedRequest, res: Response) => {
if (fieldMap[searchField as string]) {
if (searchField === "tel") {
whereConditions.push(`(tel ILIKE $${paramIndex} OR cell_phone ILIKE $${paramIndex})`);
whereConditions.push(
`(tel ILIKE $${paramIndex} OR cell_phone ILIKE $${paramIndex})`
);
queryParams.push(`%${searchValue}%`);
paramIndex++;
} else {
whereConditions.push(`${fieldMap[searchField as string]} ILIKE $${paramIndex}`);
whereConditions.push(
`${fieldMap[searchField as string]} ILIKE $${paramIndex}`
);
queryParams.push(`%${searchValue}%`);
paramIndex++;
}
@@ -271,7 +275,9 @@ export const getUserList = async (req: AuthenticatedRequest, res: Response) => {
// 전화번호 검색
if (search_tel && typeof search_tel === "string" && search_tel.trim()) {
whereConditions.push(`(tel ILIKE $${paramIndex} OR cell_phone ILIKE $${paramIndex})`);
whereConditions.push(
`(tel ILIKE $${paramIndex} OR cell_phone ILIKE $${paramIndex})`
);
queryParams.push(`%${search_tel.trim()}%`);
paramIndex++;
hasAdvancedSearch = true;
@@ -305,9 +311,10 @@ export const getUserList = async (req: AuthenticatedRequest, res: Response) => {
paramIndex++;
}
const whereClause = whereConditions.length > 0
? `WHERE ${whereConditions.join(" AND ")}`
: "";
const whereClause =
whereConditions.length > 0
? `WHERE ${whereConditions.join(" AND ")}`
: "";
// 총 개수 조회
const countQuery = `
@@ -345,7 +352,11 @@ export const getUserList = async (req: AuthenticatedRequest, res: Response) => {
LIMIT $${paramIndex} OFFSET $${paramIndex + 1}
`;
const users = await query<any>(usersQuery, [...queryParams, Number(countPerPage), offset]);
const users = await query<any>(usersQuery, [
...queryParams,
Number(countPerPage),
offset,
]);
// 응답 데이터 가공
const processedUsers = users.map((user) => ({
@@ -365,7 +376,9 @@ export const getUserList = async (req: AuthenticatedRequest, res: Response) => {
status: user.status || "active",
companyCode: user.company_code || null,
locale: user.locale || null,
regDate: user.regdate ? new Date(user.regdate).toISOString().split("T")[0] : null,
regDate: user.regdate
? new Date(user.regdate).toISOString().split("T")[0]
: null,
}));
const response = {
@@ -498,10 +511,10 @@ export const setUserLocale = async (
}
// Raw Query로 사용자 로케일 저장
await query(
"UPDATE user_info SET locale = $1 WHERE user_id = $2",
[locale, req.user.userId]
);
await query("UPDATE user_info SET locale = $1 WHERE user_id = $2", [
locale,
req.user.userId,
]);
logger.info("사용자 로케일을 데이터베이스에 저장 완료", {
locale,
@@ -680,9 +693,13 @@ export async function getLangKeyList(
langKey: row.lang_key,
description: row.description,
isActive: row.is_active,
createdDate: row.created_date ? new Date(row.created_date).toISOString() : null,
createdDate: row.created_date
? new Date(row.created_date).toISOString()
: null,
createdBy: row.created_by,
updatedDate: row.updated_date ? new Date(row.updated_date).toISOString() : null,
updatedDate: row.updated_date
? new Date(row.updated_date).toISOString()
: null,
updatedBy: row.updated_by,
}));
@@ -1010,6 +1027,9 @@ export async function saveMenu(
// Raw Query를 사용한 메뉴 저장
const objid = Date.now(); // 고유 ID 생성
// 사용자의 company_code 사용
const companyCode = req.user?.companyCode || "*";
const [savedMenu] = await query<any>(
`INSERT INTO menu_info (
objid, menu_type, parent_obj_id, menu_name_kor, menu_name_eng,
@@ -1030,7 +1050,7 @@ export async function saveMenu(
new Date(),
menuData.status || "active",
menuData.systemName || null,
menuData.companyCode || "*",
companyCode,
menuData.langKey || null,
menuData.langKeyDesc || null,
]
@@ -1079,6 +1099,9 @@ export async function updateMenu(
user: req.user,
});
// 사용자의 company_code 사용
const companyCode = req.user?.companyCode || "*";
// Raw Query를 사용한 메뉴 수정
const [updatedMenu] = await query<any>(
`UPDATE menu_info SET
@@ -1106,7 +1129,7 @@ export async function updateMenu(
menuData.menuDesc || null,
menuData.status || "active",
menuData.systemName || null,
menuData.companyCode || "*",
companyCode,
menuData.langKey || null,
menuData.langKeyDesc || null,
Number(menuId),
@@ -1356,9 +1379,10 @@ export const getDepartmentList = async (
paramIndex++;
}
const whereClause = whereConditions.length > 0
? `WHERE ${whereConditions.join(" AND ")}`
: "";
const whereClause =
whereConditions.length > 0
? `WHERE ${whereConditions.join(" AND ")}`
: "";
const departments = await query<any>(
`SELECT
@@ -1970,7 +1994,9 @@ export const saveUser = async (req: AuthenticatedRequest, res: Response) => {
);
// 기존 사용자인지 새 사용자인지 확인 (regdate로 판단)
const isUpdate = savedUser.regdate && new Date(savedUser.regdate).getTime() < Date.now() - 1000;
const isUpdate =
savedUser.regdate &&
new Date(savedUser.regdate).getTime() < Date.now() - 1000;
logger.info(isUpdate ? "사용자 정보 수정 완료" : "새 사용자 등록 완료", {
userId: userData.userId,