Files
shz-admin/src/services/jobportal/jobFair.ts
lapuda bdb1516570
Some checks failed
Node CI / build (14.x, macOS-latest) (push) Has been cancelled
Node CI / build (14.x, ubuntu-latest) (push) Has been cancelled
Node CI / build (14.x, windows-latest) (push) Has been cancelled
Node CI / build (16.x, macOS-latest) (push) Has been cancelled
Node CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Node CI / build (16.x, windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
coverage CI / build (push) Has been cancelled
Node pnpm CI / build (16.x, macOS-latest) (push) Has been cancelled
Node pnpm CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Node pnpm CI / build (16.x, windows-latest) (push) Has been cancelled
feat: add enterprise outdoor fair viewer
2026-07-23 10:52:38 +08:00

241 lines
6.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { request } from '@umijs/max';
export type JobFairChannel = 'online' | 'outdoor';
/** 招聘会公共列表项;线上与户外接口统一为该结构。 */
export interface PortalJobFairItem {
jobFairId: string;
jobFairTitle: string;
jobFairAddress?: string;
/** 线上接口通常为 1/2户外接口固定返回 outdoor。 */
jobFairType?: string;
jobFairStartTime?: string;
jobFairEndTime?: string;
jobFairStatus?: string;
jobFairHostUnit?: string;
jobFairOrganizeUnit?: string;
jobFairIntroduction?: string;
jobFairProcess?: string;
jobFairPhone?: string;
jobFairImage?: string;
enterpriseNum?: string;
boothNum?: string;
/** 户外招聘会展位图中的实际摊位数量 */
boothMapCount?: number;
divisionName?: string;
jobFairCategory?: string;
jobFairRegion?: string;
jobFairVenueName?: string;
}
export interface PortalJobFairPageParams {
pageNum?: number;
pageSize?: number;
jobFairTitle?: string;
/** 招聘会举办日期,格式 yyyy-MM-dd。 */
zphjbsj?: string;
}
export interface PortalJobFairPageData {
total: number;
list: PortalJobFairItem[];
pageNum?: number;
pageSize?: number;
pages?: number;
}
export interface PortalJobFairPageResult {
code: number;
msg?: string;
data?: PortalJobFairPageData;
}
export interface PortalJobFairListResult {
code: number;
msg?: string;
data?: PortalJobFairItem[];
}
export interface PortalJobFairDatesResult {
code: number;
msg?: string;
data?: string[];
}
interface PortalOutdoorFairDetailData extends Partial<PortalJobFairItem> {
id?: number;
title?: string;
hostUnit?: string;
fairType?: string;
region?: string;
venueName?: string;
address?: string;
boothCount?: number;
boothMapCount?: number;
holdTime?: string;
endTime?: string;
photoUrl?: string;
fairIntroduction?: string;
fairProcess?: string;
}
interface PortalOutdoorFairDetailResult {
code: number;
msg?: string;
/**
* 旧接口返回 { fair: {...} },当前公共接口直接返回招聘会对象。
* 两种格式均保留兼容,避免接口升级后户外详情页显示为空。
*/
data?: PortalOutdoorFairDetailData | { fair?: PortalOutdoorFairDetailData };
}
function isOutdoorFairDetailWrapper(
data: NonNullable<PortalOutdoorFairDetailResult['data']>,
): data is { fair?: PortalOutdoorFairDetailData } {
return 'fair' in data;
}
export interface PortalJobFairDetailResult {
code: number;
msg?: string;
data?: PortalJobFairItem;
}
/** 招聘会关联岗位;由公共接口中的企业岗位列表展平得到。 */
export interface PortalJobFairPosition {
jobId?: number | string;
fairRelationId?: string;
jobTitle?: string;
minSalary?: number;
maxSalary?: number;
education?: string;
experience?: string;
companyId?: number | string;
companyName?: string;
jobLocation?: string;
jobAddress?: string;
vacancies?: number | string;
isUrgent?: number;
}
interface PortalJobFairCompanyWithJobs {
companyId?: number | string;
companyName?: string;
jobInfoList?: PortalJobFairPosition[];
}
interface PortalJobFairCompaniesWithJobsResult {
code: number;
msg?: string;
data?: PortalJobFairCompanyWithJobs[];
}
export interface PortalJobFairPositionResult {
code: number;
msg?: string;
data?: PortalJobFairPosition[];
}
const FAIR_API = {
online: '/app/jobfair/public/jobfair',
outdoor: '/app/outdoor-fair',
} as const;
/** 获取线上或户外招聘会分页列表。 */
export async function getPortalJobFairPage(
channel: JobFairChannel,
params?: PortalJobFairPageParams,
) {
return request<PortalJobFairPageResult>(`${FAIR_API[channel]}/page`, {
method: 'GET',
params,
});
}
/** 获取有招聘会的日期,用于与小程序一致的日期筛选提示。 */
export async function getPortalJobFairDates(channel: JobFairChannel) {
return request<PortalJobFairDatesResult>(`${FAIR_API[channel]}/dates`, {
method: 'GET',
});
}
/** 获取当前月招聘会摘要。 */
export async function getPortalCurrentMonthJobFairs(channel: JobFairChannel) {
return request<PortalJobFairListResult>(`${FAIR_API[channel]}/currentMonth`, {
method: 'GET',
});
}
/** 获取当前季度招聘会摘要。 */
export async function getPortalCurrentQuarterJobFairs(channel: JobFairChannel) {
return request<PortalJobFairListResult>(`${FAIR_API[channel]}/currentQuarter`, {
method: 'GET',
});
}
/** 获取招聘会详情,并把户外招聘会详情转换为与列表一致的公共字段。 */
export async function getPortalJobFairDetail(channel: JobFairChannel, jobFairId: string) {
if (channel === 'online') {
return request<PortalJobFairDetailResult>(`${FAIR_API.online}/detail`, {
method: 'GET',
params: { jobFairId },
});
}
const response = await request<PortalOutdoorFairDetailResult>(
`${FAIR_API.outdoor}/${encodeURIComponent(jobFairId)}`,
{ method: 'GET' },
);
const payload = response.data;
const fair = payload && (isOutdoorFairDetailWrapper(payload) ? payload.fair : payload);
if (!fair) {
return { code: response.code, msg: response.msg } as PortalJobFairDetailResult;
}
return {
code: response.code,
msg: response.msg,
data: {
jobFairId: fair.jobFairId || String(fair.id ?? jobFairId),
jobFairTitle: fair.jobFairTitle || fair.title || '线下招聘会',
jobFairAddress: fair.jobFairAddress || fair.address || fair.venueName,
jobFairType: fair.jobFairType || fair.fairType || 'outdoor',
jobFairStartTime: fair.jobFairStartTime || fair.holdTime,
jobFairEndTime: fair.jobFairEndTime || fair.endTime,
jobFairHostUnit: fair.jobFairHostUnit || fair.hostUnit,
jobFairOrganizeUnit: fair.jobFairOrganizeUnit,
jobFairIntroduction: fair.jobFairIntroduction || fair.fairIntroduction,
jobFairProcess: fair.jobFairProcess || fair.fairProcess,
jobFairPhone: fair.jobFairPhone,
jobFairImage: fair.jobFairImage || fair.photoUrl,
boothNum:
fair.boothNum || (fair.boothCount === undefined ? undefined : String(fair.boothCount)),
boothMapCount: fair.boothMapCount,
jobFairRegion: fair.jobFairRegion || fair.region,
jobFairVenueName: fair.jobFairVenueName || fair.venueName,
},
} as PortalJobFairDetailResult;
}
/** 获取线上招聘会的关联岗位,并将企业分组数据转换为岗位卡片数据。 */
export async function getPortalJobFairPositions(jobFairId: string) {
const response = await request<PortalJobFairCompaniesWithJobsResult>(
`${FAIR_API.online}/enterprises-with-jobs-by-job-fair-id`,
{
method: 'GET',
params: { jobFairId },
},
);
return {
code: response.code,
msg: response.msg,
data: (response.data || []).flatMap((company) =>
(company.jobInfoList || []).map((position) => ({
...position,
companyId: position.companyId || company.companyId,
companyName: position.companyName || company.companyName,
})),
),
} as PortalJobFairPositionResult;
}