znpt-backend/doc/regulation_api_test.md

515 lines
10 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 制度模块API测试文档
## 1. 获取制度列表 (流程管理页面)
### 请求信息
- **URL**: `GET /api/regulation?page=1&size=10`
- **Method**: GET
### 请求参数
- `page`: 页码从1开始必填
- `size`: 每页数量(必填)
### 响应格式
```json
{
"status": 200,
"data": {
"records": [
{
"regulationId": "reg001",
"title": "员工考勤管理制度优化提案",
"content": "建议优化考勤管理制度,增加弹性工作时间,提高员工工作积极性...",
"regulationType": "人事制度",
"status": "VOTING",
"publisherId": "2",
"publisherName": "张三",
"publishTime": "2024-01-01T12:00:00",
"effectiveTime": "2024-01-01T12:00:00",
"expireTime": "2024-01-08T12:00:00",
"scope": "全体员工",
"level": "MEDIUM",
"version": "1.0",
"remark": "需要与人事部门协调实施",
"createBy": "admin",
"updateBy": "admin",
"createTime": "2024-01-01 10:00:00",
"updateTime": "2024-01-01 12:00:00",
"page": 1,
"pageSize": 10,
"delFlag": "0",
"voteFor": 15,
"voteAgainst": 3,
"voteAbstain": 2
}
],
"total": 4,
"size": 10,
"current": 1,
"pages": 1
}
}
```
## 2. 创建制度提案
### 请求信息
- **URL**: `POST /api/regulation/proposal`
- **Content-Type**: `application/json`
### 请求参数
```json
{
"title": "员工考勤管理制度优化提案",
"content": "建议优化考勤管理制度,增加弹性工作时间...",
"regulationType": "人事制度",
"scope": "全体员工",
"level": "MEDIUM",
"remark": "需要与人事部门协调实施"
}
```
### 响应格式
```json
{
"status": 200,
"data": {
"regulationId": "reg005",
"title": "员工考勤管理制度优化提案",
"content": "建议优化考勤管理制度,增加弹性工作时间...",
"regulationType": "人事制度",
"status": "DRAFT",
"publisherId": "1",
"publisherName": "当前用户",
"publishTime": "2024-01-25T10:30:00",
"effectiveTime": "2024-01-25T10:30:00",
"expireTime": "2025-01-25T10:30:00",
"scope": "全体员工",
"level": "MEDIUM",
"version": "1.0",
"remark": "需要与人事部门协调实施",
"createBy": "admin",
"updateBy": "admin",
"createTime": "2024-01-25 10:30:00",
"updateTime": "2024-01-25 10:30:00",
"page": 1,
"pageSize": 10,
"delFlag": "0"
}
}
```
## 3. 更新制度提案
### 请求信息
- **URL**: `PUT /api/regulation/proposal/{regulationId}`
- **Content-Type**: `application/json`
### 请求参数
```json
{
"title": "员工考勤管理制度优化提案",
"content": "建议优化考勤管理制度,增加弹性工作时间...",
"regulationType": "人事制度",
"scope": "全体员工",
"level": "MEDIUM",
"remark": "需要与人事部门协调实施"
}
```
### 响应格式
```json
{
"status": 200,
"message": "制度提案更新成功"
}
```
## 4. 删除制度提案
### 请求信息
- **URL**: `DELETE /api/regulation/proposal/{regulationId}`
- **Method**: DELETE
### 响应格式
```json
{
"status": 200,
"data": {
"success": true
}
}
```
## 5. 获取制度详情
### 请求信息
- **URL**: `GET /api/regulation/{regulationId}`
- **Method**: GET
### 响应格式
```json
{
"status": 200,
"data": {
"regulationId": "reg001",
"title": "员工考勤管理制度优化提案",
"content": "建议优化考勤管理制度,增加弹性工作时间...",
"regulationType": "人事制度",
"status": "VOTING",
"publisherId": "1",
"publisherName": "张三",
"publishTime": "2024-01-01T12:00:00",
"effectiveTime": "2024-01-01T12:00:00",
"expireTime": "2024-01-08T12:00:00",
"scope": "全体员工",
"level": "MEDIUM",
"version": "1.0",
"remark": "需要与人事部门协调实施",
"createBy": "admin",
"updateBy": "admin",
"createTime": "2024-01-01 10:00:00",
"updateTime": "2024-01-01 12:00:00",
"page": 1,
"pageSize": 10,
"delFlag": "0",
"voteFor": 15,
"voteAgainst": 3,
"voteAbstain": 2
}
}
```
## 6. 提交投票
### 请求信息
- **URL**: `POST /api/regulation/{regulationId}/vote`
- **Content-Type**: `application/json`
### 请求参数
```json
{
"voteType": "FOR", // FOR: 赞成, AGAINST: 反对, ABSTAIN: 弃权
"reason": "这个提案很有建设性" // 可选
}
```
### 响应格式
```json
{
"status": 200,
"data": {
"success": true
}
}
```
## 7. 获取投票结果
### 请求信息
- **URL**: `GET /api/regulation/{regulationId}/vote-result`
- **Method**: GET
### 响应格式
```json
{
"status": 200,
"data": {
"regulationId": "reg001",
"voteFor": 15,
"voteAgainst": 3,
"voteAbstain": 2,
"totalVotes": 20,
"approvalRate": 0.75
}
}
```
## 8. 发布制度
### 请求信息
- **URL**: `POST /api/regulation/{regulationId}/publish`
- **Method**: POST
### 响应格式
```json
{
"status": 200,
"message": "制度发布成功"
}
```
## 9. 获取已发布制度列表
### 请求信息
- **URL**: `GET /api/regulation/published?page=1&size=10`
- **Method**: GET
### 请求参数
- `page`: 页码默认1
- `size`: 页大小默认10
### 响应格式
```json
{
"status": 200,
"data": {
"records": [
{
"regulationId": "reg001",
"title": "员工考勤管理制度",
"content": "规范员工考勤管理...",
"status": "PUBLISHED",
"publishTime": "2024-01-01T12:00:00",
"confirmStatus": "pending"
}
],
"total": 1,
"size": 10,
"current": 1
}
}
```
## 10. 确认制度知晓
### 请求信息
- **URL**: `POST /api/regulation/{regulationId}/confirm`
- **Content-Type**: `application/json`
### 请求参数
```json
{
"confirmComment": "已阅读并同意遵守该制度"
}
```
### 响应格式
```json
{
"status": 200,
"message": "制度确认成功"
}
```
## 11. 批量确认制度
### 请求信息
- **URL**: `POST /api/regulation/confirm-all`
- **Method**: POST
### 响应格式
```json
{
"status": 200,
"message": "批量确认成功"
}
```
---
# 制度类型管理API
## 1. 获取制度类型列表
### 请求信息
- **URL**: `GET /api/regulation-type?parentId=type_001`
- **Method**: GET
### 请求参数
- `parentId`: 父类型ID可选
### 响应格式
```json
{
"status": 200,
"data": [
{
"typeId": "type_005",
"typeName": "考勤管理",
"typeCode": "ATTENDANCE",
"description": "员工考勤相关制度",
"parentId": "type_001",
"level": 2,
"sortOrder": 1,
"isEnabled": "1",
"icon": "clock-circle",
"color": "#1890ff",
"remark": "考勤管理子类型",
"createTime": "2024-01-01 10:00:00",
"updateTime": "2024-01-01 10:00:00"
}
]
}
```
## 2. 获取制度类型树
### 请求信息
- **URL**: `GET /api/regulation-type/tree`
- **Method**: GET
### 响应格式
```json
{
"status": 200,
"data": [
{
"typeId": "type_001",
"typeName": "人事制度",
"typeCode": "HR",
"description": "人力资源管理相关制度",
"parentId": null,
"level": 1,
"sortOrder": 1,
"isEnabled": "1",
"icon": "user",
"color": "#1890ff",
"children": [
{
"typeId": "type_005",
"typeName": "考勤管理",
"typeCode": "ATTENDANCE",
"description": "员工考勤相关制度",
"parentId": "type_001",
"level": 2,
"sortOrder": 1,
"isEnabled": "1",
"icon": "clock-circle",
"color": "#1890ff"
}
]
}
]
}
```
## 3. 创建制度类型
### 请求信息
- **URL**: `POST /api/regulation-type`
- **Content-Type**: `application/json`
### 请求参数
```json
{
"typeName": "新制度类型",
"typeCode": "NEW_TYPE",
"description": "新制度类型描述",
"parentId": "type_001",
"level": 2,
"sortOrder": 3,
"isEnabled": "1",
"icon": "star",
"color": "#f5222d",
"remark": "新制度类型备注"
}
```
### 响应格式
```json
{
"status": 200,
"message": "制度类型创建成功"
}
```
## 4. 更新制度类型
### 请求信息
- **URL**: `PUT /api/regulation-type/type_001`
- **Content-Type**: `application/json`
### 请求参数
```json
{
"typeName": "更新后的制度类型",
"typeCode": "UPDATED_TYPE",
"description": "更新后的描述",
"icon": "star",
"color": "#f5222d"
}
```
### 响应格式
```json
{
"status": 200,
"message": "制度类型更新成功"
}
```
## 5. 删除制度类型
### 请求信息
- **URL**: `DELETE /api/regulation-type/type_001`
- **Method**: DELETE
### 响应格式
```json
{
"status": 200,
"message": "制度类型删除成功"
}
```
## 6. 获取制度类型详情
### 请求信息
- **URL**: `GET /api/regulation-type/type_001`
- **Method**: GET
### 响应格式
```json
{
"status": 200,
"data": {
"typeId": "type_001",
"typeName": "人事制度",
"typeCode": "HR",
"description": "人力资源管理相关制度",
"parentId": null,
"level": 1,
"sortOrder": 1,
"isEnabled": "1",
"icon": "user",
"color": "#1890ff",
"remark": "人事管理相关制度",
"createTime": "2024-01-01 10:00:00",
"updateTime": "2024-01-01 10:00:00"
}
}
```
## 7. 启用/禁用制度类型
### 请求信息
- **URL**: `PUT /api/regulation-type/type_001/status?isEnabled=0`
- **Method**: PUT
### 请求参数
- `isEnabled`: 是否启用1-启用0-禁用)
### 响应格式
```json
{
"status": 200,
"message": "制度类型禁用成功"
}
```
## 测试步骤
1. **执行建表语句**: 运行 `regulation_tables.sql`
2. **插入测试数据**: 运行 `regulation_test_data.sql`
3. **启动应用**: 确保后端服务正常运行
4. **测试接口**: 使用Postman或其他工具测试上述接口
## 注意事项
1. 所有接口都需要用户登录认证
2. ID字段使用UUID自动生成无需手动设置
3. 创建时间和更新时间会自动设置
4. 创建人和更新人会从当前登录用户获取
5. 制度状态包括DRAFT草稿、VOTING投票中、PUBLISHED已发布、ARCHIVED已归档
6. 投票类型FOR赞成、AGAINST反对、ABSTAIN弃权