restapi 도 경로보기 가능, 출발지목적지 동시에 같은거 못하게, 자물쇠걸면 컬럼 수정 못함 tablelistcomponent

This commit is contained in:
leeheejin
2025-12-08 10:23:54 +09:00
parent 7a596cad3d
commit 8ec5c987de
11 changed files with 485 additions and 14 deletions

View File

@@ -632,6 +632,9 @@ export class DashboardController {
validateStatus: () => true, // 모든 상태 코드 허용 (에러도 응답으로 처리)
};
// 연결 정보 (응답에 포함용)
let connectionInfo: { saveToHistory?: boolean } | null = null;
// 외부 커넥션 ID가 있는 경우, 해당 커넥션의 인증 정보(DB 토큰 등)를 적용
if (externalConnectionId) {
try {
@@ -652,6 +655,11 @@ export class DashboardController {
if (connectionResult.success && connectionResult.data) {
const connection = connectionResult.data;
// 연결 정보 저장 (응답에 포함)
connectionInfo = {
saveToHistory: connection.save_to_history === "Y",
};
// 인증 헤더 생성 (DB 토큰 등)
const authHeaders =
await ExternalRestApiConnectionService.getAuthHeaders(
@@ -753,6 +761,7 @@ export class DashboardController {
res.status(200).json({
success: true,
data,
connectionInfo, // 외부 연결 정보 (saveToHistory 등)
});
} catch (error: any) {
const status = error.response?.status || 500;

View File

@@ -492,7 +492,7 @@ export const saveLocationHistory = async (
res: Response
): Promise<Response | void> => {
try {
const { companyCode, userId } = req.user as any;
const { companyCode, userId: loginUserId } = req.user as any;
const {
latitude,
longitude,
@@ -508,10 +508,17 @@ export const saveLocationHistory = async (
destinationName,
recordedAt,
vehicleId,
userId: requestUserId, // 프론트엔드에서 보낸 userId (차량 번호판 등)
} = req.body;
// 프론트엔드에서 보낸 userId가 있으면 그것을 사용 (차량 번호판 등)
// 없으면 로그인한 사용자의 userId 사용
const userId = requestUserId || loginUserId;
console.log("📍 [saveLocationHistory] 요청:", {
userId,
requestUserId,
loginUserId,
companyCode,
latitude,
longitude,

View File

@@ -209,8 +209,8 @@ export class ExternalRestApiConnectionService {
connection_name, description, base_url, endpoint_path, default_headers,
default_method, default_request_body,
auth_type, auth_config, timeout, retry_count, retry_delay,
company_code, is_active, created_by
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)
company_code, is_active, created_by, save_to_history
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)
RETURNING *
`;
@@ -230,6 +230,7 @@ export class ExternalRestApiConnectionService {
data.company_code || "*",
data.is_active || "Y",
data.created_by || "system",
data.save_to_history || "N",
];
// 디버깅: 저장하려는 데이터 로깅
@@ -377,6 +378,12 @@ export class ExternalRestApiConnectionService {
paramIndex++;
}
if (data.save_to_history !== undefined) {
updateFields.push(`save_to_history = $${paramIndex}`);
params.push(data.save_to_history);
paramIndex++;
}
if (data.updated_by !== undefined) {
updateFields.push(`updated_by = $${paramIndex}`);
params.push(data.updated_by);

View File

@@ -53,6 +53,9 @@ export interface ExternalRestApiConnection {
retry_delay?: number;
company_code: string;
is_active: string;
// 위치 이력 저장 설정 (지도 위젯용)
save_to_history?: string; // 'Y' 또는 'N' - REST API에서 가져온 위치 데이터를 vehicle_location_history에 저장
created_date?: Date;
created_by?: string;
updated_date?: Date;