feat: add leave request draft workflow foundation

This commit is contained in:
selfrelease
2026-07-18 08:14:05 +08:00
parent bbb09ed56f
commit 7107c7cc82
14 changed files with 675 additions and 13 deletions
+90 -12
View File
@@ -1,7 +1,7 @@
openapi: 3.1.0
info:
title: AIOA API
version: 0.1.0
version: 0.2.0
servers:
- url: /api/v1
paths:
@@ -19,9 +19,24 @@ paths:
"401":
$ref: "#/components/responses/Unauthorized"
/leave-requests:
get:
operationId: listOwnLeaveRequests
summary: 查询当前用户的请假申请
responses:
"200":
description: 申请列表
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/LeaveRequest"
"401":
$ref: "#/components/responses/Unauthorized"
/leave-requests/drafts:
post:
operationId: createLeaveRequest
summary: 创建并发起请假申
operationId: createLeaveRequestDraft
summary: 创建请假草稿
parameters:
- $ref: "#/components/parameters/IdempotencyKey"
requestBody:
@@ -29,7 +44,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/CreateLeaveRequest"
$ref: "#/components/schemas/SaveLeaveDraft"
responses:
"201":
description: 已创建
@@ -43,6 +58,52 @@ paths:
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
"409":
$ref: "#/components/responses/Conflict"
/leave-requests/{id}:
parameters:
- name: id
in: path
required: true
schema: { type: string, format: uuid }
get:
operationId: getOwnLeaveRequest
summary: 查询当前用户的单条请假申请
responses:
"200":
description: 请假申请
content:
application/json:
schema:
$ref: "#/components/schemas/LeaveRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
put:
operationId: updateLeaveRequestDraft
summary: 修改当前用户的请假草稿
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/SaveLeaveDraft"
responses:
"200":
description: 已修改
content:
application/json:
schema:
$ref: "#/components/schemas/LeaveRequest"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
"409":
$ref: "#/components/responses/Conflict"
components:
parameters:
IdempotencyKey:
@@ -72,6 +133,18 @@ components:
application/problem+json:
schema:
$ref: "#/components/schemas/Problem"
NotFound:
description: 资源不存在或当前用户不可见
content:
application/problem+json:
schema:
$ref: "#/components/schemas/Problem"
Conflict:
description: 幂等键、状态或乐观锁冲突
content:
application/problem+json:
schema:
$ref: "#/components/schemas/Problem"
schemas:
CurrentUser:
type: object
@@ -102,9 +175,9 @@ components:
properties:
id: { type: string, format: uuid }
name: { type: string }
CreateLeaveRequest:
SaveLeaveDraft:
type: object
required: [type, startsAt, endsAt, reason]
required: [type, startsAt, endsAt, reason, version]
properties:
type:
type: string
@@ -112,20 +185,25 @@ components:
startsAt: { type: string, format: date-time }
endsAt: { type: string, format: date-time }
reason: { type: string, minLength: 1, maxLength: 2000 }
attachmentIds:
type: array
maxItems: 10
items: { type: string, format: uuid }
version: { type: integer, format: int64, minimum: 0 }
LeaveRequest:
type: object
required: [id, status, version, createdAt]
required: [id, applicantId, type, startsAt, endsAt, reason, status, version, createdAt, updatedAt]
properties:
id: { type: string, format: uuid }
applicantId: { type: string, format: uuid }
type:
type: string
enum: [PERSONAL, SICK, ANNUAL]
startsAt: { type: string, format: date-time }
endsAt: { type: string, format: date-time }
reason: { type: string }
status:
type: string
enum: [PENDING, APPROVED, REJECTED, WITHDRAWN]
enum: [DRAFT, PENDING, APPROVED, REJECTED, WITHDRAWN]
version: { type: integer, minimum: 0 }
createdAt: { type: string, format: date-time }
updatedAt: { type: string, format: date-time }
Problem:
type: object
required: [type, title, status, code, traceId]