feat: add job fair region type functionality and improve job fair detail pages
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
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
- Introduced job fair region type selection in EditModal and PublicJobFairList components. - Enhanced JobFairDetail page to display job fair region type using DictTag. - Updated API types to include jobFairRegionType for better data handling. - Created new JobPortal pages for displaying job fair details with improved styling. - Added CSS styles for job fair detail and list pages to enhance user experience. - Implemented loading states and error handling for job fair data fetching.
This commit is contained in:
174
src/services/jobportal/jobFair.ts
Normal file
174
src/services/jobportal/jobFair.ts
Normal file
@@ -0,0 +1,174 @@
|
||||
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;
|
||||
jobFairPhone?: string;
|
||||
jobFairImage?: string;
|
||||
enterpriseNum?: string;
|
||||
boothNum?: string;
|
||||
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;
|
||||
holdTime?: string;
|
||||
endTime?: string;
|
||||
photoUrl?: 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;
|
||||
}
|
||||
|
||||
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,
|
||||
jobFairPhone: fair.jobFairPhone,
|
||||
jobFairImage: fair.jobFairImage || fair.photoUrl,
|
||||
boothNum:
|
||||
fair.boothNum || (fair.boothCount === undefined ? undefined : String(fair.boothCount)),
|
||||
jobFairRegion: fair.jobFairRegion || fair.region,
|
||||
jobFairVenueName: fair.jobFairVenueName || fair.venueName,
|
||||
},
|
||||
} as PortalJobFairDetailResult;
|
||||
}
|
||||
Reference in New Issue
Block a user