ваше сообщение коммита

This commit is contained in:
2025-07-18 12:42:37 +03:00
parent 1588e879ed
commit ed5c0d53fb
2 changed files with 8 additions and 45 deletions

View File

@@ -2,8 +2,6 @@ const express = require('express');
const router = express.Router();
const db = require('../db');
const logger = require('../utils/logger'); // Если используете логгер
const fs = require('fs');
const csv = require('csv-parser');
/**
* @swagger
@@ -76,47 +74,8 @@ router.get('/codes', async (req, res) => {
const offset = (page - 1) * limit;
const { lang } = req.query;
// Если запрошен русский язык — отдаём из CSV
if (lang === 'ru') {
const { level, parent_code } = req.query;
const results = [];
fs.createReadStream(__dirname + '/../db/data/isic_titles_ru.csv')
.pipe(csv())
.on('data', (data) => {
let pass = true;
// Фильтрация по уровню (по длине кода)
if (level) {
if (level == 1 && data.code.length !== 1) pass = false;
if (level == 2 && data.code.length !== 2) pass = false;
if (level == 3 && data.code.length !== 3) pass = false;
if (level == 4 && data.code.length !== 4) pass = false;
}
// Фильтрация по parent_code
if (parent_code && pass) {
if (level == 2 && !data.code.startsWith(parent_code)) pass = false;
if (level == 3 && !data.code.startsWith(parent_code)) pass = false;
if (level == 4 && !data.code.startsWith(parent_code)) pass = false;
}
if (pass) {
results.push({
code: data.code,
description: data.title,
});
}
})
.on('end', () => {
res.json({
totalItems: results.length,
codes: results,
totalPages: 1,
currentPage: 1,
});
})
.on('error', (err) => {
res.status(500).json({ error: 'Ошибка чтения русских кодов ISIC', details: err.message });
});
return;
}
// Убираем русский вариант и всегда используем базу данных PostgreSQL
// if (lang === 'ru') { ... } - удалено
const baseQuerySelect = `
SELECT c.code, c.description, c.code_level, c.explanatory_note_inclusion, c.explanatory_note_exclusion,

View File

@@ -452,7 +452,7 @@ const fetchIsicCodes = async (params = {}, optionsRef, loadingRef) => {
loadingRef.value = true;
optionsRef.value = []; // Очищаем перед загрузкой
try {
const queryParams = new URLSearchParams({ ...params, lang: 'ru' }).toString();
const queryParams = new URLSearchParams(params).toString();
console.debug(`[BlockchainSettingsView] Fetching ISIC codes with params: ${queryParams}`);
// Убедитесь, что базовый URL настроен правильно (например, через axios interceptors или .env)
@@ -464,7 +464,8 @@ const fetchIsicCodes = async (params = {}, optionsRef, loadingRef) => {
// Отображаем код и описание для ясности
text: `${code.code} - ${code.description}`
}));
console.debug(`[BlockchainSettingsView] Loaded ISIC codes for level ${params.level || ('parent: '+params.parent_code)}, count:`, optionsRef.value.length);
console.log(`[BlockchainSettingsView] Loaded ISIC codes for level ${params.level || ('parent: '+params.parent_code)}, count:`, optionsRef.value.length);
console.log('[BlockchainSettingsView] Response data:', response.data);
} else {
console.error('[BlockchainSettingsView] Invalid response structure for ISIC codes:', response.data);
}
@@ -513,6 +514,7 @@ const updateCurrentIsicSelection = () => {
// --- Наблюдатели для каскадной загрузки и обновления текущего выбора ---
watch(selectedSection, (newVal) => {
console.log('[BlockchainSettingsView] selectedSection changed to:', newVal);
selectedDivision.value = ''; divisionOptions.value = [];
selectedGroup.value = ''; groupOptions.value = [];
selectedClass.value = ''; classOptions.value = [];
@@ -523,6 +525,7 @@ watch(selectedSection, (newVal) => {
});
watch(selectedDivision, (newVal) => {
console.log('[BlockchainSettingsView] selectedDivision changed to:', newVal);
selectedGroup.value = ''; groupOptions.value = [];
selectedClass.value = ''; classOptions.value = [];
if (newVal) {
@@ -532,6 +535,7 @@ watch(selectedDivision, (newVal) => {
});
watch(selectedGroup, (newVal) => {
console.log('[BlockchainSettingsView] selectedGroup changed to:', newVal);
selectedClass.value = ''; classOptions.value = [];
if (newVal) {
fetchIsicCodes({ parent_code: newVal }, classOptions, isLoadingClasses);