# 银龄岗管理功能实施方案
## 项目概述
基于现有架构,创建一套独立的银龄岗(SilverJob)管理系统,包含完整的前后端功能。
## 技术方案
采用标准通用CRUD模式实现,使用GenericCrudService和createCrudRoutes快速开发。
## 实施步骤
### 1. 银龄岗实体设计
**文件位置**: `src/server/modules/silver-jobs/silver-job.entity.ts`
```typescript
// 银龄岗状态枚举
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;
}
```
### 2. 数据源注册
**文件位置**: `src/server/data-source.ts`
**修改内容**: 在entities数组中添加SilverJob实体
### 3. 通用CRUD API实现
**文件位置**: `src/server/api/silver-jobs/index.ts`
使用createCrudRoutes快速创建:
- GET /api/v1/silver-jobs - 获取岗位列表
- POST /api/v1/silver-jobs - 创建新岗位
- GET /api/v1/silver-jobs/:id - 获取岗位详情
- PUT /api/v1/silver-jobs/:id - 更新岗位
- DELETE /api/v1/silver-jobs/:id - 删除岗位
### 4. 管理员菜单配置
**文件位置**: `src/client/admin/menu.tsx`
**修改内容**: 在menuItems数组中添加:
```typescript
{
key: 'silver-jobs',
label: '银龄岗管理',
icon: ,
path: '/admin/silver-jobs',
permission: 'silver-job:manage'
}
```
### 5. 路由配置
**文件位置**: `src/client/admin/routes.tsx`
**修改内容**: 在children数组中添加:
```typescript
{
path: 'silver-jobs',
element: ,
errorElement:
}
```
### 6. 管理页面创建
**文件位置**: `src/client/admin/pages/SilverJobs.tsx`
页面功能包括:
- 岗位列表展示(支持分页、搜索、筛选)
- 岗位详情查看
- 岗位创建/编辑
- 状态管理(草稿/发布/关闭/招满)
- 统计卡片展示
### 7. 客户端API定义
**文件位置**: `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 | 是 | 岗位状态 |
## 实施时间预估
- 后端实体和API:30分钟
- 前端页面和集成:45分钟
- 测试和调试:15分钟
- 总计:约90分钟
## 下一步操作
1. 切换到代码模式实施具体开发
2. 按顺序完成各个组件的创建
3. 进行集成测试验证功能完整性