|
|
@@ -0,0 +1,741 @@
|
|
|
+# API参考文档
|
|
|
+
|
|
|
+<cite>
|
|
|
+**本文档中引用的文件**
|
|
|
+- [PerformanceItemController.cs](file://wispro.sp.api/Controllers/PerformanceItemController.cs)
|
|
|
+- [AppealController.cs](file://wispro.sp.api/Controllers/AppealController.cs)
|
|
|
+- [OrganizationController.cs](file://wispro.sp.api/Controllers/OrganizationController.cs)
|
|
|
+- [AccountController.cs](file://wispro.sp.api/Controllers/AccountController.cs)
|
|
|
+- [StaffController.cs](file://wispro.sp.api/Controllers/StaffController.cs)
|
|
|
+- [PerformanceItem.cs](file://wospro.sp.entity/PerformanceItem.cs)
|
|
|
+- [AppealRecord.cs](file://wospro.sp.entity/AppealRecord.cs)
|
|
|
+- [Staff.cs](file://wospro.sp.entity/Organization/Staff.cs)
|
|
|
+- [ApiSaveResponse.cs](file://wispro.sp.share/ApiSaveResponse.cs)
|
|
|
+- [ListApiResponse.cs](file://wispro.sp.share/ListApiResponse.cs)
|
|
|
+- [appsettings.json](file://wispro.sp.api/appsettings.json)
|
|
|
+</cite>
|
|
|
+
|
|
|
+## 目录
|
|
|
+1. [简介](#简介)
|
|
|
+2. [认证机制](#认证机制)
|
|
|
+3. [PerformanceItemController API](#performanceitemcontroller-api)
|
|
|
+4. [AppealController API](#appealcontroller-api)
|
|
|
+5. [OrganizationController API](#organizationcontroller-api)
|
|
|
+6. [StaffController API](#staffcontroller-api)
|
|
|
+7. [数据模型](#数据模型)
|
|
|
+8. [错误码](#错误码)
|
|
|
+9. [API使用模式最佳实践](#api使用模式最佳实践)
|
|
|
+
|
|
|
+## 简介
|
|
|
+本API参考文档为小美集团绩效管理系统提供完整的公开API端点说明。文档详细描述了PerformanceItemController、AppealController、OrganizationController和StaffController等核心控制器的HTTP端点,包括URL路径、请求方法、参数、请求体结构、响应格式和状态码。所有数据模型均基于实际代码中的实体类(如PerformanceItem、AppealRecord)定义,确保前端开发者能够准确理解和使用API。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [PerformanceItemController.cs](file://wispro.sp.api/Controllers/PerformanceItemController.cs#L30-L36)
|
|
|
+- [AppealController.cs](file://wispro.sp.api/Controllers/AppealController.cs#L27-L33)
|
|
|
+- [OrganizationController.cs](file://wispro.sp.api/Controllers/OrganizationController.cs#L12-L18)
|
|
|
+
|
|
|
+## 认证机制
|
|
|
+本系统使用JWT(JSON Web Token)进行API认证。所有需要认证的API端点都标记有`[Authorize]`属性。
|
|
|
+
|
|
|
+### JWT认证流程
|
|
|
+1. **登录获取Token**:用户通过`/api/account/login`端点提交用户名和密码,成功后返回包含JWT的`userToken`对象。
|
|
|
+2. **携带Token请求**:后续请求需要在HTTP头中包含`Authorization: Bearer <token>`。
|
|
|
+3. **Token内容**:JWT包含用户ID、姓名、邮箱和角色信息,有效期为5小时。
|
|
|
+
|
|
|
+### Token结构
|
|
|
+```json
|
|
|
+{
|
|
|
+ "Id": "123",
|
|
|
+ "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name": "张三",
|
|
|
+ "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress": "zhangsan@company.com",
|
|
|
+ "http://schemas.microsoft.com/ws/2008/06/identity/claims/role": "[1]-[2]",
|
|
|
+ "exp": 1700000000,
|
|
|
+ "iss": "https://staffperformance.com",
|
|
|
+ "aud": "https://staffperformance.com"
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+### 配置信息
|
|
|
+JWT配置在`appsettings.json`中定义:
|
|
|
+```json
|
|
|
+{
|
|
|
+ "jwt": {
|
|
|
+ "Key": "your-secret-key-here",
|
|
|
+ "Issuer": "https://staffperformance.com",
|
|
|
+ "Audience": "https://staffperformance.com"
|
|
|
+ }
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [AccountController.cs](file://wispro.sp.api/Controllers/AccountController.cs#L21-L23)
|
|
|
+- [AccountController.cs](file://wispro.sp.api/Controllers/AccountController.cs#L158-L202)
|
|
|
+- [appsettings.json](file://wispro.sp.api/appsettings.json)
|
|
|
+
|
|
|
+## PerformanceItemController API
|
|
|
+PerformanceItemController负责处理绩效事项相关的所有操作,包括创建、查询、更新绩效记录以及生成统计报告。
|
|
|
+
|
|
|
+### 获取绩效记录列表
|
|
|
+获取当前用户有权限查看的绩效记录列表。
|
|
|
+
|
|
|
+```mermaid
|
|
|
+sequenceDiagram
|
|
|
+participant Client
|
|
|
+participant Controller
|
|
|
+participant Context
|
|
|
+Client->>Controller : GET /api/PerformanceItem/Query?pageIndex=1&pageSize=10
|
|
|
+Controller->>Context : 查询绩效记录
|
|
|
+Context-->>Controller : 返回记录列表
|
|
|
+Controller->>Client : 返回ListApiResponse<PerformanceItem>
|
|
|
+```
|
|
|
+
|
|
|
+**Diagram sources**
|
|
|
+- [PerformanceItemController.cs](file://wispro.sp.api/Controllers/PerformanceItemController.cs#L370-L398)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/PerformanceItem/Query`
|
|
|
+- **请求方法**: `GET`
|
|
|
+- **认证**: 是
|
|
|
+- **请求参数**:
|
|
|
+ - `pageIndex` (int, 必需): 页码,从1开始
|
|
|
+ - `pageSize` (int, 必需): 每页记录数
|
|
|
+- **响应格式**: `ListApiResponse<PerformanceItem>`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 请求成功
|
|
|
+ - `401 Unauthorized`: 未认证
|
|
|
+
|
|
|
+### 获取指定绩效记录
|
|
|
+根据ID获取单个绩效记录的详细信息。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [PerformanceItemController.cs](file://wispro.sp.api/Controllers/PerformanceItemController.cs#L402-L421)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/PerformanceItem/Get`
|
|
|
+- **请求方法**: `GET`
|
|
|
+- **认证**: 是
|
|
|
+- **请求参数**:
|
|
|
+ - `Id` (int, 必需): 绩效记录ID
|
|
|
+- **响应格式**: `PerformanceItem`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 请求成功
|
|
|
+ - `401 Unauthorized`: 未认证
|
|
|
+
|
|
|
+### 创建绩效记录
|
|
|
+创建新的绩效记录。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [PerformanceItemController.cs](file://wispro.sp.api/Controllers/PerformanceItemController.cs#L105-L262)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/PerformanceItem/New`
|
|
|
+- **请求方法**: `POST`
|
|
|
+- **认证**: 是
|
|
|
+- **请求体**: `PerformanceItem` 对象
|
|
|
+- **响应格式**: `ApiSaveResponse`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 创建成功
|
|
|
+ - `401 Unauthorized`: 未认证
|
|
|
+ - `500 Internal Server Error`: 创建失败
|
|
|
+
|
|
|
+### 更新绩效记录字段
|
|
|
+批量更新绩效记录的指定字段值。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [PerformanceItemController.cs](file://wispro.sp.api/Controllers/PerformanceItemController.cs#L272-L368)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/PerformanceItem/UpdateFieldValue`
|
|
|
+- **请求方法**: `POST`
|
|
|
+- **认证**: 是
|
|
|
+- **请求参数**:
|
|
|
+ - `id` (int, 必需): 绩效记录ID
|
|
|
+ - `field` (string, 必需): 字段名,多个字段用"|"分隔
|
|
|
+ - `value` (string, 可选): 字段值,多个值用"|"分隔
|
|
|
+- **响应格式**: `ApiSaveResponse`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 更新成功
|
|
|
+ - `400 Bad Request`: 参数错误
|
|
|
+ - `401 Unauthorized`: 未认证
|
|
|
+
|
|
|
+### 获取个人绩效列表
|
|
|
+获取指定用户的绩效清单。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [PerformanceItemController.cs](file://wispro.sp.api/Controllers/PerformanceItemController.cs#L429-L461)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/PerformanceItem/GetMyList`
|
|
|
+- **请求方法**: `GET`
|
|
|
+- **认证**: 是
|
|
|
+- **请求参数**:
|
|
|
+ - `userid` (int, 必需): 用户ID
|
|
|
+ - `type` (int, 必需): 获取类型(0:处理中;1:所有;4:已归档)
|
|
|
+ - `pageIndex` (int, 可选): 页码,默认为1
|
|
|
+ - `pageSize` (int, 可选): 每页记录数,默认为10
|
|
|
+- **响应格式**: `ListApiResponse<PerformanceItem>`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 请求成功
|
|
|
+ - `401 Unauthorized`: 未认证
|
|
|
+
|
|
|
+### 生成统计报告
|
|
|
+为指定年月生成绩效统计报告。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [PerformanceItemController.cs](file://wispro.sp.api/Controllers/PerformanceItemController.cs#L795-L827)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/PerformanceItem/GetStaticsReport`
|
|
|
+- **请求方法**: `GET`
|
|
|
+- **认证**: 是
|
|
|
+- **请求参数**:
|
|
|
+ - `Year` (int, 必需): 年份
|
|
|
+ - `Month` (int, 必需): 月份
|
|
|
+- **响应格式**: `FileProcessTask`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 报告生成任务已创建
|
|
|
+ - `401 Unauthorized`: 未认证
|
|
|
+
|
|
|
+## AppealController API
|
|
|
+AppealController处理申诉相关的所有操作,包括创建申诉、审核申诉和查询申诉记录。
|
|
|
+
|
|
|
+### 获取申诉类型列表
|
|
|
+获取系统支持的所有申诉类型。
|
|
|
+
|
|
|
+```mermaid
|
|
|
+sequenceDiagram
|
|
|
+participant Client
|
|
|
+participant Controller
|
|
|
+participant Context
|
|
|
+Client->>Controller : GET /api/Appeal/GetAppealTypes
|
|
|
+Controller->>Context : 查询申诉类型
|
|
|
+Context-->>Controller : 返回申诉类型列表
|
|
|
+Controller->>Client : 返回List<AppealType>
|
|
|
+```
|
|
|
+
|
|
|
+**Diagram sources**
|
|
|
+- [AppealController.cs](file://wispro.sp.api/Controllers/AppealController.cs#L43-L46)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/Appeal/GetAppealTypes`
|
|
|
+- **请求方法**: `GET`
|
|
|
+- **认证**: 否
|
|
|
+- **响应格式**: `List<AppealType>`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 请求成功
|
|
|
+
|
|
|
+### 创建申诉
|
|
|
+创建新的申诉流程。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [AppealController.cs](file://wispro.sp.api/Controllers/AppealController.cs#L308-L387)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/Appeal/CreateAppeal`
|
|
|
+- **请求方法**: `POST`
|
|
|
+- **认证**: 否
|
|
|
+- **请求参数**:
|
|
|
+ - `ItemId` (int, 必需): 绩效记录ID
|
|
|
+ - `typeid` (int, 必需): 申诉类型ID
|
|
|
+ - `reviewerId` (int, 必需): 审核人ID
|
|
|
+- **请求体**: `AppealObject` 对象
|
|
|
+- **响应格式**: `ApiSaveResponse`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 申诉创建成功
|
|
|
+ - `500 Internal Server Error`: 创建失败
|
|
|
+
|
|
|
+### 审核申诉
|
|
|
+审核指定的申诉记录。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [AppealController.cs](file://wispro.sp.api/Controllers/AppealController.cs#L390-L497)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/Appeal/ReviewerAppeal`
|
|
|
+- **请求方法**: `POST`
|
|
|
+- **认证**: 否
|
|
|
+- **请求参数**:
|
|
|
+ - `appealRecordId` (int, 必需): 申诉记录ID
|
|
|
+- **请求体**: `AppealObject` 对象
|
|
|
+- **响应格式**: `ApiSaveResponse`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 审核成功
|
|
|
+ - `400 Bad Request`: 无效的申诉记录
|
|
|
+ - `500 Internal Server Error`: 审核失败
|
|
|
+
|
|
|
+### 查询申诉记录
|
|
|
+根据过滤条件查询申诉记录。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [AppealController.cs](file://wispro.sp.api/Controllers/AppealController.cs#L784-L842)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/Appeal/QueryByFilter`
|
|
|
+- **请求方法**: `POST`
|
|
|
+- **认证**: 否
|
|
|
+- **请求体**: `AppealRecordFilter` 对象
|
|
|
+- **响应格式**: `List<AppealRecord>`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 请求成功
|
|
|
+
|
|
|
+### 获取申诉记录详情
|
|
|
+获取指定申诉记录的详细信息。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [AppealController.cs](file://wispro.sp.api/Controllers/AppealController.cs#L844-L852)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/Appeal/GetAppealRecord`
|
|
|
+- **请求方法**: `GET`
|
|
|
+- **认证**: 否
|
|
|
+- **请求参数**:
|
|
|
+ - `Id` (int, 必需): 申诉记录ID
|
|
|
+- **响应格式**: `AppealRecord`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 请求成功
|
|
|
+
|
|
|
+## OrganizationController API
|
|
|
+OrganizationController处理组织架构相关的操作,包括部门、职位和客户管理。
|
|
|
+
|
|
|
+### 保存部门信息
|
|
|
+创建或更新部门信息。
|
|
|
+
|
|
|
+```mermaid
|
|
|
+flowchart TD
|
|
|
+Start([开始]) --> ValidateInput["验证输入参数"]
|
|
|
+ValidateInput --> InputValid{"参数有效?"}
|
|
|
+InputValid --> |否| ReturnError["返回错误"]
|
|
|
+InputValid --> |是| CheckExist["检查部门是否存在"]
|
|
|
+CheckExist --> IsNew{"新部门?"}
|
|
|
+IsNew --> |是| SetOrder["设置排序号"]
|
|
|
+IsNew --> |否| UpdateDept["更新现有部门"]
|
|
|
+SetOrder --> SaveDept["保存部门"]
|
|
|
+UpdateDept --> SaveDept
|
|
|
+SaveDept --> End([结束])
|
|
|
+```
|
|
|
+
|
|
|
+**Diagram sources**
|
|
|
+- [OrganizationController.cs](file://wispro.sp.api/Controllers/OrganizationController.cs#L27-L141)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/Organization/SaveDept`
|
|
|
+- **请求方法**: `POST`
|
|
|
+- **认证**: 是
|
|
|
+- **请求体**: `Department` 对象
|
|
|
+- **响应格式**: `Department`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 保存成功
|
|
|
+ - `401 Unauthorized`: 未认证
|
|
|
+
|
|
|
+### 获取部门列表
|
|
|
+获取所有部门的列表。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [OrganizationController.cs](file://wispro.sp.api/Controllers/OrganizationController.cs#L145-L148)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/Organization/GetDepartments`
|
|
|
+- **请求方法**: `GET`
|
|
|
+- **认证**: 是
|
|
|
+- **响应格式**: `List<Department>`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 请求成功
|
|
|
+ - `401 Unauthorized`: 未认证
|
|
|
+
|
|
|
+### 删除部门
|
|
|
+删除指定的部门。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [OrganizationController.cs](file://wispro.sp.api/Controllers/OrganizationController.cs#L151-L164)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/Organization/DeleteDept`
|
|
|
+- **请求方法**: `GET`
|
|
|
+- **认证**: 是
|
|
|
+- **请求参数**:
|
|
|
+ - `Id` (int, 必需): 部门ID
|
|
|
+- **响应格式**: `bool`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 删除成功
|
|
|
+ - `401 Unauthorized`: 未认证
|
|
|
+ - `500 Internal Server Error`: 删除失败
|
|
|
+
|
|
|
+### 获取职位列表
|
|
|
+获取指定部门的职位列表。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [OrganizationController.cs](file://wispro.sp.api/Controllers/OrganizationController.cs#L167-L180)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/Organization/GetPositions`
|
|
|
+- **请求方法**: `GET`
|
|
|
+- **认证**: 是
|
|
|
+- **请求参数**:
|
|
|
+ - `deptId` (int?, 可选): 部门ID,为空时返回所有职位
|
|
|
+- **响应格式**: `List<Position>`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 请求成功
|
|
|
+ - `401 Unauthorized`: 未认证
|
|
|
+
|
|
|
+### 保存客户信息
|
|
|
+创建或更新客户信息。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [OrganizationController.cs](file://wispro.sp.api/Controllers/OrganizationController.cs#L206-L304)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/Organization/SaveCustomer`
|
|
|
+- **请求方法**: `POST`
|
|
|
+- **认证**: 是
|
|
|
+- **请求体**: `Customer` 对象
|
|
|
+- **响应格式**: `ApiSaveResponse`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 保存成功
|
|
|
+ - `401 Unauthorized`: 未认证
|
|
|
+
|
|
|
+## StaffController API
|
|
|
+StaffController处理员工相关的操作,包括员工信息管理和查询。
|
|
|
+
|
|
|
+### 获取所有员工列表
|
|
|
+获取系统中所有员工的列表。
|
|
|
+
|
|
|
+```mermaid
|
|
|
+sequenceDiagram
|
|
|
+participant Client
|
|
|
+participant Controller
|
|
|
+participant Context
|
|
|
+Client->>Controller : GET /api/Staff/GetAll
|
|
|
+Controller->>Context : 查询员工列表
|
|
|
+Context-->>Controller : 返回员工列表
|
|
|
+Controller->>Client : 返回List<Staff>
|
|
|
+```
|
|
|
+
|
|
|
+**Diagram sources**
|
|
|
+- [StaffController.cs](file://wispro.sp.api/Controllers/StaffController.cs#L31-L34)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/Staff/GetAll`
|
|
|
+- **请求方法**: `GET`
|
|
|
+- **认证**: 是
|
|
|
+- **响应格式**: `List<Staff>`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 请求成功
|
|
|
+ - `401 Unauthorized`: 未认证
|
|
|
+
|
|
|
+### 获取指定员工
|
|
|
+根据ID获取员工的详细信息。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [StaffController.cs](file://wispro.sp.api/Controllers/StaffController.cs#L238-L241)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/Staff/GetUser`
|
|
|
+- **请求方法**: `GET`
|
|
|
+- **认证**: 是
|
|
|
+- **请求参数**:
|
|
|
+ - `Id` (int, 必需): 员工ID
|
|
|
+- **响应格式**: `Staff`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 请求成功
|
|
|
+ - `401 Unauthorized`: 未认证
|
|
|
+
|
|
|
+### 查询员工列表
|
|
|
+分页查询员工列表。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [StaffController.cs](file://wispro.sp.api/Controllers/StaffController.cs#L247-L257)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/Staff/Query`
|
|
|
+- **请求方法**: `GET`
|
|
|
+- **认证**: 是
|
|
|
+- **请求参数**:
|
|
|
+ - `pageIndex` (int, 必需): 页码
|
|
|
+ - `pageSize` (int, 必需): 每页记录数
|
|
|
+- **响应格式**: `ListApiResponse<Staff>`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 请求成功
|
|
|
+ - `401 Unauthorized`: 未认证
|
|
|
+
|
|
|
+### 保存员工信息
|
|
|
+创建或更新员工信息。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [StaffController.cs](file://wispro.sp.api/Controllers/StaffController.cs#L386-L503)
|
|
|
+
|
|
|
+#### 端点信息
|
|
|
+- **URL路径**: `/api/Staff/SaveUser`
|
|
|
+- **请求方法**: `POST`
|
|
|
+- **认证**: 是
|
|
|
+- **请求体**: `SaveUserObject` 对象
|
|
|
+- **响应格式**: `ApiSaveResponse`
|
|
|
+- **HTTP状态码**:
|
|
|
+ - `200 OK`: 保存成功
|
|
|
+ - `401 Unauthorized`: 未认证
|
|
|
+ - `500 Internal Server Error`: 保存失败
|
|
|
+
|
|
|
+## 数据模型
|
|
|
+本节定义API中使用的主要数据模型,基于实际代码中的实体类。
|
|
|
+
|
|
|
+### PerformanceItem (绩效事项)
|
|
|
+表示一个绩效事项的完整信息。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [PerformanceItem.cs](file://wospro.sp.entity/PerformanceItem.cs#L14-L343)
|
|
|
+
|
|
|
+#### 属性定义
|
|
|
+| 属性名 | 类型 | 描述 |
|
|
|
+|-------|------|------|
|
|
|
+| Id | int | 编号 |
|
|
|
+| CaseNo | string | 我方文号 |
|
|
|
+| ApplicationType | string | 申请类型 |
|
|
|
+| BusinessType | string | 业务类型 |
|
|
|
+| AgentFeedbackMemo | string | 代理人反馈Memo |
|
|
|
+| DoItem | string | 处理事项 |
|
|
|
+| CaseStage | string | 案件阶段 |
|
|
|
+| CaseCoefficient | string | 案件系数 |
|
|
|
+| DoItemCoefficient | string | 处理事项系数 |
|
|
|
+| PreOastaffId | int? | 前一次OA处理人Id |
|
|
|
+| ReviewerId | int? | 核稿人Id |
|
|
|
+| ExternalHandlerId | int? | 对外处理人Id |
|
|
|
+| CustomerId | int? | 客户Id |
|
|
|
+| ApplicationName | string | 申请人 |
|
|
|
+| FinishedDate | DateTime? | 处理事项完成日 |
|
|
|
+| FinalizationDate | DateTime? | 定稿日 |
|
|
|
+| ReturnDate | DateTime? | 返稿日 |
|
|
|
+| CaseType | string | 案件类型 |
|
|
|
+| CaseState | string | 案件状态 |
|
|
|
+| DoItemMemo | string | 处理事项备注 |
|
|
|
+| DoItemState | string | 处理状态 |
|
|
|
+| CaseName | string | 案件名称 |
|
|
|
+| CustomerLimitDate | DateTime? | 客户期限 |
|
|
|
+| EntrustingDate | DateTime? | 委托日期 |
|
|
|
+| InternalDate | DateTime? | 内部期限 |
|
|
|
+| FirstDraftDate | DateTime? | 初稿日 |
|
|
|
+| OverDueMemo | string | 备注(发文严重超期是否属客观原因) |
|
|
|
+| BasePoint | double? | 基础点数 |
|
|
|
+| Status | int? | 绩效核算状态 |
|
|
|
+| CaseMemo | string | 案件备注 |
|
|
|
+| WordCount | int? | 按翻译字数计算设定的字数值 |
|
|
|
+| ReturnCasseNo | string | 撤回案件编号 |
|
|
|
+| Country | string | 国家或地区 |
|
|
|
+| Type | string | 绩效类型 |
|
|
|
+| Customer | Customer | 客户对象 |
|
|
|
+| PreOastaff | Staff | 前一次OA处理人 |
|
|
|
+| ItemStaffs | ICollection<ItemStaff> | 处理人员集合 |
|
|
|
+| AllocationRatios | ICollection<AllocationRatio> | 分配比例集合 |
|
|
|
+| Reviewer | Staff | 核稿人 |
|
|
|
+| ExternalHandler | Staff | 客户处理人 |
|
|
|
+| WorkflowUserId | int? | 流程负责人Id |
|
|
|
+| WorkflowUser | Staff | 流程负责人 |
|
|
|
+| CalMonth | CalMonth | 绩效月份 |
|
|
|
+| CalMonthId | int | 绩效月份ID |
|
|
|
+| FinallyDelayDays | int? | 最终延迟天数 |
|
|
|
+
|
|
|
+### AppealRecord (申诉记录)
|
|
|
+表示一个申诉记录的完整信息。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [AppealRecord.cs](file://wospro.sp.entity/AppealRecord.cs#L9-L46)
|
|
|
+
|
|
|
+#### 属性定义
|
|
|
+| 属性名 | 类型 | 描述 |
|
|
|
+|-------|------|------|
|
|
|
+| Id | int | 编号 |
|
|
|
+| Creater | Staff | 创建人 |
|
|
|
+| CreaterId | int | 创建人ID |
|
|
|
+| CreateTime | DateTime | 创建时间 |
|
|
|
+| AttachFiles | List<AttachFile> | 附件文件列表 |
|
|
|
+| Reason | string | 申诉原因 |
|
|
|
+| State | int | 申诉状态(0:待审核;1:审核完成) |
|
|
|
+| Reviewer | Staff | 审核人 |
|
|
|
+| ReviewerId | int? | 审核人ID |
|
|
|
+| ReviewerMemo | string | 审核人备注 |
|
|
|
+| ReviewTime | DateTime? | 审核时间 |
|
|
|
+| Type | AppealType | 申诉类型 |
|
|
|
+| TypeId | int | 申诉类型ID |
|
|
|
+| ItemId | int? | 关联的绩效记录ID |
|
|
|
+| Item | PerformanceItem | 关联的绩效记录 |
|
|
|
+
|
|
|
+### Staff (员工)
|
|
|
+表示一个员工的完整信息。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [Staff.cs](file://wospro.sp.entity/Organization/Staff.cs#L11-L145)
|
|
|
+
|
|
|
+#### 属性定义
|
|
|
+| 属性名 | 类型 | 描述 |
|
|
|
+|-------|------|------|
|
|
|
+| Id | int | 编号 |
|
|
|
+| Account | string | 登录账号 |
|
|
|
+| Password | string | 登录密码 |
|
|
|
+| Name | string | 姓名 |
|
|
|
+| Sex | string | 性别 |
|
|
|
+| Tel | string | 电话号码 |
|
|
|
+| Mobile | string | 手机号码 |
|
|
|
+| IsOnJob | bool | 是否在职 |
|
|
|
+| Status | string | 在岗状态 |
|
|
|
+| IsCalPerformsnce | bool | 是否核算绩效 |
|
|
|
+| StaffGradeId | int? | 代理人等级Id |
|
|
|
+| Department | string | 部门 |
|
|
|
+| WorkPlace | string | 工作地 |
|
|
|
+| EntyDate | DateTime? | 入职日期 |
|
|
|
+| RegularDate | DateTime? | 转正日期 |
|
|
|
+| IsGradeAssess | bool | 是否参与等级考核 |
|
|
|
+| Mail | string | 邮箱 |
|
|
|
+| Memo | string | 备注 |
|
|
|
+| StaffGrade | StaffGrade | 代理人等级 |
|
|
|
+| Customers | ICollection<Customer> | 负责客户 |
|
|
|
+| ItemStaffs | ICollection<ItemStaff> | 处理的绩效事项 |
|
|
|
+| AllocationRatios | ICollection<AllocationRatio> | 分配比例 |
|
|
|
+| ReviewerItems | ICollection<PerformanceItem> | 核稿记录 |
|
|
|
+| ExternalHandlerItems | ICollection<PerformanceItem> | 作为对外处理人的案件清单 |
|
|
|
+| Positions | ICollection<DepartmentPosition> | 职位 |
|
|
|
+
|
|
|
+### ApiSaveResponse (API保存响应)
|
|
|
+通用的API保存操作响应模型。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [ApiSaveResponse.cs](file://wispro.sp.share/ApiSaveResponse.cs#L9-L14)
|
|
|
+
|
|
|
+#### 属性定义
|
|
|
+| 属性名 | 类型 | 描述 |
|
|
|
+|-------|------|------|
|
|
|
+| Success | bool | 操作是否成功 |
|
|
|
+| ErrorMessage | string | 错误信息(操作失败时) |
|
|
|
+
|
|
|
+### ListApiResponse<T> (列表API响应)
|
|
|
+通用的列表API响应模型。
|
|
|
+
|
|
|
+**Section sources**
|
|
|
+- [ListApiResponse.cs](file://wispro.sp.share/ListApiResponse.cs#L10-L15)
|
|
|
+
|
|
|
+#### 属性定义
|
|
|
+| 属性名 | 类型 | 描述 |
|
|
|
+|-------|------|------|
|
|
|
+| Results | List<T> | 结果列表 |
|
|
|
+| TotalCount | int | 总记录数 |
|
|
|
+
|
|
|
+## 错误码
|
|
|
+本系统使用统一的错误处理机制,通过`ApiSaveResponse`对象返回错误信息。
|
|
|
+
|
|
|
+### 通用错误码
|
|
|
+| 错误码 | 描述 | 示例场景 |
|
|
|
+|-------|------|---------|
|
|
|
+| 401 | Unauthorized | 用户未登录或Token过期 |
|
|
|
+| 400 | Bad Request | 请求参数格式错误 |
|
|
|
+| 500 | Internal Server Error | 服务器内部错误 |
|
|
|
+| 404 | Not Found | 请求的资源不存在 |
|
|
|
+
|
|
|
+### 业务错误码
|
|
|
+| 错误码 | 描述 | 示例场景 |
|
|
|
+|-------|------|---------|
|
|
|
+| APPEAL_CREATE_FAILED | 申诉创建失败 | 创建申诉时发生数据库错误 |
|
|
|
+| INVALID_ITEM_ID | 无效的绩效记录ID | 指定的绩效记录不存在 |
|
|
|
+| ITEM_ALREADY_ARCHIVED | 绩效记录已归档 | 试图修改已归档的绩效记录 |
|
|
|
+| USER_NOT_FOUND | 用户不存在 | 指定的用户ID不存在 |
|
|
|
+| DEPARTMENT_DELETE_FAILED | 部门删除失败 | 部门删除时发生数据库错误 |
|
|
|
+
|
|
|
+## API使用模式最佳实践
|
|
|
+为前端开发者提供API使用的最佳实践建议。
|
|
|
+
|
|
|
+### 认证管理
|
|
|
+```mermaid
|
|
|
+stateDiagram-v2
|
|
|
+[*] --> Idle
|
|
|
+Idle --> Authenticating : "用户登录"
|
|
|
+Authenticating --> Authenticated : "获取Token"
|
|
|
+Authenticated --> Idle : "Token过期"
|
|
|
+Authenticated --> Error : "认证失败"
|
|
|
+Error --> Idle : "重新登录"
|
|
|
+```
|
|
|
+
|
|
|
+**Diagram sources**
|
|
|
+- [AccountController.cs](file://wispro.sp.api/Controllers/AccountController.cs#L35-L55)
|
|
|
+
|
|
|
+#### 最佳实践
|
|
|
+1. **Token存储**:使用`localStorage`或`sessionStorage`安全存储JWT Token。
|
|
|
+2. **Token刷新**:在Token即将过期时(如剩余1小时),自动调用登录接口刷新Token。
|
|
|
+3. **错误处理**:当收到401状态码时,清除本地Token并重定向到登录页面。
|
|
|
+
|
|
|
+### 请求示例
|
|
|
+#### curl命令示例
|
|
|
+```bash
|
|
|
+# 登录获取Token
|
|
|
+curl -X POST "https://api.staffperformance.com/api/account/login" \
|
|
|
+ -H "Content-Type: application/json" \
|
|
|
+ -d '{"Name": "zhangsan", "Password": "123456"}'
|
|
|
+
|
|
|
+# 获取绩效记录列表(携带Token)
|
|
|
+curl -X GET "https://api.staffperformance.com/api/PerformanceItem/Query?pageIndex=1&pageSize=10" \
|
|
|
+ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
|
|
|
+```
|
|
|
+
|
|
|
+#### C#客户端调用示例
|
|
|
+```csharp
|
|
|
+using System;
|
|
|
+using System.Net.Http;
|
|
|
+using System.Text;
|
|
|
+using System.Text.Json;
|
|
|
+using System.Threading.Tasks;
|
|
|
+
|
|
|
+public class PerformanceApiClient
|
|
|
+{
|
|
|
+ private readonly HttpClient _httpClient;
|
|
|
+ private string _token;
|
|
|
+
|
|
|
+ public PerformanceApiClient()
|
|
|
+ {
|
|
|
+ _httpClient = new HttpClient();
|
|
|
+ _httpClient.BaseAddress = new Uri("https://api.staffperformance.com/");
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task<bool> LoginAsync(string username, string password)
|
|
|
+ {
|
|
|
+ var loginData = new { Name = username, Password = password };
|
|
|
+ var content = new StringContent(
|
|
|
+ JsonSerializer.Serialize(loginData),
|
|
|
+ Encoding.UTF8,
|
|
|
+ "application/json"
|
|
|
+ );
|
|
|
+
|
|
|
+ var response = await _httpClient.PostAsync("api/account/login", content);
|
|
|
+ if (response.IsSuccessStatusCode)
|
|
|
+ {
|
|
|
+ var responseContent = await response.Content.ReadAsStringAsync();
|
|
|
+ var tokenResponse = JsonSerializer.Deserialize<UserToken>(responseContent);
|
|
|
+ _token = tokenResponse.Token;
|
|
|
+ _httpClient.DefaultRequestHeaders.Authorization =
|
|
|
+ new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _token);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task<ListApiResponse<PerformanceItem>> GetPerformanceItemsAsync(int pageIndex, int pageSize)
|
|
|
+ {
|
|
|
+ var response = await _httpClient.GetAsync($"api/PerformanceItem/Query?pageIndex={pageIndex}&pageSize={pageSize}");
|
|
|
+ if (response.IsSuccessStatusCode)
|
|
|
+ {
|
|
|
+ var content = await response.Content.ReadAsStringAsync();
|
|
|
+ return JsonSerializer.Deserialize<ListApiResponse<PerformanceItem>>(content);
|
|
|
+ }
|
|
|
+ throw new Exception($"API调用失败: {response.StatusCode}");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 使用示例
|
|
|
+var client = new PerformanceApiClient();
|
|
|
+if (await client.LoginAsync("zhangsan", "123456"))
|
|
|
+{
|
|
|
+ var items = await client.GetPerformanceItemsAsync(1, 10);
|
|
|
+ Console.WriteLine($"获取到 {items.TotalCount} 条记录");
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+### 前端开发最佳实践
|
|
|
+1. **错误处理**:统一处理API错误,向用户显示友好的错误信息。
|
|
|
+2. **加载状态**:在API请求期间显示加载指示器,提升用户体验。
|
|
|
+3. **缓存策略**:对不经常变化的数据(如部门列表、员工列表)进行客户端缓存。
|
|
|
+4. **分页处理**:对于列表数据,实现分页加载,避免一次性加载过多数据。
|
|
|
+5. **数据验证**:在提交表单前进行前端验证,减少无效的API调用。
|