148 lines
3.7 KiB
TypeScript
148 lines
3.7 KiB
TypeScript
import request from '@/utils/request'
|
||
import type { ApiResult } from '@/api/auth'
|
||
|
||
/** 行业树节点(二级) */
|
||
export interface IndustryChild {
|
||
id: string
|
||
name: string
|
||
level: number
|
||
}
|
||
|
||
/** 行业树节点(一级,含子节点) */
|
||
export interface IndustryItem {
|
||
id: string
|
||
name: string
|
||
level: number
|
||
children: IndustryChild[]
|
||
}
|
||
|
||
/**
|
||
* 获取行业树分类数据
|
||
* GET /public/industries/tree
|
||
* 返回一级二级嵌套的行业分类
|
||
*/
|
||
export function fetchIndustryTree(params?: { includeEmpty?: boolean }) {
|
||
return request.get<any, ApiResult<IndustryItem[]>>('/public/industries/tree', { params })
|
||
}
|
||
|
||
// ==================== 岗位分类相关 ====================
|
||
|
||
/** 岗位树节点(三级 / 末级) */
|
||
export interface JobCategoryLeaf {
|
||
id: string
|
||
name: string
|
||
level: number
|
||
}
|
||
|
||
/** 岗位树节点(二级,含三级子节点) */
|
||
export interface JobCategoryChild {
|
||
id: string
|
||
name: string
|
||
level: number
|
||
children: JobCategoryLeaf[]
|
||
}
|
||
|
||
/** 岗位树节点(一级,含二级子节点) */
|
||
export interface JobCategoryItem {
|
||
id: string
|
||
name: string
|
||
level: number
|
||
children: JobCategoryChild[]
|
||
}
|
||
|
||
/**
|
||
* 获取岗位树分类数据
|
||
* GET /public/job-categories/tree
|
||
* 返回一级二级三级嵌套的岗位分类
|
||
*/
|
||
export function fetchJobCategoryTree(params?: { includeEmpty?: boolean }) {
|
||
return request.get<any, ApiResult<JobCategoryItem[]>>('/public/job-categories/tree', { params })
|
||
}
|
||
|
||
// ==================== 地区分类相关 ====================
|
||
|
||
/** 地区树节点(三级 / 区县级) */
|
||
export interface RegionLeaf {
|
||
code: string
|
||
name: string
|
||
}
|
||
|
||
/** 地区树节点(二级 / 市级,可能含三级子节点) */
|
||
export interface RegionChild {
|
||
code: string
|
||
name: string
|
||
children?: RegionLeaf[]
|
||
}
|
||
|
||
/** 地区树节点(一级 / 省级,含二级子节点) */
|
||
export interface RegionItem {
|
||
code: string
|
||
name: string
|
||
children: RegionChild[]
|
||
}
|
||
|
||
/**
|
||
* 获取地区树分类数据
|
||
* GET /public/regions/tree
|
||
* 返回省市区三级嵌套的地区分类
|
||
*/
|
||
export function fetchRegionTree() {
|
||
return request.get<any, ApiResult<RegionItem[]>>('/public/regions/tree')
|
||
}
|
||
|
||
// ==================== OSS 文件上传相关 ====================
|
||
|
||
/** 文件上传路径枚举 */
|
||
export type OssPathEnum = 'UserImage' | 'ResumeImage' | 'SystemImage' | 'ResumeFile' | 'OtherFile'
|
||
|
||
/** 文件上传返回结果 */
|
||
export interface OssUploadResult {
|
||
/** 上传地址 */
|
||
uploadUrl?: string
|
||
/** 下载地址 */
|
||
downloadUrl?: string
|
||
}
|
||
|
||
/**
|
||
* 上传文件到OSS
|
||
* POST /oss/simpleUpload
|
||
* @param file 要上传的文件
|
||
* @param pathEnum 路径枚举,默认 ResumeFile
|
||
* @returns 上传结果(含下载地址)
|
||
*/
|
||
export function uploadFileToOss(file: File, pathEnum: OssPathEnum = 'ResumeFile') {
|
||
const formData = new FormData()
|
||
formData.append('file', file)
|
||
return request.post<any, ApiResult<OssUploadResult>>('/oss/simpleUpload', formData, {
|
||
params: { pathEnum },
|
||
headers: { 'Content-Type': 'multipart/form-data' },
|
||
})
|
||
}
|
||
|
||
// ==================== 协议查询相关 ====================
|
||
|
||
/** 协议数据结构 */
|
||
export interface AgreementDto {
|
||
/** 协议表ID */
|
||
id?: number
|
||
/** 协议码,唯一标识一类协议 */
|
||
agreementCode?: string
|
||
/** 修改版本 */
|
||
version?: number
|
||
/** 协议名称 */
|
||
agreementName?: string
|
||
/** 协议内容(富文本/Markdown) */
|
||
content?: string
|
||
/** 状态 1=启用 0=禁用 */
|
||
status?: number
|
||
}
|
||
|
||
/**
|
||
* 根据协议码查询协议内容
|
||
* GET /public/agreement?code=xxx
|
||
* @param code 协议码
|
||
*/
|
||
export function fetchAgreement(code: string) {
|
||
return request.get<any, ApiResult<AgreementDto>>('/public/agreement', { params: { code } })
|
||
}
|