|
|
@@ -1,1053 +0,0 @@
|
|
|
-# 网页人才信息添加API使用说明手册
|
|
|
-
|
|
|
-## API概述
|
|
|
-
|
|
|
-`/add-webpage-talent` 接口用于批量添加网页提取的人才信息到系统中。该接口能够将网页内容保存到MinIO存储,并为每个人才创建对应的业务卡片记录。系统会自动设置数据来源信息(`origin_source`)和人才档案信息(`talent_profile`)。
|
|
|
-
|
|
|
----
|
|
|
-
|
|
|
-## 基本信息
|
|
|
-
|
|
|
-| 项目 | 值 |
|
|
|
-|------|-----|
|
|
|
-| **接口路径** | `/api/data-parse/add-webpage-talent` |
|
|
|
-| **请求方法** | `POST` |
|
|
|
-| **Content-Type** | `application/json` |
|
|
|
-| **认证方式** | 根据系统配置 |
|
|
|
-
|
|
|
----
|
|
|
-
|
|
|
-## 输入参数
|
|
|
-
|
|
|
-### 请求体结构
|
|
|
-
|
|
|
-```json
|
|
|
-{
|
|
|
- "talent_list": [
|
|
|
- {
|
|
|
- "name_zh": "张三",
|
|
|
- "name_en": "Zhang San",
|
|
|
- "title_zh": "总经理",
|
|
|
- "title_en": "General Manager",
|
|
|
- "hotel_zh": "北京万豪酒店",
|
|
|
- "hotel_en": "Beijing Marriott Hotel",
|
|
|
- "brand_group": "万豪",
|
|
|
- "mobile": "13800138000",
|
|
|
- "email": "zhangsan@example.com",
|
|
|
- "phone": "010-12345678",
|
|
|
- "address_zh": "北京市朝阳区XXX路123号",
|
|
|
- "address_en": "123 XXX Road, Chaoyang District, Beijing",
|
|
|
- "postal_code_zh": "100000",
|
|
|
- "postal_code_en": "100000",
|
|
|
- "brand_zh": "万豪",
|
|
|
- "brand_en": "Marriott",
|
|
|
- "affiliation_zh": "万豪国际集团",
|
|
|
- "affiliation_en": "Marriott International",
|
|
|
- "birthday": "1980-01-01",
|
|
|
- "age": 44,
|
|
|
- "native_place": "北京市",
|
|
|
- "residence": "北京市朝阳区",
|
|
|
- "pic_url": "https://example.com/photo.jpg",
|
|
|
- "talent_profile": "资深酒店管理专家,拥有20年行业经验..."
|
|
|
- }
|
|
|
- ],
|
|
|
- "web_md": "# 酒店任命公告\n\n## 人事变动\n\n1. **张三** 被任命为北京万豪酒店总经理...\n\n更多内容..."
|
|
|
-}
|
|
|
-```
|
|
|
-
|
|
|
-### 参数详细说明
|
|
|
-
|
|
|
-#### `talent_list` (必填)
|
|
|
-- **类型**: `Array<Object>`
|
|
|
-- **描述**: 人才信息列表,每个对象包含一个人才的详细信息
|
|
|
-- **限制**: 非空数组
|
|
|
-
|
|
|
-#### `talent_list[].name_zh` (必填)
|
|
|
-- **类型**: `String`
|
|
|
-- **描述**: 中文姓名
|
|
|
-- **示例**: `"张三"`
|
|
|
-
|
|
|
-#### `talent_list[].name_en` (可选)
|
|
|
-- **类型**: `String`
|
|
|
-- **描述**: 英文姓名
|
|
|
-- **示例**: `"Zhang San"`
|
|
|
-
|
|
|
-#### `talent_list[].title_zh` (可选)
|
|
|
-- **类型**: `String`
|
|
|
-- **描述**: 中文职位
|
|
|
-- **示例**: `"总经理"`
|
|
|
-
|
|
|
-#### `talent_list[].title_en` (可选)
|
|
|
-- **类型**: `String`
|
|
|
-- **描述**: 英文职位
|
|
|
-- **示例**: `"General Manager"`
|
|
|
-
|
|
|
-#### `talent_list[].hotel_zh` (可选)
|
|
|
-- **类型**: `String`
|
|
|
-- **描述**: 酒店中文名称
|
|
|
-- **示例**: `"北京万豪酒店"`
|
|
|
-
|
|
|
-#### `talent_list[].hotel_en` (可选)
|
|
|
-- **类型**: `String`
|
|
|
-- **描述**: 酒店英文名称
|
|
|
-- **示例**: `"Beijing Marriott Hotel"`
|
|
|
-
|
|
|
-#### `talent_list[].brand_group` (可选)
|
|
|
-- **类型**: `String`
|
|
|
-- **描述**: 品牌组合
|
|
|
-- **示例**: `"万豪"`
|
|
|
-
|
|
|
-#### `talent_list[].mobile` (可选)
|
|
|
-- **类型**: `String`
|
|
|
-- **描述**: 手机号码,支持多个号码用逗号分隔
|
|
|
-- **示例**: `"13800138000,13900139000"`
|
|
|
-
|
|
|
-#### `talent_list[].email` (可选)
|
|
|
-- **类型**: `String`
|
|
|
-- **描述**: 电子邮箱
|
|
|
-- **示例**: `"zhangsan@example.com"`
|
|
|
-
|
|
|
-#### `talent_list[].phone` (可选)
|
|
|
-- **类型**: `String`
|
|
|
-- **描述**: 固定电话
|
|
|
-- **示例**: `"010-12345678"`
|
|
|
-
|
|
|
-#### `talent_list[].address_zh` (可选)
|
|
|
-- **类型**: `String`
|
|
|
-- **描述**: 中文地址
|
|
|
-- **示例**: `"北京市朝阳区XXX路123号"`
|
|
|
-
|
|
|
-#### `talent_list[].address_en` (可选)
|
|
|
-- **类型**: `String`
|
|
|
-- **描述**: 英文地址
|
|
|
-- **示例**: `"123 XXX Road, Chaoyang District, Beijing"`
|
|
|
-
|
|
|
-#### `talent_list[].birthday` (可选)
|
|
|
-- **类型**: `String`
|
|
|
-- **描述**: 生日,格式为YYYY-MM-DD
|
|
|
-- **示例**: `"1980-01-01"`
|
|
|
-
|
|
|
-#### `talent_list[].age` (可选)
|
|
|
-- **类型**: `Integer`
|
|
|
-- **描述**: 年龄
|
|
|
-- **示例**: `44`
|
|
|
-
|
|
|
-#### `talent_list[].pic_url` (可选)
|
|
|
-- **类型**: `String`
|
|
|
-- **描述**: 人才照片URL地址,系统会自动下载并保存到MinIO
|
|
|
-- **示例**: `"https://example.com/photo.jpg"`
|
|
|
-- **注意**: 如果提供了有效的图片URL,系统会自动下载图片并保存到MinIO存储中
|
|
|
-
|
|
|
-#### `talent_list[].talent_profile` (可选)
|
|
|
-- **类型**: `String`
|
|
|
-- **描述**: 人才档案信息,包含个人简介、工作经历、专业技能等详细信息
|
|
|
-- **示例**: `"资深酒店管理专家,拥有20年行业经验,曾在多家国际知名酒店担任高级管理职位..."`
|
|
|
-
|
|
|
-#### `web_md` (必填)
|
|
|
-- **类型**: `String`
|
|
|
-- **描述**: 网页的markdown格式文本内容,将被保存到MinIO存储
|
|
|
-- **限制**: 非空字符串
|
|
|
-
|
|
|
----
|
|
|
-
|
|
|
-## 输出参数
|
|
|
-
|
|
|
-### 响应结构
|
|
|
-
|
|
|
-#### 成功响应 (所有记录处理成功)
|
|
|
-```json
|
|
|
-{
|
|
|
- "code": 200,
|
|
|
- "success": true,
|
|
|
- "message": "所有3条人才记录处理成功",
|
|
|
- "data": [
|
|
|
- {
|
|
|
- "id": 123,
|
|
|
- "name_zh": "张三",
|
|
|
- "name_en": "Zhang San",
|
|
|
- "title_zh": "总经理",
|
|
|
- "title_en": "General Manager",
|
|
|
- "hotel_zh": "北京万豪酒店",
|
|
|
- "hotel_en": "Beijing Marriott Hotel",
|
|
|
- "mobile": "13800138000",
|
|
|
- "email": "zhangsan@example.com",
|
|
|
- "phone": "010-12345678",
|
|
|
- "address_zh": "北京市朝阳区XXX路123号",
|
|
|
- "address_en": "123 XXX Road, Chaoyang District, Beijing",
|
|
|
- "postal_code_zh": "100000",
|
|
|
- "postal_code_en": "100000",
|
|
|
- "brand_zh": "万豪",
|
|
|
- "brand_en": "Marriott",
|
|
|
- "affiliation_zh": "万豪国际集团",
|
|
|
- "affiliation_en": "Marriott International",
|
|
|
- "birthday": "1980-01-01",
|
|
|
- "age": 44,
|
|
|
- "native_place": "北京市",
|
|
|
- "residence": "北京市朝阳区",
|
|
|
- "brand_group": "万豪",
|
|
|
- "image_path": "talent_photos/talent_photo_张三_20240101_12345678.jpg",
|
|
|
- "career_path": [
|
|
|
- {
|
|
|
- "date": "2024-01-01",
|
|
|
- "hotel_zh": "北京万豪酒店",
|
|
|
- "hotel_en": "Beijing Marriott Hotel",
|
|
|
- "title_zh": "总经理",
|
|
|
- "title_en": "General Manager",
|
|
|
- "image_path": "talent_photos/talent_photo_张三_20240101_12345678.jpg",
|
|
|
- "source": "webpage_extraction"
|
|
|
- }
|
|
|
- ],
|
|
|
- "talent_profile": "资深酒店管理专家,拥有20年行业经验...",
|
|
|
- "origin_source": {
|
|
|
- "type": "webpage_talent",
|
|
|
- "minio_path": "webpage_talent/webpage_talent_20240101_12345678.md",
|
|
|
- "source_date": "2024-01-01 12:00:00"
|
|
|
- },
|
|
|
- "created_at": "2024-01-01 12:00:00",
|
|
|
- "updated_at": "2024-01-01 12:00:00",
|
|
|
- "updated_by": "webpage_talent_system",
|
|
|
- "status": "active"
|
|
|
- },
|
|
|
- {
|
|
|
- "id": 124,
|
|
|
- "name_zh": "李四",
|
|
|
- "name_en": "Li Si",
|
|
|
- "title_zh": "副总经理",
|
|
|
- "title_en": "Deputy General Manager",
|
|
|
- "hotel_zh": "上海希尔顿酒店",
|
|
|
- "hotel_en": "Shanghai Hilton Hotel",
|
|
|
- "mobile": "13900139000",
|
|
|
- "email": "lisi@example.com",
|
|
|
- "brand_group": "希尔顿",
|
|
|
- "image_path": "talent_photos/talent_photo_李四_20240101_12345679.jpg",
|
|
|
- "career_path": [
|
|
|
- {
|
|
|
- "date": "2024-01-01",
|
|
|
- "hotel_zh": "上海希尔顿酒店",
|
|
|
- "hotel_en": "Shanghai Hilton Hotel",
|
|
|
- "title_zh": "副总经理",
|
|
|
- "title_en": "Deputy General Manager",
|
|
|
- "image_path": "talent_photos/talent_photo_李四_20240101_12345679.jpg",
|
|
|
- "source": "webpage_extraction"
|
|
|
- }
|
|
|
- ],
|
|
|
- "talent_profile": "酒店业资深管理者,专注于市场营销和品牌推广...",
|
|
|
- "origin_source": {
|
|
|
- "type": "webpage_talent",
|
|
|
- "minio_path": "webpage_talent/webpage_talent_20240101_12345678.md",
|
|
|
- "source_date": "2024-01-01 12:00:00"
|
|
|
- },
|
|
|
- "created_at": "2024-01-01 12:00:00",
|
|
|
- "updated_at": "2024-01-01 12:00:00",
|
|
|
- "updated_by": "webpage_talent_system",
|
|
|
- "status": "active"
|
|
|
- }
|
|
|
- ]
|
|
|
-}
|
|
|
-```
|
|
|
-
|
|
|
-#### 部分成功响应
|
|
|
-```json
|
|
|
-{
|
|
|
- "code": 206,
|
|
|
- "success": true,
|
|
|
- "message": "部分处理成功:2/3条记录成功",
|
|
|
- "data": {
|
|
|
- "total_count": 3,
|
|
|
- "success_count": 2,
|
|
|
- "failed_count": 1,
|
|
|
- "success_records": [
|
|
|
- {
|
|
|
- "id": 123,
|
|
|
- "name_zh": "张三",
|
|
|
- "name_en": "Zhang San",
|
|
|
- "title_zh": "总经理",
|
|
|
- "title_en": "General Manager",
|
|
|
- "hotel_zh": "北京万豪酒店",
|
|
|
- "hotel_en": "Beijing Marriott Hotel",
|
|
|
- "mobile": "13800138000",
|
|
|
- "email": "zhangsan@example.com",
|
|
|
- "brand_group": "万豪",
|
|
|
- "image_path": "talent_photos/talent_photo_张三_20240101_12345678.jpg",
|
|
|
- "talent_profile": "资深酒店管理专家,拥有20年行业经验...",
|
|
|
- "origin_source": {
|
|
|
- "type": "webpage_talent",
|
|
|
- "minio_path": "webpage_talent/webpage_talent_20240101_12345678.md",
|
|
|
- "source_date": "2024-01-01 12:00:00"
|
|
|
- },
|
|
|
- "created_at": "2024-01-01 12:00:00",
|
|
|
- "updated_at": "2024-01-01 12:00:00",
|
|
|
- "status": "active"
|
|
|
- },
|
|
|
- {
|
|
|
- "id": 124,
|
|
|
- "name_zh": "李四",
|
|
|
- "title_zh": "副总经理",
|
|
|
- "hotel_zh": "上海希尔顿酒店",
|
|
|
- "brand_group": "希尔顿",
|
|
|
- "image_path": "talent_photos/talent_photo_李四_20240101_12345679.jpg",
|
|
|
- "talent_profile": "酒店业资深管理者...",
|
|
|
- "origin_source": {
|
|
|
- "type": "webpage_talent",
|
|
|
- "minio_path": "webpage_talent/webpage_talent_20240101_12345678.md",
|
|
|
- "source_date": "2024-01-01 12:00:00"
|
|
|
- },
|
|
|
- "created_at": "2024-01-01 12:00:00",
|
|
|
- "status": "active"
|
|
|
- }
|
|
|
- ],
|
|
|
- "failed_records": [
|
|
|
- {
|
|
|
- "error": "第3个记录缺少name_zh字段",
|
|
|
- "input_data": {
|
|
|
- "name_zh": "",
|
|
|
- "title_zh": "经理"
|
|
|
- }
|
|
|
- }
|
|
|
- ],
|
|
|
- "minio_md_path": "webpage_talent/webpage_talent_20240101_12345678.md"
|
|
|
- }
|
|
|
-}
|
|
|
-```
|
|
|
-
|
|
|
-#### 错误响应
|
|
|
-```json
|
|
|
-{
|
|
|
- "code": 400,
|
|
|
- "success": false,
|
|
|
- "message": "talent_list参数必须是非空数组",
|
|
|
- "data": null
|
|
|
-}
|
|
|
-```
|
|
|
-
|
|
|
-### 响应字段说明
|
|
|
-
|
|
|
-#### 通用字段
|
|
|
-- **`code`**: HTTP状态码 (200=全部成功, 206=部分成功, 400=参数错误, 500=服务器错误)
|
|
|
-- **`success`**: 操作是否成功 (true/false)
|
|
|
-- **`message`**: 响应消息,描述操作结果
|
|
|
-- **`data`**: 响应数据内容
|
|
|
-
|
|
|
-#### 全部成功时的data字段 (code=200)
|
|
|
-- **类型**: `Array<Object>`
|
|
|
-- **描述**: 成功创建/更新的业务卡片记录数组,每个对象包含完整的名片信息
|
|
|
-
|
|
|
-#### 部分成功时的data字段 (code=206)
|
|
|
-- **`total_count`**: 总记录数
|
|
|
-- **`success_count`**: 成功处理的记录数
|
|
|
-- **`failed_count`**: 失败记录数
|
|
|
-- **`success_records`**: 成功记录数组,每个对象包含完整的名片信息
|
|
|
-- **`failed_records`**: 失败记录数组,包含错误信息和输入数据
|
|
|
-- **`minio_md_path`**: 网页内容在MinIO中的存储路径
|
|
|
-
|
|
|
-#### 业务卡片记录字段说明
|
|
|
-每个成功创建的业务卡片记录包含以下字段:
|
|
|
-- **`id`**: 数据库记录ID
|
|
|
-- **`name_zh`**: 中文姓名
|
|
|
-- **`name_en`**: 英文姓名
|
|
|
-- **`title_zh`**: 中文职位
|
|
|
-- **`title_en`**: 英文职位
|
|
|
-- **`hotel_zh`**: 酒店中文名称
|
|
|
-- **`hotel_en`**: 酒店英文名称
|
|
|
-- **`mobile`**: 手机号码
|
|
|
-- **`email`**: 电子邮箱
|
|
|
-- **`phone`**: 固定电话
|
|
|
-- **`address_zh`**: 中文地址
|
|
|
-- **`address_en`**: 英文地址
|
|
|
-- **`postal_code_zh`**: 中文邮编
|
|
|
-- **`postal_code_en`**: 英文邮编
|
|
|
-- **`brand_zh`**: 品牌中文名称
|
|
|
-- **`brand_en`**: 品牌英文名称
|
|
|
-- **`affiliation_zh`**: 中文所属机构
|
|
|
-- **`affiliation_en`**: 英文所属机构
|
|
|
-- **`birthday`**: 生日 (YYYY-MM-DD格式)
|
|
|
-- **`age`**: 年龄
|
|
|
-- **`native_place`**: 籍贯
|
|
|
-- **`residence`**: 居住地
|
|
|
-- **`brand_group`**: 品牌组合
|
|
|
-- **`image_path`**: 人才照片在MinIO中的存储路径(如果提供了pic_url)
|
|
|
-- **`career_path`**: 职业轨迹数组,包含职位变化历史
|
|
|
-- **`talent_profile`**: 人才档案信息
|
|
|
-- **`origin_source`**: 数据来源信息,包含以下子字段:
|
|
|
- - **`type`**: 数据来源类型,固定为"webpage_talent"
|
|
|
- - **`minio_path`**: 原始网页内容在MinIO中的存储路径
|
|
|
- - **`source_date`**: 数据处理时间
|
|
|
-- **`created_at`**: 创建时间
|
|
|
-- **`updated_at`**: 更新时间
|
|
|
-- **`updated_by`**: 更新人
|
|
|
-- **`status`**: 记录状态 (通常为"active")
|
|
|
-
|
|
|
----
|
|
|
-
|
|
|
-## 返回状态码
|
|
|
-
|
|
|
-| 状态码 | 说明 | 场景 |
|
|
|
-|--------|------|------|
|
|
|
-| **200** | 成功 | 所有记录处理成功 |
|
|
|
-| **206** | 部分成功 | 部分记录处理成功 |
|
|
|
-| **400** | 请求参数错误 | 参数格式不正确或缺少必填参数 |
|
|
|
-| **500** | 服务器内部错误 | 系统异常或数据库错误 |
|
|
|
-
|
|
|
----
|
|
|
-
|
|
|
-## 前端代码示例
|
|
|
-
|
|
|
-### JavaScript (原生)
|
|
|
-
|
|
|
-```javascript
|
|
|
-// 发送请求函数
|
|
|
-async function addWebpageTalent(talentList, webMd) {
|
|
|
- const url = '/api/data-parse/add-webpage-talent';
|
|
|
-
|
|
|
- const requestBody = {
|
|
|
- talent_list: talentList,
|
|
|
- web_md: webMd
|
|
|
- };
|
|
|
-
|
|
|
- try {
|
|
|
- const response = await fetch(url, {
|
|
|
- method: 'POST',
|
|
|
- headers: {
|
|
|
- 'Content-Type': 'application/json',
|
|
|
- // 如果需要认证,添加相应的头部
|
|
|
- // 'Authorization': 'Bearer your-token'
|
|
|
- },
|
|
|
- body: JSON.stringify(requestBody)
|
|
|
- });
|
|
|
-
|
|
|
- const result = await response.json();
|
|
|
-
|
|
|
- if (result.success) {
|
|
|
- console.log('处理成功:', result.message);
|
|
|
- console.log('处理详情:', result.data);
|
|
|
-
|
|
|
- // 处理成功记录 - 区分全部成功和部分成功的响应格式
|
|
|
- if (result.code === 200) {
|
|
|
- // 全部成功:data是业务卡片记录数组
|
|
|
- console.log(`成功处理 ${result.data.length} 条记录`);
|
|
|
- result.data.forEach((record, index) => {
|
|
|
- console.log(`记录 ${index + 1}: ${record.name_zh}`);
|
|
|
-
|
|
|
- // 显示图片路径信息
|
|
|
- if (record.image_path) {
|
|
|
- console.log(` 图片路径: ${record.image_path}`);
|
|
|
- }
|
|
|
-
|
|
|
- // 显示人才档案信息
|
|
|
- if (record.talent_profile) {
|
|
|
- console.log(` 人才档案: ${record.talent_profile.substring(0, 50)}...`);
|
|
|
- }
|
|
|
-
|
|
|
- // 显示数据来源信息
|
|
|
- if (record.origin_source) {
|
|
|
- console.log(` 数据来源: ${record.origin_source.type}`);
|
|
|
- console.log(` 原始文档: ${record.origin_source.minio_path}`);
|
|
|
- }
|
|
|
- });
|
|
|
- } else if (result.code === 206) {
|
|
|
- // 部分成功:data包含详细的成功和失败信息
|
|
|
- console.log(`部分成功:${result.data.success_count}/${result.data.total_count} 条记录成功`);
|
|
|
-
|
|
|
- // 显示成功记录
|
|
|
- if (result.data.success_records.length > 0) {
|
|
|
- result.data.success_records.forEach((record, index) => {
|
|
|
- console.log(`成功记录 ${record.index}: ${record.data.name_zh} - ${record.message}`);
|
|
|
- if (record.data.image_path) {
|
|
|
- console.log(` 图片路径: ${record.data.image_path}`);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- // 显示失败记录
|
|
|
- if (result.data.failed_records.length > 0) {
|
|
|
- result.data.failed_records.forEach((record, index) => {
|
|
|
- console.error(`失败记录 ${record.index}: ${record.error}`);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return result;
|
|
|
- } else {
|
|
|
- console.error('处理失败:', result.message);
|
|
|
- throw new Error(result.message);
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error('请求失败:', error);
|
|
|
- throw error;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// 使用示例
|
|
|
-const talentData = [
|
|
|
- {
|
|
|
- name_zh: "张三",
|
|
|
- name_en: "Zhang San",
|
|
|
- title_zh: "总经理",
|
|
|
- title_en: "General Manager",
|
|
|
- hotel_zh: "北京万豪酒店",
|
|
|
- hotel_en: "Beijing Marriott Hotel",
|
|
|
- brand_group: "万豪",
|
|
|
- mobile: "13800138000",
|
|
|
- email: "zhangsan@example.com",
|
|
|
- pic_url: "https://example.com/photos/zhangsan.jpg",
|
|
|
- talent_profile: "资深酒店管理专家,拥有20年行业经验,曾在多家国际知名酒店担任高级管理职位。精通酒店运营管理、客户服务、团队建设等多个领域。"
|
|
|
- },
|
|
|
- {
|
|
|
- name_zh: "李四",
|
|
|
- name_en: "Li Si",
|
|
|
- title_zh: "副总经理",
|
|
|
- title_en: "Deputy General Manager",
|
|
|
- hotel_zh: "上海希尔顿酒店",
|
|
|
- hotel_en: "Shanghai Hilton Hotel",
|
|
|
- brand_group: "希尔顿",
|
|
|
- mobile: "13900139000",
|
|
|
- email: "lisi@example.com",
|
|
|
- pic_url: "https://example.com/photos/lisi.jpg",
|
|
|
- talent_profile: "酒店业资深管理者,专注于市场营销和品牌推广,具有丰富的国际酒店管理经验。"
|
|
|
- }
|
|
|
-];
|
|
|
-
|
|
|
-const webContent = `
|
|
|
-# 酒店人事任命公告
|
|
|
-
|
|
|
-## 重要人事变动
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-1. **张三**被任命为北京万豪酒店总经理
|
|
|
- - 手机:13800138000
|
|
|
- - 邮箱:zhangsan@example.com
|
|
|
- - 简介:资深酒店管理专家,拥有20年行业经验
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-2. **李四**被任命为上海希尔顿酒店副总经理
|
|
|
- - 手机:13900139000
|
|
|
- - 邮箱:lisi@example.com
|
|
|
- - 简介:酒店业资深管理者,专注于市场营销和品牌推广
|
|
|
-`;
|
|
|
-
|
|
|
-// 调用函数
|
|
|
-addWebpageTalent(talentData, webContent)
|
|
|
- .then(result => {
|
|
|
- console.log('操作完成:', result);
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- console.error('操作失败:', error);
|
|
|
- });
|
|
|
-```
|
|
|
-
|
|
|
-### jQuery
|
|
|
-
|
|
|
-```javascript
|
|
|
-function addWebpageTalent(talentList, webMd) {
|
|
|
- return $.ajax({
|
|
|
- url: '/api/data-parse/add-webpage-talent',
|
|
|
- type: 'POST',
|
|
|
- contentType: 'application/json',
|
|
|
- data: JSON.stringify({
|
|
|
- talent_list: talentList,
|
|
|
- web_md: webMd
|
|
|
- }),
|
|
|
- success: function(result) {
|
|
|
- if (result.success) {
|
|
|
- console.log('处理成功:', result.message);
|
|
|
-
|
|
|
- // 显示处理结果 - 区分全部成功和部分成功的响应格式
|
|
|
- if (result.code === 200) {
|
|
|
- // 全部成功
|
|
|
- alert(`成功处理 ${result.data.length} 条记录`);
|
|
|
-
|
|
|
- // 显示详细信息
|
|
|
- result.data.forEach(record => {
|
|
|
- console.log(`人才: ${record.name_zh}`);
|
|
|
- if (record.image_path) {
|
|
|
- console.log(`图片已保存: ${record.image_path}`);
|
|
|
- }
|
|
|
- if (record.talent_profile) {
|
|
|
- console.log(`人才档案: ${record.talent_profile.substring(0, 50)}...`);
|
|
|
- }
|
|
|
- });
|
|
|
- } else if (result.code === 206) {
|
|
|
- // 部分成功
|
|
|
- alert(`部分成功: ${result.data.success_count}/${result.data.total_count} 条记录成功`);
|
|
|
-
|
|
|
- // 显示成功记录
|
|
|
- result.data.success_records.forEach(record => {
|
|
|
- console.log(`成功: ${record.data.name_zh}`);
|
|
|
- if (record.data.image_path) {
|
|
|
- console.log(`图片已保存: ${record.data.image_path}`);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- // 显示失败记录
|
|
|
- result.data.failed_records.forEach(record => {
|
|
|
- console.error(`失败: ${record.error}`);
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- if (result.data.failed_count > 0) {
|
|
|
- console.warn(`失败 ${result.data.failed_count} 条记录`);
|
|
|
- result.data.failed_records.forEach(record => {
|
|
|
- console.error(`记录 ${record.index}: ${record.error}`);
|
|
|
- });
|
|
|
- }
|
|
|
- } else {
|
|
|
- alert('处理失败: ' + result.message);
|
|
|
- }
|
|
|
- },
|
|
|
- error: function(xhr, status, error) {
|
|
|
- console.error('请求失败:', error);
|
|
|
- alert('请求失败: ' + error);
|
|
|
- }
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-// 使用示例
|
|
|
-const talentData = [
|
|
|
- {
|
|
|
- name_zh: "张三",
|
|
|
- title_zh: "总经理",
|
|
|
- hotel_zh: "北京万豪酒店",
|
|
|
- mobile: "13800138000",
|
|
|
- pic_url: "https://example.com/photos/zhangsan.jpg",
|
|
|
- talent_profile: "资深酒店管理专家,拥有20年行业经验..."
|
|
|
- }
|
|
|
-];
|
|
|
-
|
|
|
-const webContent = "# 人事任命公告\n\n\n\n张三被任命为总经理...";
|
|
|
-
|
|
|
-addWebpageTalent(talentData, webContent);
|
|
|
-```
|
|
|
-
|
|
|
-### Vue.js
|
|
|
-
|
|
|
-```vue
|
|
|
-<template>
|
|
|
- <div>
|
|
|
- <h3>添加网页人才信息</h3>
|
|
|
-
|
|
|
- <!-- 人才信息表单 -->
|
|
|
- <div v-for="(talent, index) in talentList" :key="index" class="talent-form">
|
|
|
- <h4>人才 {{ index + 1 }}</h4>
|
|
|
- <div class="form-group">
|
|
|
- <label>中文姓名 (必填):</label>
|
|
|
- <input v-model="talent.name_zh" type="text" required>
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label>英文姓名:</label>
|
|
|
- <input v-model="talent.name_en" type="text">
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label>中文职位:</label>
|
|
|
- <input v-model="talent.title_zh" type="text">
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label>酒店名称:</label>
|
|
|
- <input v-model="talent.hotel_zh" type="text">
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label>手机号码:</label>
|
|
|
- <input v-model="talent.mobile" type="text">
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label>电子邮箱:</label>
|
|
|
- <input v-model="talent.email" type="email">
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label>照片URL:</label>
|
|
|
- <input v-model="talent.pic_url" type="url" placeholder="https://example.com/photo.jpg">
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label>人才档案:</label>
|
|
|
- <textarea v-model="talent.talent_profile" rows="4" cols="50"
|
|
|
- placeholder="请输入人才的详细档案信息,包括工作经历、专业技能等..."></textarea>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <!-- 网页内容 -->
|
|
|
- <div class="form-group">
|
|
|
- <label>网页内容 (Markdown格式):</label>
|
|
|
- <textarea v-model="webMd" rows="10" cols="50" required></textarea>
|
|
|
- </div>
|
|
|
-
|
|
|
- <!-- 操作按钮 -->
|
|
|
- <div class="actions">
|
|
|
- <button @click="addTalent">添加人才</button>
|
|
|
- <button @click="submitData" :disabled="loading">
|
|
|
- {{ loading ? '处理中...' : '提交数据' }}
|
|
|
- </button>
|
|
|
- </div>
|
|
|
-
|
|
|
- <!-- 结果显示 -->
|
|
|
- <div v-if="result" class="result">
|
|
|
- <h4>处理结果</h4>
|
|
|
- <p :class="result.success ? 'success' : 'error'">{{ result.message }}</p>
|
|
|
-
|
|
|
- <div v-if="result.data">
|
|
|
- <!-- 全部成功的显示 -->
|
|
|
- <div v-if="result.code === 200">
|
|
|
- <p>总记录数: {{ result.data.length }}</p>
|
|
|
- <p>全部处理成功</p>
|
|
|
-
|
|
|
- <div class="success-records">
|
|
|
- <h5>成功记录:</h5>
|
|
|
- <ul>
|
|
|
- <li v-for="(record, index) in result.data" :key="index">
|
|
|
- <strong>{{ record.name_zh }}</strong>
|
|
|
- <div v-if="record.image_path" class="detail">
|
|
|
- 图片已保存: {{ record.image_path }}
|
|
|
- </div>
|
|
|
- <div v-if="record.talent_profile" class="detail">
|
|
|
- 人才档案: {{ record.talent_profile.substring(0, 100) }}...
|
|
|
- </div>
|
|
|
- <div v-if="record.origin_source" class="detail">
|
|
|
- 数据来源: {{ record.origin_source.type }}
|
|
|
- ({{ record.origin_source.source_date }})
|
|
|
- </div>
|
|
|
- </li>
|
|
|
- </ul>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <!-- 部分成功的显示 -->
|
|
|
- <div v-if="result.code === 206">
|
|
|
- <p>总记录数: {{ result.data.total_count }}</p>
|
|
|
- <p>成功: {{ result.data.success_count }}</p>
|
|
|
- <p>失败: {{ result.data.failed_count }}</p>
|
|
|
-
|
|
|
- <!-- 成功记录详情 -->
|
|
|
- <div v-if="result.data.success_records.length > 0" class="success-records">
|
|
|
- <h5>成功记录:</h5>
|
|
|
- <ul>
|
|
|
- <li v-for="record in result.data.success_records" :key="record.index">
|
|
|
- <strong>{{ record.data.name_zh }}</strong> - {{ record.message }}
|
|
|
- <div v-if="record.data.image_path" class="detail">
|
|
|
- 图片已保存: {{ record.data.image_path }}
|
|
|
- </div>
|
|
|
- <div v-if="record.data.talent_profile" class="detail">
|
|
|
- 人才档案: {{ record.data.talent_profile.substring(0, 100) }}...
|
|
|
- </div>
|
|
|
- <div v-if="record.data.origin_source" class="detail">
|
|
|
- 数据来源: {{ record.data.origin_source.type }}
|
|
|
- ({{ record.data.origin_source.source_date }})
|
|
|
- </div>
|
|
|
- </li>
|
|
|
- </ul>
|
|
|
- </div>
|
|
|
-
|
|
|
- <!-- 失败记录详情 -->
|
|
|
- <div v-if="result.data.failed_records.length > 0" class="failed-records">
|
|
|
- <h5>失败记录:</h5>
|
|
|
- <ul>
|
|
|
- <li v-for="record in result.data.failed_records" :key="record.index">
|
|
|
- 记录 {{ record.index }}: {{ record.error }}
|
|
|
- </li>
|
|
|
- </ul>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-</template>
|
|
|
-
|
|
|
-<script>
|
|
|
-export default {
|
|
|
- name: 'AddWebpageTalent',
|
|
|
- data() {
|
|
|
- return {
|
|
|
- talentList: [
|
|
|
- {
|
|
|
- name_zh: '',
|
|
|
- name_en: '',
|
|
|
- title_zh: '',
|
|
|
- title_en: '',
|
|
|
- hotel_zh: '',
|
|
|
- hotel_en: '',
|
|
|
- brand_group: '',
|
|
|
- mobile: '',
|
|
|
- email: '',
|
|
|
- phone: '',
|
|
|
- address_zh: '',
|
|
|
- address_en: '',
|
|
|
- pic_url: '',
|
|
|
- talent_profile: ''
|
|
|
- }
|
|
|
- ],
|
|
|
- webMd: '',
|
|
|
- loading: false,
|
|
|
- result: null
|
|
|
- };
|
|
|
- },
|
|
|
- methods: {
|
|
|
- addTalent() {
|
|
|
- this.talentList.push({
|
|
|
- name_zh: '',
|
|
|
- name_en: '',
|
|
|
- title_zh: '',
|
|
|
- title_en: '',
|
|
|
- hotel_zh: '',
|
|
|
- hotel_en: '',
|
|
|
- brand_group: '',
|
|
|
- mobile: '',
|
|
|
- email: '',
|
|
|
- phone: '',
|
|
|
- address_zh: '',
|
|
|
- address_en: '',
|
|
|
- pic_url: '',
|
|
|
- talent_profile: ''
|
|
|
- });
|
|
|
- },
|
|
|
-
|
|
|
- async submitData() {
|
|
|
- if (!this.validateData()) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- this.loading = true;
|
|
|
- this.result = null;
|
|
|
-
|
|
|
- try {
|
|
|
- const response = await fetch('/api/data-parse/add-webpage-talent', {
|
|
|
- method: 'POST',
|
|
|
- headers: {
|
|
|
- 'Content-Type': 'application/json'
|
|
|
- },
|
|
|
- body: JSON.stringify({
|
|
|
- talent_list: this.talentList,
|
|
|
- web_md: this.webMd
|
|
|
- })
|
|
|
- });
|
|
|
-
|
|
|
- const result = await response.json();
|
|
|
- this.result = result;
|
|
|
-
|
|
|
- if (result.success) {
|
|
|
- this.$message.success(result.message);
|
|
|
-
|
|
|
- // 显示详细处理结果
|
|
|
- if (result.code === 200) {
|
|
|
- console.log('成功处理的记录详情:');
|
|
|
- result.data.forEach(record => {
|
|
|
- console.log(`- ${record.name_zh}:`);
|
|
|
- if (record.image_path) {
|
|
|
- console.log(` 图片: ${record.image_path}`);
|
|
|
- }
|
|
|
- if (record.talent_profile) {
|
|
|
- console.log(` 档案: ${record.talent_profile.substring(0, 50)}...`);
|
|
|
- }
|
|
|
- });
|
|
|
- } else if (result.code === 206) {
|
|
|
- console.log('部分成功的记录详情:');
|
|
|
- result.data.success_records.forEach(record => {
|
|
|
- console.log(`- ${record.data.name_zh}: ${record.message}`);
|
|
|
- if (record.data.image_path) {
|
|
|
- console.log(` 图片: ${record.data.image_path}`);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- if (result.data.failed_records.length > 0) {
|
|
|
- console.log('失败的记录详情:');
|
|
|
- result.data.failed_records.forEach(record => {
|
|
|
- console.error(`- 记录 ${record.index}: ${record.error}`);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.$message.error(result.message);
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- this.result = {
|
|
|
- success: false,
|
|
|
- message: '请求失败: ' + error.message
|
|
|
- };
|
|
|
- this.$message.error('请求失败: ' + error.message);
|
|
|
- } finally {
|
|
|
- this.loading = false;
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- validateData() {
|
|
|
- // 验证必填字段
|
|
|
- for (let i = 0; i < this.talentList.length; i++) {
|
|
|
- if (!this.talentList[i].name_zh.trim()) {
|
|
|
- this.$message.error(`第 ${i + 1} 个人才的中文姓名不能为空`);
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (!this.webMd.trim()) {
|
|
|
- this.$message.error('网页内容不能为空');
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
-};
|
|
|
-</script>
|
|
|
-
|
|
|
-<style scoped>
|
|
|
-.talent-form {
|
|
|
- border: 1px solid #ddd;
|
|
|
- padding: 15px;
|
|
|
- margin: 10px 0;
|
|
|
- border-radius: 5px;
|
|
|
-}
|
|
|
-
|
|
|
-.form-group {
|
|
|
- margin: 10px 0;
|
|
|
-}
|
|
|
-
|
|
|
-.form-group label {
|
|
|
- display: inline-block;
|
|
|
- width: 120px;
|
|
|
- font-weight: bold;
|
|
|
-}
|
|
|
-
|
|
|
-.form-group input,
|
|
|
-.form-group textarea {
|
|
|
- width: 300px;
|
|
|
- padding: 5px;
|
|
|
- border: 1px solid #ccc;
|
|
|
- border-radius: 3px;
|
|
|
-}
|
|
|
-
|
|
|
-.actions {
|
|
|
- margin: 20px 0;
|
|
|
-}
|
|
|
-
|
|
|
-.actions button {
|
|
|
- margin-right: 10px;
|
|
|
- padding: 10px 20px;
|
|
|
- background: #007bff;
|
|
|
- color: white;
|
|
|
- border: none;
|
|
|
- border-radius: 5px;
|
|
|
- cursor: pointer;
|
|
|
-}
|
|
|
-
|
|
|
-.actions button:disabled {
|
|
|
- background: #6c757d;
|
|
|
- cursor: not-allowed;
|
|
|
-}
|
|
|
-
|
|
|
-.result {
|
|
|
- margin: 20px 0;
|
|
|
- padding: 15px;
|
|
|
- border: 1px solid #ddd;
|
|
|
- border-radius: 5px;
|
|
|
-}
|
|
|
-
|
|
|
-.success {
|
|
|
- color: #28a745;
|
|
|
-}
|
|
|
-
|
|
|
-.error {
|
|
|
- color: #dc3545;
|
|
|
-}
|
|
|
-
|
|
|
-.success-records, .failed-records {
|
|
|
- margin-top: 15px;
|
|
|
-}
|
|
|
-
|
|
|
-.detail {
|
|
|
- font-size: 12px;
|
|
|
- color: #666;
|
|
|
- margin-left: 10px;
|
|
|
-}
|
|
|
-</style>
|
|
|
-```
|
|
|
-
|
|
|
----
|
|
|
-
|
|
|
-## 错误处理
|
|
|
-
|
|
|
-### 常见错误及解决方案
|
|
|
-
|
|
|
-#### 1. 参数验证错误
|
|
|
-**错误**: `talent_list参数必须是非空数组`
|
|
|
-**解决**: 确保talent_list是一个非空数组
|
|
|
-
|
|
|
-#### 2. 缺少必填字段
|
|
|
-**错误**: `第X个记录缺少name_zh字段`
|
|
|
-**解决**: 确保每个人才记录都包含name_zh字段
|
|
|
-
|
|
|
-#### 3. MinIO上传失败
|
|
|
-**错误**: `上传网页内容到MinIO失败`
|
|
|
-**解决**: 检查MinIO服务状态和配置
|
|
|
-
|
|
|
-#### 4. 图片下载失败
|
|
|
-**错误**: `人员XXX的图片处理失败`
|
|
|
-**解决**: 检查pic_url是否有效,网络连接是否正常。图片下载失败不会影响其他数据的处理
|
|
|
-
|
|
|
-#### 5. 数据库错误
|
|
|
-**错误**: `数据库操作失败`
|
|
|
-**解决**: 检查数据库连接和表结构
|
|
|
-
|
|
|
----
|
|
|
-
|
|
|
-## 数据字段详解
|
|
|
-
|
|
|
-### 新增字段说明
|
|
|
-
|
|
|
-#### `origin_source` (JSON类型)
|
|
|
-系统自动生成的数据来源信息,包含:
|
|
|
-- **`type`**: 数据来源类型,网页人才固定为"webpage_talent"
|
|
|
-- **`minio_path`**: 原始网页内容在MinIO中的存储路径
|
|
|
-- **`source_date`**: 数据处理时间
|
|
|
-
|
|
|
-#### `talent_profile` (文本类型)
|
|
|
-人才档案信息,可包含:
|
|
|
-- 个人简介和背景
|
|
|
-- 工作经历和职业发展
|
|
|
-- 专业技能和资质认证
|
|
|
-- 教育背景
|
|
|
-- 获奖情况和荣誉
|
|
|
-- 其他相关信息
|
|
|
-
|
|
|
-#### `image_path` (字符串类型)
|
|
|
-如果提供了`pic_url`,系统会:
|
|
|
-1. 自动下载图片
|
|
|
-2. 保存到MinIO的`talent_photos/`目录
|
|
|
-3. 生成唯一的文件名
|
|
|
-4. 将MinIO路径保存到此字段
|
|
|
-
|
|
|
----
|
|
|
-
|
|
|
-## 注意事项
|
|
|
-
|
|
|
-1. **数据完整性**: 确保talent_list中每个对象都包含name_zh字段
|
|
|
-2. **内容大小**: web_md内容不应过大,建议控制在合理范围内
|
|
|
-3. **并发处理**: 该接口支持批量处理,但建议控制单次请求的记录数量
|
|
|
-4. **重复检查**: 系统会自动检查重复记录并相应处理
|
|
|
-5. **存储路径**: 网页内容会自动保存到MinIO的`webpage_talent/`目录下
|
|
|
-6. **数据溯源**: origin_source字段保存了完整的数据来源信息,便于后续追溯
|
|
|
-7. **图片处理**:
|
|
|
- - 支持常见图片格式(JPG、PNG、GIF、WebP)
|
|
|
- - 图片下载失败不会影响其他数据处理
|
|
|
- - 图片文件名会包含人员姓名、时间戳和唯一标识
|
|
|
-8. **人才档案**: talent_profile字段支持存储大量文本信息,建议合理控制内容长度
|
|
|
-9. **自动字段**: origin_source字段由系统自动生成,无需在请求中提供
|
|
|
-10. **向后兼容**: 新增字段都是可选的,现有的API调用不会受到影响
|
|
|
-
|
|
|
----
|
|
|
-
|
|
|
-## 版本信息
|
|
|
-
|
|
|
-- **API版本**: v1.1
|
|
|
-- **文档版本**: 1.1.0
|
|
|
-- **创建日期**: 2025年
|
|
|
-- **最后更新**: 2025年07月10日
|
|
|
-- **更新内容**:
|
|
|
- - 新增 `origin_source` 字段支持
|
|
|
- - 新增 `talent_profile` 字段支持
|
|
|
- - 新增 `pic_url` 字段和图片自动下载功能
|
|
|
- - 更新响应示例和代码示例
|
|
|
- - 增加详细的字段说明和注意事项
|
|
|
-
|
|
|
----
|
|
|
-
|
|
|
-## 联系支持
|
|
|
-
|
|
|
-如果在使用过程中遇到问题,请联系技术支持团队。
|