Files
shz-admin/src/services/jobportal/outdoorFair.ts

404 lines
11 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';
import type { VenueBoothItem } from './venueInfo';
import { downLoadXlsx } from '@/utils/downloadfile';
import type { RecruitmentFairExportParams } from '@/services/jobfair/recruitmentFairExport';
/** 户外招聘会列表项 */
export interface OutdoorFairItem {
id: number;
/** 招聘会标题 */
title: string;
/** 举办单位 */
hostUnit: string;
/** 招聘会类型 */
fairType: string;
/** 举办区域 */
region: string;
/** 绑定场地ID */
venueId?: number;
/** 绑定场地 */
venueName?: string;
/** 举办地址 */
address: string;
/** 展位数量 */
boothCount: number;
/** 已预定摊位数 */
reservedBoothCount?: number;
/** 招聘会实际展位图中的展位数量 */
boothMapCount?: number;
/** 举办时间 */
holdTime: string;
/** 招聘会结束时间 */
endTime: string;
/** 报名开始时间 */
applyStartTime: string;
/** 报名截止时间 */
applyEndTime: string;
/** 是否开启线上申请 */
onlineApply: boolean;
/** 招聘会照片 */
photoUrl: string;
/** 招聘会简介 */
fairIntroduction?: string;
/** 招聘会整体流程 */
fairProcess?: string;
/** 企业参加招聘会需携带的资料 */
requiredMaterials?: string;
/** 企业到场须知 */
attendanceNotes?: string;
/** 当前企业ID */
companyId?: number;
/** 当前企业名称 */
companyName?: string;
/** 当前企业是否已报名 */
signedUp?: boolean;
/** 当前企业公共 H5 页面链接 */
h5Url?: string;
/** 二维码内容,通常与 h5Url 一致 */
qrCodeContent?: string;
/** 当前企业报名审核状态0待审核 1通过 2驳回 */
reviewStatus?: string;
/** 当前企业报名审核备注 */
reviewRemark?: string;
/** 当前企业签到状态not_checked_in/checked_in */
companyCheckInStatus?: 'not_checked_in' | 'checked_in';
/** 当前企业签到时间 */
companyCheckInTime?: string;
/** 当前企业当前是否允许签到 */
companyCheckInAllowed?: boolean;
createTime?: string;
updateTime?: string;
}
/** 户外招聘会查询参数 */
export interface OutdoorFairListParams {
title?: string;
hostUnit?: string;
fairType?: string;
region?: string;
venueId?: number;
onlineApply?: boolean;
/** 举办开始时间下限 */
startTime?: string;
/** 举办结束时间上限 */
endTime?: string;
/** 报名开始时间下限 */
applyStartTime?: string;
/** 报名截止时间上限 */
applyEndTime?: string;
current?: number;
pageSize?: number;
}
/** 户外招聘会列表响应 */
export interface OutdoorFairListResult {
code: number;
msg?: string;
total: number;
rows: OutdoorFairItem[];
}
/** 户外招聘会新增/编辑表单 */
export interface OutdoorFairForm {
id?: number;
title: string;
hostUnit: string;
fairType: string;
region: string;
venueId?: number;
venueName?: string;
address: string;
boothCount: number;
holdTime: string;
endTime: string;
applyStartTime: string;
applyEndTime: string;
onlineApply: boolean;
photoUrl: string;
/** 招聘会简介 */
fairIntroduction?: string;
/** 招聘会整体流程 */
fairProcess?: string;
/** 企业参加招聘会需携带的资料 */
requiredMaterials?: string;
/** 企业到场须知 */
attendanceNotes?: string;
/** 更换场地时确认清空旧展位图与预定,并按新模板重建 */
resetBoothMap?: boolean;
}
/** 通用响应 */
export interface OutdoorFairCommonResult {
code: number;
msg?: string;
data?: any;
url?: string;
fileName?: string;
newFileName?: string;
originalFilename?: string;
}
/** 企业报名/二维码信息 */
export interface OutdoorFairCompanyQrCodeInfo {
fairId: number;
companyId: number;
companyName?: string;
signedUp?: boolean;
reviewStatus?: string;
reviewRemark?: string;
deviceId?: number;
deviceCode?: string;
h5Url: string;
qrCodeContent: string;
}
/** 管理端查看的招聘会微信小程序码。 */
export interface OutdoorFairMiniProgramQrCodeInfo {
fairId: number;
page: string;
scene: string;
/** 小程序目标版本:当前尚未正式发布,默认为体验版 trial。 */
envVersion: 'trial' | 'release' | 'develop';
imageData: string;
/** getUnlimitedQRCode 生成的小程序码长期有效。 */
permanent: boolean;
/** 小程序码本身是否需要周期轮换。 */
rotationRequired: boolean;
}
/** 企业审核通过后可读取的只读展位图。 */
export interface OutdoorFairCompanyBoothMap {
currentCompanyId: number;
booths: VenueBoothItem[];
}
/** 户外招聘会字典新增表单 */
export interface OutdoorFairDictForm {
dictType: 'outdoor_fair_type' | 'outdoor_fair_region';
dictLabel: string;
}
const CMS_OUTDOOR_FAIR_BASE = '/api/cms/outdoor-fair';
const formatDateTime = (value: any) => {
if (value && typeof value.format === 'function') {
return value.format('YYYY-MM-DD HH:mm:ss');
}
return value;
};
const toApiPayload = (data: OutdoorFairForm) => ({
...data,
holdTime: formatDateTime(data.holdTime),
endTime: formatDateTime(data.endTime),
applyStartTime: formatDateTime(data.applyStartTime),
applyEndTime: formatDateTime(data.applyEndTime),
});
/**
* 获取户外招聘会管理列表
* GET /api/cms/outdoor-fair/list
*/
export async function getOutdoorFairList(params?: OutdoorFairListParams) {
return request<OutdoorFairListResult>(`${CMS_OUTDOOR_FAIR_BASE}/list`, {
method: 'GET',
params,
});
}
/** 导出户外招聘会参会企业/岗位。 */
export async function exportOutdoorFair(params: RecruitmentFairExportParams) {
return downLoadXlsx(
`${CMS_OUTDOOR_FAIR_BASE}/export`,
{ params },
`outdoor_fair_participants_${new Date().getTime()}.xlsx`,
);
}
/**
* 获取户外招聘会详情
* GET /api/cms/outdoor-fair/{id}
*/
export async function getOutdoorFairInfo(id: number) {
return request<OutdoorFairCommonResult>(`${CMS_OUTDOOR_FAIR_BASE}/${id}`, {
method: 'GET',
});
}
/**
* 当前企业查看户外招聘会展位图。
* 服务端会校验当前企业已报名且审核通过,接口只提供读取能力。
*/
export async function getCurrentCompanyOutdoorFairBoothMap(fairId: number) {
return request<{ code: number; msg?: string; data?: OutdoorFairCompanyBoothMap }>(
`${CMS_OUTDOOR_FAIR_BASE}/${fairId}/company/booth-map`,
{ method: 'GET' },
);
}
/** 招聘会统计-时间桶序列项(曲线图用) */
export interface OutdoorFairStatisticsSeriesItem {
time: string;
fairCount: number;
companyCount: number;
jobCount: number;
}
/** 招聘会数同比/环比 */
export interface OutdoorFairStatisticsRate {
fairCount: number;
previousFairCount: number;
/** 增长率:(current-previous)/previous上期为 0 时为 null */
rate?: number | null;
}
/** 招聘会统计结果dashboard */
export interface OutdoorFairStatisticsResult {
granularity: 'day' | 'week' | 'month' | 'year';
totals: { fairCount: number; companyCount: number; jobCount: number };
yoy: OutdoorFairStatisticsRate;
mom: OutdoorFairStatisticsRate;
series: OutdoorFairStatisticsSeriesItem[];
}
/** 招聘会统计查询参数 */
export interface OutdoorFairStatisticsParams {
/** 粒度day/week/month/year */
granularity?: 'day' | 'week' | 'month' | 'year';
/** 起始时间 yyyy-MM-dd HH:mm:ss */
startTime?: string;
/** 截止时间 yyyy-MM-dd HH:mm:ss */
endTime?: string;
}
/**
* 招聘会数据统计
* GET /api/cms/outdoor-fair/statistics
* skipErrorHandler: 由调用方自行处理错误,避免全局弹窗把 null msg 显示成 "null"
*/
export async function getOutdoorFairStatistics(params: OutdoorFairStatisticsParams) {
return request<{ code: number; msg?: string; data: OutdoorFairStatisticsResult }>(
`${CMS_OUTDOOR_FAIR_BASE}/statistics`,
{ method: 'GET', params, skipErrorHandler: true },
);
}
/**
* 新增户外招聘会
* POST /api/cms/outdoor-fair
*/
export async function addOutdoorFair(data: OutdoorFairForm) {
return request<OutdoorFairCommonResult>(CMS_OUTDOOR_FAIR_BASE, {
method: 'POST',
data: toApiPayload(data),
});
}
/**
* 修改户外招聘会
* PUT /api/cms/outdoor-fair
*/
export async function updateOutdoorFair(data: OutdoorFairForm) {
return request<OutdoorFairCommonResult>(CMS_OUTDOOR_FAIR_BASE, {
method: 'PUT',
data: toApiPayload(data),
});
}
/**
* 删除户外招聘会
* DELETE /api/cms/outdoor-fair/{id}
*/
export async function deleteOutdoorFair(id: number) {
return request<OutdoorFairCommonResult>(`${CMS_OUTDOOR_FAIR_BASE}/${id}`, {
method: 'DELETE',
});
}
/**
* 新增户外招聘会页面使用的字典项
* POST /api/cms/outdoor-fair/dict-data
*/
export async function addOutdoorFairDictOption(data: OutdoorFairDictForm) {
return request<OutdoorFairCommonResult>(`${CMS_OUTDOOR_FAIR_BASE}/dict-data`, {
method: 'POST',
data,
});
}
/**
* 当前企业报名户外招聘会
* POST /api/cms/outdoor-fair/{fairId}/company/signup
*/
export async function signupOutdoorFair(fairId: number) {
return request<{ code: number; msg?: string; data: OutdoorFairCompanyQrCodeInfo }>(
`${CMS_OUTDOOR_FAIR_BASE}/${fairId}/company/signup`,
{ method: 'POST' },
);
}
/** 当前企业退订已审核通过的户外招聘会。 */
export async function unsubscribeOutdoorFair(fairId: number, reason: string) {
return request<{ code: number; msg?: string }>(
`${CMS_OUTDOOR_FAIR_BASE}/${fairId}/company/unsubscribe`,
{
method: 'POST',
data: { reason },
},
);
}
/**
* 获取当前企业户外招聘会二维码
* GET /api/cms/outdoor-fair/{fairId}/company/qrcode
*/
export async function getMyOutdoorFairQrCode(fairId: number) {
return request<{ code: number; msg?: string; data: OutdoorFairCompanyQrCodeInfo }>(
`${CMS_OUTDOOR_FAIR_BASE}/${fairId}/company/qrcode`,
{ method: 'GET' },
);
}
/**
* 当前企业在招聘会举办期间签到
* POST /api/cms/outdoor-fair/{fairId}/company/check-in
*/
export async function checkInOutdoorFair(fairId: number) {
return request<{
code: number;
msg?: string;
data?: {
fairId: number;
companyId: number;
checkInTime: string;
attendanceStatus: 'checked_in';
};
}>(`${CMS_OUTDOOR_FAIR_BASE}/${fairId}/company/check-in`, {
method: 'POST',
});
}
/**
* 管理员获取招聘会微信小程序码
* GET /api/cms/outdoor-fair/{fairId}/mini-program-qrcode
*/
export async function getOutdoorFairMiniProgramQrCode(fairId: number) {
return request<{ code: number; msg?: string; data: OutdoorFairMiniProgramQrCodeInfo }>(
`${CMS_OUTDOOR_FAIR_BASE}/${fairId}/mini-program-qrcode`,
{ method: 'GET' },
);
}
/**
* 上传户外招聘会照片
* POST /api/common/upload
*/
export async function uploadOutdoorFairPhoto(file: File) {
const formData = new FormData();
formData.append('file', file);
return request<OutdoorFairCommonResult>('/api/common/upload', {
method: 'POST',
data: formData,
});
}