Merge branch 'main' into feature/screen-management
This commit is contained in:
@@ -342,4 +342,130 @@ export class AuthService {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 공차중계 회원가입 처리
|
||||
* - user_info 테이블에 사용자 정보 저장
|
||||
* - vehicles 테이블에 차량 정보 저장
|
||||
*/
|
||||
static async signupDriver(data: {
|
||||
userId: string;
|
||||
password: string;
|
||||
userName: string;
|
||||
phoneNumber: string;
|
||||
licenseNumber: string;
|
||||
vehicleNumber: string;
|
||||
vehicleType?: string;
|
||||
}): Promise<{ success: boolean; message?: string }> {
|
||||
try {
|
||||
const {
|
||||
userId,
|
||||
password,
|
||||
userName,
|
||||
phoneNumber,
|
||||
licenseNumber,
|
||||
vehicleNumber,
|
||||
vehicleType,
|
||||
} = data;
|
||||
|
||||
// 1. 중복 사용자 확인
|
||||
const existingUser = await query<any>(
|
||||
`SELECT user_id FROM user_info WHERE user_id = $1`,
|
||||
[userId]
|
||||
);
|
||||
|
||||
if (existingUser.length > 0) {
|
||||
return {
|
||||
success: false,
|
||||
message: "이미 존재하는 아이디입니다.",
|
||||
};
|
||||
}
|
||||
|
||||
// 2. 중복 차량번호 확인
|
||||
const existingVehicle = await query<any>(
|
||||
`SELECT vehicle_number FROM vehicles WHERE vehicle_number = $1`,
|
||||
[vehicleNumber]
|
||||
);
|
||||
|
||||
if (existingVehicle.length > 0) {
|
||||
return {
|
||||
success: false,
|
||||
message: "이미 등록된 차량번호입니다.",
|
||||
};
|
||||
}
|
||||
|
||||
// 3. 비밀번호 암호화 (MD5 - 기존 시스템 호환)
|
||||
const crypto = require("crypto");
|
||||
const hashedPassword = crypto
|
||||
.createHash("md5")
|
||||
.update(password)
|
||||
.digest("hex");
|
||||
|
||||
// 4. 사용자 정보 저장 (user_info)
|
||||
await query(
|
||||
`INSERT INTO user_info (
|
||||
user_id,
|
||||
user_password,
|
||||
user_name,
|
||||
cell_phone,
|
||||
license_number,
|
||||
vehicle_number,
|
||||
company_code,
|
||||
user_type,
|
||||
signup_type,
|
||||
status,
|
||||
regdate
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, NOW())`,
|
||||
[
|
||||
userId,
|
||||
hashedPassword,
|
||||
userName,
|
||||
phoneNumber,
|
||||
licenseNumber,
|
||||
vehicleNumber,
|
||||
"COMPANY_13", // 기본 회사 코드
|
||||
null, // user_type: null
|
||||
"DRIVER", // signup_type: 공차중계 회원가입 사용자
|
||||
"active", // status: active
|
||||
]
|
||||
);
|
||||
|
||||
// 5. 차량 정보 저장 (vehicles)
|
||||
await query(
|
||||
`INSERT INTO vehicles (
|
||||
vehicle_number,
|
||||
vehicle_type,
|
||||
driver_name,
|
||||
driver_phone,
|
||||
status,
|
||||
company_code,
|
||||
user_id,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, NOW(), NOW())`,
|
||||
[
|
||||
vehicleNumber,
|
||||
vehicleType || null,
|
||||
userName,
|
||||
phoneNumber,
|
||||
"off", // 초기 상태: off (대기)
|
||||
"COMPANY_13", // 기본 회사 코드
|
||||
userId, // 사용자 ID 연결
|
||||
]
|
||||
);
|
||||
|
||||
logger.info(`공차중계 회원가입 성공: ${userId}, 차량번호: ${vehicleNumber}`);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "회원가입이 완료되었습니다.",
|
||||
};
|
||||
} catch (error: any) {
|
||||
logger.error("공차중계 회원가입 오류:", error);
|
||||
return {
|
||||
success: false,
|
||||
message: error.message || "회원가입 중 오류가 발생했습니다.",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,39 +28,39 @@ export class ExternalDbConnectionService {
|
||||
|
||||
// 회사별 필터링 (최고 관리자가 아닌 경우 필수)
|
||||
if (userCompanyCode && userCompanyCode !== "*") {
|
||||
whereConditions.push(`company_code = $${paramIndex++}`);
|
||||
whereConditions.push(`e.company_code = $${paramIndex++}`);
|
||||
params.push(userCompanyCode);
|
||||
logger.info(`회사별 외부 DB 연결 필터링: ${userCompanyCode}`);
|
||||
} else if (userCompanyCode === "*") {
|
||||
logger.info(`최고 관리자: 모든 외부 DB 연결 조회`);
|
||||
// 필터가 있으면 적용
|
||||
if (filter.company_code) {
|
||||
whereConditions.push(`company_code = $${paramIndex++}`);
|
||||
whereConditions.push(`e.company_code = $${paramIndex++}`);
|
||||
params.push(filter.company_code);
|
||||
}
|
||||
} else {
|
||||
// userCompanyCode가 없는 경우 (하위 호환성)
|
||||
if (filter.company_code) {
|
||||
whereConditions.push(`company_code = $${paramIndex++}`);
|
||||
whereConditions.push(`e.company_code = $${paramIndex++}`);
|
||||
params.push(filter.company_code);
|
||||
}
|
||||
}
|
||||
|
||||
// 필터 조건 적용
|
||||
if (filter.db_type) {
|
||||
whereConditions.push(`db_type = $${paramIndex++}`);
|
||||
whereConditions.push(`e.db_type = $${paramIndex++}`);
|
||||
params.push(filter.db_type);
|
||||
}
|
||||
|
||||
if (filter.is_active) {
|
||||
whereConditions.push(`is_active = $${paramIndex++}`);
|
||||
whereConditions.push(`e.is_active = $${paramIndex++}`);
|
||||
params.push(filter.is_active);
|
||||
}
|
||||
|
||||
// 검색 조건 적용 (연결명 또는 설명에서 검색)
|
||||
if (filter.search && filter.search.trim()) {
|
||||
whereConditions.push(
|
||||
`(connection_name ILIKE $${paramIndex} OR description ILIKE $${paramIndex})`
|
||||
`(e.connection_name ILIKE $${paramIndex} OR e.description ILIKE $${paramIndex})`
|
||||
);
|
||||
params.push(`%${filter.search.trim()}%`);
|
||||
paramIndex++;
|
||||
@@ -72,9 +72,12 @@ export class ExternalDbConnectionService {
|
||||
: "";
|
||||
|
||||
const connections = await query<any>(
|
||||
`SELECT * FROM external_db_connections
|
||||
`SELECT e.*,
|
||||
COALESCE(c.company_name, CASE WHEN e.company_code = '*' THEN '전체' ELSE e.company_code END) AS company_name
|
||||
FROM external_db_connections e
|
||||
LEFT JOIN company_mng c ON e.company_code = c.company_code
|
||||
${whereClause}
|
||||
ORDER BY is_active DESC, connection_name ASC`,
|
||||
ORDER BY e.is_active DESC, e.connection_name ASC`,
|
||||
params
|
||||
);
|
||||
|
||||
|
||||
@@ -31,15 +31,17 @@ export class ExternalRestApiConnectionService {
|
||||
try {
|
||||
let query = `
|
||||
SELECT
|
||||
id, connection_name, description, base_url, endpoint_path, default_headers,
|
||||
default_method,
|
||||
e.id, e.connection_name, e.description, e.base_url, e.endpoint_path, e.default_headers,
|
||||
e.default_method,
|
||||
-- DB 스키마의 컬럼명은 default_request_body 기준이고
|
||||
-- 코드에서는 default_body 필드로 사용하기 위해 alias 처리
|
||||
default_request_body AS default_body,
|
||||
auth_type, auth_config, timeout, retry_count, retry_delay,
|
||||
company_code, is_active, created_date, created_by,
|
||||
updated_date, updated_by, last_test_date, last_test_result, last_test_message
|
||||
FROM external_rest_api_connections
|
||||
e.default_request_body AS default_body,
|
||||
e.auth_type, e.auth_config, e.timeout, e.retry_count, e.retry_delay,
|
||||
e.company_code, e.is_active, e.created_date, e.created_by,
|
||||
e.updated_date, e.updated_by, e.last_test_date, e.last_test_result, e.last_test_message,
|
||||
COALESCE(c.company_name, CASE WHEN e.company_code = '*' THEN '전체' ELSE e.company_code END) AS company_name
|
||||
FROM external_rest_api_connections e
|
||||
LEFT JOIN company_mng c ON e.company_code = c.company_code
|
||||
WHERE 1=1
|
||||
`;
|
||||
|
||||
@@ -48,7 +50,7 @@ export class ExternalRestApiConnectionService {
|
||||
|
||||
// 회사별 필터링 (최고 관리자가 아닌 경우 필수)
|
||||
if (userCompanyCode && userCompanyCode !== "*") {
|
||||
query += ` AND company_code = $${paramIndex}`;
|
||||
query += ` AND e.company_code = $${paramIndex}`;
|
||||
params.push(userCompanyCode);
|
||||
paramIndex++;
|
||||
logger.info(`회사별 REST API 연결 필터링: ${userCompanyCode}`);
|
||||
@@ -56,14 +58,14 @@ export class ExternalRestApiConnectionService {
|
||||
logger.info(`최고 관리자: 모든 REST API 연결 조회`);
|
||||
// 필터가 있으면 적용
|
||||
if (filter.company_code) {
|
||||
query += ` AND company_code = $${paramIndex}`;
|
||||
query += ` AND e.company_code = $${paramIndex}`;
|
||||
params.push(filter.company_code);
|
||||
paramIndex++;
|
||||
}
|
||||
} else {
|
||||
// userCompanyCode가 없는 경우 (하위 호환성)
|
||||
if (filter.company_code) {
|
||||
query += ` AND company_code = $${paramIndex}`;
|
||||
query += ` AND e.company_code = $${paramIndex}`;
|
||||
params.push(filter.company_code);
|
||||
paramIndex++;
|
||||
}
|
||||
@@ -71,14 +73,14 @@ export class ExternalRestApiConnectionService {
|
||||
|
||||
// 활성 상태 필터
|
||||
if (filter.is_active) {
|
||||
query += ` AND is_active = $${paramIndex}`;
|
||||
query += ` AND e.is_active = $${paramIndex}`;
|
||||
params.push(filter.is_active);
|
||||
paramIndex++;
|
||||
}
|
||||
|
||||
// 인증 타입 필터
|
||||
if (filter.auth_type) {
|
||||
query += ` AND auth_type = $${paramIndex}`;
|
||||
query += ` AND e.auth_type = $${paramIndex}`;
|
||||
params.push(filter.auth_type);
|
||||
paramIndex++;
|
||||
}
|
||||
@@ -86,9 +88,9 @@ export class ExternalRestApiConnectionService {
|
||||
// 검색어 필터 (연결명, 설명, URL)
|
||||
if (filter.search) {
|
||||
query += ` AND (
|
||||
connection_name ILIKE $${paramIndex} OR
|
||||
description ILIKE $${paramIndex} OR
|
||||
base_url ILIKE $${paramIndex}
|
||||
e.connection_name ILIKE $${paramIndex} OR
|
||||
e.description ILIKE $${paramIndex} OR
|
||||
e.base_url ILIKE $${paramIndex}
|
||||
)`;
|
||||
params.push(`%${filter.search}%`);
|
||||
paramIndex++;
|
||||
@@ -233,6 +235,7 @@ export class ExternalRestApiConnectionService {
|
||||
// 디버깅: 저장하려는 데이터 로깅
|
||||
logger.info(`REST API 연결 생성 요청 데이터:`, {
|
||||
connection_name: data.connection_name,
|
||||
company_code: data.company_code,
|
||||
default_method: data.default_method,
|
||||
endpoint_path: data.endpoint_path,
|
||||
base_url: data.base_url,
|
||||
|
||||
Reference in New Issue
Block a user