feat: Enhance API path handling and normalize company industry names

This commit is contained in:
2026-07-03 13:19:47 +08:00
parent 0024f81484
commit 23b60904e4
4 changed files with 113 additions and 10 deletions

View File

@@ -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 @@
'</section>' +
'<div class="actions">' +
'<button type="button" class="btn checkin" id="checkinBtn">签到</button>' +
'<a class="btn" href="' + escapeHtml(data.fairH5Url) + '">查看招聘会</a>' +
'<a class="btn" href="' + escapeHtml(apiBase() + '/h5/outdoor-fair/detail.html?fairId=' + pageFairId) + '">查看招聘会</a>' +
'</div>' +
'<section class="section">' +
'<h2>企业信息</h2>' +
@@ -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() })

View File

@@ -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 = '<div class="error">缺少招聘会参数</div>';
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) {

View File

@@ -43,6 +43,57 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectCompanyVo">
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
</sql>
<sql id="companyIndustryFilter">
<if test="industry != null and industry != ''">
<choose>
<when test="industry == '食品产业' or industry == '食品加工'">
and (
industry in ('食品加工', '食品产业', '绿色有机食品', '食品/饮料/酒水')
or industry like '%食品%'
or industry like '%饮料%'
or industry like '%酒%'
)
</when>
<when test="industry == '纺织服装'">
and (
industry = '纺织服装'
or industry like '%纺织%'
or industry like '%服装%'
)
</when>
<when test="industry == '装备制造'">
and (
industry = '装备制造'
or industry like '%装备%'
or industry like '%制造%'
or industry like '%机械%'
or industry like '%设备%'
)
</when>
<when test="industry == '其他'">
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 '%设备%'
)
)
</when>
<otherwise>
and industry = #{industry}
</otherwise>
</choose>
</if>
</sql>
<insert id="batchInsert" parameterType="java.util.List">
INSERT INTO company (
name, location, industry, scale, code, description, nature,
@@ -70,7 +121,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where> del_flag = '0'
<if test="name != null and name != ''"> and name like concat('%', cast(#{name, jdbcType=VARCHAR} as varchar), '%')</if>
<if test="location != null and location != ''"> and location = #{location}</if>
<if test="industry != null and industry != ''"> and industry = #{industry}</if>
<include refid="companyIndustryFilter"/>
<if test="scale != null and scale != ''"> and scale = #{scale}</if>
<if test="nature != null and nature != ''"> and nature = #{nature}</if>
<if test="code != null and code != ''"> and code = #{code}</if>
@@ -102,7 +153,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where> del_flag = '0'
<if test="name != null and name != ''"> and name like concat('%', cast(#{name, jdbcType=VARCHAR} as varchar), '%')</if>
<if test="location != null and location != ''"> and location = #{location}</if>
<if test="industry != null and industry != ''"> and industry = #{industry}</if>
<include refid="companyIndustryFilter"/>
<if test="scale != null and scale != ''"> and scale = #{scale}</if>
<if test="nature != null and nature != ''"> and nature = #{nature}</if>
<if test="code != null and code != ''"> and code = #{code}</if>
@@ -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
</select>
</mapper>
</mapper>

View File

@@ -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 '%设备%'
);