feat(UniversalFormModal): 전용 API 저장 기능 및 사원+부서 통합 저장 API 구현
- CustomApiSaveConfig 타입 정의 (apiType, mainDeptFields, subDeptFields) - saveWithCustomApi() 함수 추가로 테이블 직접 저장 대신 전용 API 호출 - adminController에 saveUserWithDept(), getUserWithDept() API 추가 - user_info + user_dept 트랜잭션 저장, 메인 부서 변경 시 자동 겸직 전환 - ConfigPanel에 전용 API 저장 설정 UI 추가 - SplitPanelLayout2: getColumnValue()로 조인 테이블 컬럼 값 추출 개선 - 검색 컬럼 선택 시 표시 컬럼 기반으로 변경
This commit is contained in:
@@ -183,6 +183,127 @@ export async function checkDuplicateUserId(userId: string) {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 사원 + 부서 통합 관리 API
|
||||
// ============================================================
|
||||
|
||||
/**
|
||||
* 사원 + 부서 정보 저장 요청 타입
|
||||
*/
|
||||
export interface SaveUserWithDeptRequest {
|
||||
userInfo: {
|
||||
user_id: string;
|
||||
user_name: string;
|
||||
user_name_eng?: string;
|
||||
user_password?: string;
|
||||
email?: string;
|
||||
tel?: string;
|
||||
cell_phone?: string;
|
||||
sabun?: string;
|
||||
user_type?: string;
|
||||
user_type_name?: string;
|
||||
status?: string;
|
||||
locale?: string;
|
||||
dept_code?: string;
|
||||
dept_name?: string;
|
||||
position_code?: string;
|
||||
position_name?: string;
|
||||
};
|
||||
mainDept?: {
|
||||
dept_code: string;
|
||||
dept_name?: string;
|
||||
position_name?: string;
|
||||
};
|
||||
subDepts?: Array<{
|
||||
dept_code: string;
|
||||
dept_name?: string;
|
||||
position_name?: string;
|
||||
}>;
|
||||
isUpdate?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 사원 + 부서 정보 응답 타입
|
||||
*/
|
||||
export interface UserWithDeptResponse {
|
||||
userInfo: Record<string, any>;
|
||||
mainDept: {
|
||||
dept_code: string;
|
||||
dept_name?: string;
|
||||
position_name?: string;
|
||||
is_primary: boolean;
|
||||
} | null;
|
||||
subDepts: Array<{
|
||||
dept_code: string;
|
||||
dept_name?: string;
|
||||
position_name?: string;
|
||||
is_primary: boolean;
|
||||
}>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 사원 + 부서 통합 저장
|
||||
*
|
||||
* user_info와 user_dept 테이블에 트랜잭션으로 동시 저장합니다.
|
||||
* - 메인 부서 변경 시 기존 메인은 겸직으로 자동 전환
|
||||
* - 겸직 부서는 전체 삭제 후 재입력 방식
|
||||
*
|
||||
* @param data 저장할 사원 및 부서 정보
|
||||
* @returns 저장 결과
|
||||
*/
|
||||
export async function saveUserWithDept(data: SaveUserWithDeptRequest): Promise<ApiResponse<{ userId: string; isUpdate: boolean }>> {
|
||||
try {
|
||||
console.log("사원+부서 통합 저장 API 호출:", data);
|
||||
|
||||
const response = await apiClient.post("/admin/users/with-dept", data);
|
||||
|
||||
console.log("사원+부서 통합 저장 API 응답:", response.data);
|
||||
return response.data;
|
||||
} catch (error: any) {
|
||||
console.error("사원+부서 통합 저장 API 오류:", error);
|
||||
|
||||
// Axios 에러 응답 처리
|
||||
if (error.response?.data) {
|
||||
return error.response.data;
|
||||
}
|
||||
|
||||
return {
|
||||
success: false,
|
||||
message: error.message || "사원 저장 중 오류가 발생했습니다.",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 사원 + 부서 정보 조회 (수정 모달용)
|
||||
*
|
||||
* user_info와 user_dept 정보를 함께 조회합니다.
|
||||
*
|
||||
* @param userId 조회할 사용자 ID
|
||||
* @returns 사원 정보 및 부서 관계 정보
|
||||
*/
|
||||
export async function getUserWithDept(userId: string): Promise<ApiResponse<UserWithDeptResponse>> {
|
||||
try {
|
||||
console.log("사원+부서 조회 API 호출:", userId);
|
||||
|
||||
const response = await apiClient.get(`/admin/users/${userId}/with-dept`);
|
||||
|
||||
console.log("사원+부서 조회 API 응답:", response.data);
|
||||
return response.data;
|
||||
} catch (error: any) {
|
||||
console.error("사원+부서 조회 API 오류:", error);
|
||||
|
||||
if (error.response?.data) {
|
||||
return error.response.data;
|
||||
}
|
||||
|
||||
return {
|
||||
success: false,
|
||||
message: error.message || "사원 조회 중 오류가 발생했습니다.",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// 사용자 API 객체로 export
|
||||
export const userAPI = {
|
||||
getList: getUserList,
|
||||
@@ -195,4 +316,7 @@ export const userAPI = {
|
||||
getCompanyList: getCompanyList,
|
||||
getDepartmentList: getDepartmentList,
|
||||
checkDuplicateId: checkDuplicateUserId,
|
||||
// 사원 + 부서 통합 관리
|
||||
saveWithDept: saveUserWithDept,
|
||||
getWithDept: getUserWithDept,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user