基于现有架构,创建一套独立的银龄岗(SilverJob)管理系统,包含完整的前后端功能。
采用标准通用CRUD模式实现,使用GenericCrudService和createCrudRoutes快速开发。
文件位置: src/server/modules/silver-jobs/silver-job.entity.ts
// 银龄岗状态枚举
export enum JobStatus {
DRAFT = 0, // 草稿
PUBLISHED = 1, // 已发布
CLOSED = 2, // 已关闭
FILLED = 3 // 已招满
}
// 银龄岗实体类
@Entity('silver_jobs')
export class SilverJob {
@PrimaryGeneratedColumn({ unsigned: true })
id!: number;
@Column({ name: 'title', type: 'varchar', length: 255 })
title!: string;
@Column({ name: 'description', type: 'text' })
description!: string;
@Column({ name: 'requirements', type: 'text', nullable: true })
requirements!: string | null;
@Column({ name: 'location', type: 'varchar', length: 255 })
location!: string;
@Column({ name: 'salary_range', type: 'varchar', length: 100, nullable: true })
salaryRange!: string | null;
@Column({ name: 'work_hours', type: 'varchar', length: 100 })
workHours!: string;
@Column({ name: 'contact_person', type: 'varchar', length: 50 })
contactPerson!: string;
@Column({ name: 'contact_phone', type: 'varchar', length: 20 })
contactPhone!: string;
@Column({ name: 'contact_email', type: 'varchar', length: 255, nullable: true })
contactEmail!: string | null;
@Column({ name: 'employer_name', type: 'varchar', length: 255 })
employerName!: string;
@Column({ name: 'employer_address', type: 'varchar', length: 500, nullable: true })
employerAddress!: string | null;
@Column({ name: 'job_type', type: 'varchar', length: 50 })
jobType!: string;
@Column({ name: 'required_skills', type: 'text', nullable: true })
requiredSkills!: string | null;
@Column({ name: 'benefits', type: 'text', nullable: true })
benefits!: string | null;
@Column({ name: 'application_deadline', type: 'date', nullable: true })
applicationDeadline!: Date | null;
@Column({ name: 'start_date', type: 'date', nullable: true })
startDate!: Date | null;
@Column({ name: 'status', type: 'tinyint', default: JobStatus.DRAFT })
status!: JobStatus;
@Column({ name: 'view_count', type: 'int', unsigned: true, default: 0 })
viewCount!: number;
@Column({ name: 'application_count', type: 'int', unsigned: true, default: 0 })
applicationCount!: number;
@CreateDateColumn({ name: 'created_at' })
createdAt!: Date;
@UpdateDateColumn({ name: 'updated_at' })
updatedAt!: Date;
@Column({ name: 'created_by', type: 'int', nullable: true })
createdBy!: number | null;
@Column({ name: 'updated_by', type: 'int', nullable: true })
updatedBy!: number | null;
}
文件位置: src/server/data-source.ts
修改内容: 在entities数组中添加SilverJob实体
文件位置: src/server/api/silver-jobs/index.ts
使用createCrudRoutes快速创建:
文件位置: src/client/admin/menu.tsx
修改内容: 在menuItems数组中添加:
{
key: 'silver-jobs',
label: '银龄岗管理',
icon: <BriefcaseOutlined />,
path: '/admin/silver-jobs',
permission: 'silver-job:manage'
}
文件位置: src/client/admin/routes.tsx
修改内容: 在children数组中添加:
{
path: 'silver-jobs',
element: <SilverJobsPage />,
errorElement: <ErrorPage />
}
文件位置: src/client/admin/pages/SilverJobs.tsx
页面功能包括:
文件位置: src/client/api.ts
修改内容: 添加silverJobsClient定义
| 字段名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| title | string | 是 | 岗位标题 |
| description | text | 是 | 岗位描述 |
| requirements | text | 否 | 岗位要求 |
| location | string | 是 | 工作地点 |
| salaryRange | string | 否 | 薪资范围 |
| workHours | string | 是 | 工作时间 |
| contactPerson | string | 是 | 联系人 |
| contactPhone | string | 是 | 联系电话 |
| contactEmail | string | 否 | 联系邮箱 |
| employerName | string | 是 | 雇主名称 |
| employerAddress | string | 否 | 雇主地址 |
| jobType | string | 是 | 岗位类型 |
| requiredSkills | text | 否 | 所需技能 |
| benefits | text | 否 | 福利待遇 |
| applicationDeadline | date | 否 | 申请截止日期 |
| startDate | date | 否 | 开始日期 |
| status | tinyint | 是 | 岗位状态 |