Merge branch 'main' of https://g.wace.me/jskim/vexplor_dev into jskim-node
This commit is contained in:
@@ -2142,6 +2142,35 @@ export const getDepartmentList = async (
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* GET /api/admin/users/name-map
|
||||
* 사용자 ID → 이름 매핑만 반환하는 경량 엔드포인트
|
||||
* 목적: 이력(writer/created_by 등)에 찍힌 user_id를 이름으로 표시하기 위함
|
||||
* 보안: 민감 정보(전화번호/이메일 등) 미포함, 인증된 사용자면 누구나 조회
|
||||
* 회사 필터 없음 — 최고 관리자 계정(company_code='*')도 포함
|
||||
*/
|
||||
export const getUserNameMap = async (req: AuthenticatedRequest, res: Response) => {
|
||||
try {
|
||||
const rows = await query(
|
||||
`SELECT user_id, user_name FROM user_info WHERE user_id IS NOT NULL`,
|
||||
[]
|
||||
);
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
data: rows.map((r: any) => ({
|
||||
user_id: r.user_id,
|
||||
user_name: r.user_name,
|
||||
})),
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error("사용자 이름 맵 조회 실패", { error });
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: "사용자 이름 맵 조회 중 오류가 발생했습니다.",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* GET /api/admin/users/:userId
|
||||
* 사용자 상세 조회 API
|
||||
|
||||
@@ -174,6 +174,7 @@ export async function getMaterialStatus(
|
||||
ii.item_name AS material_name,
|
||||
ii.item_number AS material_code,
|
||||
ii.unit AS material_unit,
|
||||
ii.inventory_unit AS material_inventory_unit,
|
||||
COALESCE(ii.width::text, '') AS material_width,
|
||||
COALESCE(ii.height::text, '') AS material_height,
|
||||
COALESCE(ii.thickness::text, '') AS material_thickness
|
||||
@@ -220,7 +221,11 @@ export async function getMaterialStatus(
|
||||
materialCode:
|
||||
bomRow.material_code || bomRow.child_item_id,
|
||||
materialName: bomRow.material_name || "알 수 없음",
|
||||
unit: bomRow.bom_unit || bomRow.material_unit || "EA",
|
||||
unit:
|
||||
bomRow.material_inventory_unit ||
|
||||
bomRow.bom_unit ||
|
||||
bomRow.material_unit ||
|
||||
"EA",
|
||||
requiredQty,
|
||||
width: bomRow.material_width || "",
|
||||
height: bomRow.material_height || "",
|
||||
@@ -260,12 +265,16 @@ export async function getMaterialStatus(
|
||||
}
|
||||
|
||||
const stockQuery = `
|
||||
SELECT
|
||||
SELECT
|
||||
s.item_code,
|
||||
s.warehouse_code,
|
||||
w.warehouse_name,
|
||||
s.location_code,
|
||||
COALESCE(CAST(s.current_qty AS NUMERIC), 0) AS current_qty
|
||||
FROM inventory_stock s
|
||||
LEFT JOIN warehouse_info w
|
||||
ON w.warehouse_code = s.warehouse_code
|
||||
AND w.company_code = s.company_code
|
||||
WHERE ${stockConditions.join(" AND ")}
|
||||
AND COALESCE(CAST(s.current_qty AS NUMERIC), 0) > 0
|
||||
ORDER BY s.item_code, s.warehouse_code, s.location_code
|
||||
@@ -277,7 +286,7 @@ export async function getMaterialStatus(
|
||||
// item_code 기준 재고 맵핑 (inventory_stock.item_code는 item_info.item_number 또는 item_info.id일 수 있음)
|
||||
const stockByItem: Record<
|
||||
string,
|
||||
{ location: string; warehouse: string; qty: number }[]
|
||||
{ location: string; warehouse: string; warehouse_name: string; qty: number }[]
|
||||
> = {};
|
||||
|
||||
for (const stockRow of stockResult.rows) {
|
||||
@@ -288,6 +297,7 @@ export async function getMaterialStatus(
|
||||
stockByItem[code].push({
|
||||
location: stockRow.location_code || "",
|
||||
warehouse: stockRow.warehouse_code || "",
|
||||
warehouse_name: stockRow.warehouse_name || "",
|
||||
qty: Number(stockRow.current_qty),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
toggleMenuStatus, // 메뉴 상태 토글
|
||||
copyMenu, // 메뉴 복사
|
||||
getUserList,
|
||||
getUserNameMap, // 사용자 ID→이름 맵 (경량)
|
||||
getUserInfo, // 사용자 상세 조회
|
||||
getUserHistory, // 사용자 변경이력 조회
|
||||
changeUserStatus, // 사용자 상태 변경
|
||||
@@ -70,6 +71,7 @@ router.delete("/menus/:menuId", deleteMenu); // 메뉴 삭제
|
||||
|
||||
// 사용자 관리 API
|
||||
router.get("/users", getUserList);
|
||||
router.get("/users/name-map", getUserNameMap); // 사용자 ID→이름 매핑 (경량)
|
||||
router.get("/users/:userId", getUserInfo); // 사용자 상세 조회
|
||||
router.get("/users/:userId/history", getUserHistory); // 사용자 변경이력 조회
|
||||
router.get("/users/:userId/with-dept", getUserWithDept); // 사원 + 부서 조회 (NEW!)
|
||||
|
||||
Reference in New Issue
Block a user