From 23b60904e4c0e55ec3962bff59f3bce16766db54 Mon Sep 17 00:00:00 2001 From: lapuda <577732344@qq.com> Date: Fri, 3 Jul 2026 13:19:47 +0800 Subject: [PATCH] feat: Enhance API path handling and normalize company industry names --- .../static/h5/outdoor-fair/company.html | 18 ++++-- .../static/h5/outdoor-fair/detail.html | 12 +++- .../resources/mapper/app/CompanyMapper.xml | 57 ++++++++++++++++++- sql/normalize_company_industry.sql | 36 ++++++++++++ 4 files changed, 113 insertions(+), 10 deletions(-) create mode 100644 sql/normalize_company_industry.sql diff --git a/ruoyi-admin/src/main/resources/static/h5/outdoor-fair/company.html b/ruoyi-admin/src/main/resources/static/h5/outdoor-fair/company.html index f95904a..426806f 100644 --- a/ruoyi-admin/src/main/resources/static/h5/outdoor-fair/company.html +++ b/ruoyi-admin/src/main/resources/static/h5/outdoor-fair/company.html @@ -104,11 +104,19 @@ }); } + // 反向代理子路径(如 /api/shihezi)下,依据当前页面路径推导 API 前缀, + // 保证 /app/... 请求带上子路径,避免落到根路径 404。 + function apiBase() { + var path = window.location.pathname; + var idx = path.indexOf('/h5/'); + return idx > 0 ? path.slice(0, idx) : ''; + } + function apiUrl() { if (deviceCode) { - return '/app/outdoor-fair/company-page?deviceCode=' + encodeURIComponent(deviceCode); + return apiBase() + '/app/outdoor-fair/company-page?deviceCode=' + encodeURIComponent(deviceCode); } - return '/app/outdoor-fair/' + encodeURIComponent(fairId) + '/companies/' + encodeURIComponent(companyId) + '/page'; + return apiBase() + '/app/outdoor-fair/' + encodeURIComponent(fairId) + '/companies/' + encodeURIComponent(companyId) + '/page'; } function fetchJson(url) { @@ -118,7 +126,7 @@ } function fetchDict(dictType) { - return fetchJson('/app/common/dict/' + encodeURIComponent(dictType)).then(function (body) { + return fetchJson(apiBase() + '/app/common/dict/' + encodeURIComponent(dictType)).then(function (body) { if (body.code !== 200 || !Array.isArray(body.data)) { return {}; } @@ -157,7 +165,7 @@ '' + '
' + '' + - '查看招聘会' + + '查看招聘会' + '
' + '
' + '

企业信息

