znpt-backend/doc/regulation_api_test.md

323 lines
6.7 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",
"createBy": "张三",
"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",
"createBy": "当前用户",
"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",
"createBy": "张三",
"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,
"data": {
"success": true,
"confirmedCount": 5
}
}
```
## 测试步骤
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弃权