' + @@ -245,7 +253,7 @@ if (!pageFairId) { showToast('缺少招聘会信息', true); return; } var submitBtn = document.getElementById('checkinSubmit'); if (submitBtn) submitBtn.disabled = true; - fetch('/app/outdoor-fair/check-in', { + fetch(apiBase() + '/app/outdoor-fair/check-in', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ fairId: Number(pageFairId), name: name.trim(), phone: phone.trim() }) diff --git a/ruoyi-admin/src/main/resources/static/h5/outdoor-fair/detail.html b/ruoyi-admin/src/main/resources/static/h5/outdoor-fair/detail.html index 17b4af7..b0d3c32 100644 --- a/ruoyi-admin/src/main/resources/static/h5/outdoor-fair/detail.html +++ b/ruoyi-admin/src/main/resources/static/h5/outdoor-fair/detail.html @@ -88,6 +88,14 @@ }); } + // 反向代理子路径(如 /api/shihezi)下,依据当前页面路径推导 API 前缀, + // 保证 /app/... 请求带上子路径,避免落到根路径 404。 + function apiBase() { + var path = window.location.pathname; + var idx = path.indexOf('/h5/'); + return idx > 0 ? path.slice(0, idx) : ''; + } + function render(data) { var fair = data.fair || {}; pageFairId = (fair.id !== null && fair.id !== undefined) ? fair.id : fairId; @@ -174,7 +182,7 @@ if (!pageFairId) { showToast('缺少招聘会信息', true); return; } var submitBtn = document.getElementById('checkinSubmit'); if (submitBtn) submitBtn.disabled = true; - fetch('/app/outdoor-fair/check-in', { + fetch(apiBase() + '/app/outdoor-fair/check-in', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ fairId: Number(pageFairId), name: name.trim(), phone: phone.trim() }) @@ -192,7 +200,7 @@ app.innerHTML = '
缺少招聘会参数
'; return; } - fetch('/app/outdoor-fair/' + encodeURIComponent(fairId)).then(function (res) { + fetch(apiBase() + '/app/outdoor-fair/' + encodeURIComponent(fairId)).then(function (res) { return res.json(); }).then(function (body) { if (body.code !== 200) { diff --git a/ruoyi-bussiness/src/main/resources/mapper/app/CompanyMapper.xml b/ruoyi-bussiness/src/main/resources/mapper/app/CompanyMapper.xml index 0d75e65..c047566 100644 --- a/ruoyi-bussiness/src/main/resources/mapper/app/CompanyMapper.xml +++ b/ruoyi-bussiness/src/main/resources/mapper/app/CompanyMapper.xml @@ -43,6 +43,57 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select company_id, name, location, industry, scale, del_flag, create_by, create_time, update_by, update_time, remark,code,description,nature,total_recruitment,registered_address,contact_person,contact_person_phone,is_abnormal,not_pass_reason,status,case when status='2' then update_time else null end reject_time,is_imp_company,imp_company_type,enterprise_type,legal_person,legal_id_card,legal_phone from company + + + + + + and ( + industry in ('食品加工', '食品产业', '绿色有机食品', '食品/饮料/酒水') + or industry like '%食品%' + or industry like '%饮料%' + or industry like '%酒%' + ) + + + and ( + industry = '纺织服装' + or industry like '%纺织%' + or industry like '%服装%' + ) + + + and ( + industry = '装备制造' + or industry like '%装备%' + or industry like '%制造%' + or industry like '%机械%' + or industry like '%设备%' + ) + + + and ( + industry is null + or ( + coalesce(industry, '') not in ('食品加工', '食品产业', '绿色有机食品', '食品/饮料/酒水', '纺织服装', '装备制造') + and coalesce(industry, '') not like '%食品%' + and coalesce(industry, '') not like '%饮料%' + and coalesce(industry, '') not like '%酒%' + and coalesce(industry, '') not like '%纺织%' + and coalesce(industry, '') not like '%服装%' + and coalesce(industry, '') not like '%装备%' + and coalesce(industry, '') not like '%制造%' + and coalesce(industry, '') not like '%机械%' + and coalesce(industry, '') not like '%设备%' + ) + ) + + + and industry = #{industry} + + + + INSERT INTO company ( name, location, industry, scale, code, description, nature, @@ -70,7 +121,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" del_flag = '0' and name like concat('%', cast(#{name, jdbcType=VARCHAR} as varchar), '%') and location = #{location} - and industry = #{industry} + and scale = #{scale} and nature = #{nature} and code = #{code} @@ -102,7 +153,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" del_flag = '0' and name like concat('%', cast(#{name, jdbcType=VARCHAR} as varchar), '%') and location = #{location} - and industry = #{industry} + and scale = #{scale} and nature = #{nature} and code = #{code} @@ -115,4 +166,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select a.* from COMPANY a inner join job b on a.company_id=b.company_id and b.job_id=#{jobId} limit 1 - \ No newline at end of file + diff --git a/sql/normalize_company_industry.sql b/sql/normalize_company_industry.sql new file mode 100644 index 0000000..b45dcdb --- /dev/null +++ b/sql/normalize_company_industry.sql @@ -0,0 +1,36 @@ +-- Normalize company industry names used by the dashboard industry analysis. +-- The backend treats these three names as the canonical categories: +-- 食品加工、纺织服装、装备制造 + +UPDATE company +SET industry = '食品加工' +WHERE del_flag = '0' + AND industry IS NOT NULL + AND ( + industry IN ('食品产业', '食品加工', '绿色有机食品', '食品/饮料/酒水') + OR industry LIKE '%食品%' + OR industry LIKE '%饮料%' + OR industry LIKE '%酒%' + ); + +UPDATE company +SET industry = '纺织服装' +WHERE del_flag = '0' + AND industry IS NOT NULL + AND ( + industry = '纺织服装' + OR industry LIKE '%纺织%' + OR industry LIKE '%服装%' + ); + +UPDATE company +SET industry = '装备制造' +WHERE del_flag = '0' + AND industry IS NOT NULL + AND ( + industry = '装备制造' + OR industry LIKE '%装备%' + OR industry LIKE '%制造%' + OR industry LIKE '%机械%' + OR industry LIKE '%设备%' + );