feat(verification): 教練審核流程完整版——狀態機/證照送審/Admin 裁決/通知
Run Tests / test (pull_request) Successful in 2m3s

實作 openspec change provider-verification-workflow(25/25 tasks):
- is_verified 升級為 verification_status 四狀態機(unsubmitted/pending/
  approved/rejected),migration 自動轉換既有資料,API 以 accessor 保留
  is_verified 相容輸出
- 教練端:證照上傳(≤3 張、複用 CompressesImages)、送審、駁回原因
  顯示與重送(/coach/verification 新頁面)
- Admin 端:審核佇列、通過/駁回(原因必填)、撤銷 approved;移除
  toggle-verified 端點(防繞過狀態機);裁決後 flush 課程快取
- 通知:審核通過/駁回(站內+Email,駁回含原因)
- 可見性與預約入口改判 approved(行為等價)
- 測試 +18(ProviderVerificationTest 10、AdminVerificationTest 8),
  既有 4 個測試檔 helper 遷移;Swagger 同步
- 規格同步:provider-verification 全面改寫、admin-user-management
  toggle 段落改為移除聲明

容器內全套件 173 passed / 439 assertions。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 00:26:12 +08:00
parent 37140554d3
commit 43720482c4
36 changed files with 1622 additions and 274 deletions
+204 -146
View File
@@ -612,28 +612,29 @@
]
}
},
"/admin/providers/{id}/toggle-verified": {
"put": {
"/admin/verifications": {
"get": {
"tags": [
"Admin 教練管理"
],
"summary": "切換教練審核狀態",
"description": "通過或撤銷教練審核,回傳新的 is_verified 狀態",
"operationId": "toggleProviderVerified",
"summary": "教練審核佇列",
"description": "查詢教練驗證申請(預設僅 pending;status=all 可查全部),含證照圖片 URL",
"operationId": "adminVerificationIndex",
"parameters": [
{
"name": "id",
"in": "path",
"description": "使用者 ID",
"required": true,
"name": "status",
"in": "query",
"description": "unsubmitted / pending / approved / rejected / all",
"required": false,
"schema": {
"type": "integer"
"type": "string",
"default": "pending"
}
}
],
"responses": {
"200": {
"description": "切換成功",
"description": "查詢成功",
"content": {
"application/json": {
"schema": {
@@ -642,13 +643,54 @@
"type": "boolean",
"example": true
},
"message": {
"type": "string",
"example": "教練已通過審核"
},
"is_verified": {
"type": "boolean",
"example": true
"data": {
"type": "array",
"items": {
"properties": {
"user_id": {
"type": "integer",
"example": 5
},
"name": {
"type": "string",
"example": "王教練"
},
"email": {
"type": "string",
"example": "coach@example.com"
},
"business_name": {
"type": "string",
"example": "藍海潛水"
},
"verification_status": {
"type": "string",
"example": "pending"
},
"rejection_reason": {
"type": "string",
"example": null,
"nullable": true
},
"certifications": {
"type": "array",
"items": {
"properties": {
"id": {
"type": "integer",
"example": 1
},
"url": {
"type": "string",
"example": "http://localhost:8080/storage/providers/5/certifications/uuid.jpg"
}
},
"type": "object"
}
}
},
"type": "object"
}
}
},
"type": "object"
@@ -656,6 +698,47 @@
}
}
},
"403": {
"description": "非 admin 角色",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorResponse"
}
}
}
}
},
"security": [
{
"bearerAuth": []
}
]
}
},
"/admin/verifications/{userId}/approve": {
"put": {
"tags": [
"Admin 教練管理"
],
"summary": "通過教練審核",
"description": "將 pending 教練轉為 approved,課程恢復公開曝光並通知教練",
"operationId": "adminVerificationApprove",
"parameters": [
{
"name": "userId",
"in": "path",
"description": "教練使用者 ID",
"required": true,
"schema": {
"type": "integer"
}
}
],
"responses": {
"200": {
"description": "已通過審核"
},
"403": {
"description": "非 admin 角色",
"content": {
@@ -675,6 +758,97 @@
}
}
}
},
"422": {
"description": "當前狀態無法通過審核",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorResponse"
}
}
}
}
},
"security": [
{
"bearerAuth": []
}
]
}
},
"/admin/verifications/{userId}/reject": {
"put": {
"tags": [
"Admin 教練管理"
],
"summary": "駁回教練審核",
"description": "駁回 pending 教練或撤銷 approved 教練,原因必填並通知教練",
"operationId": "adminVerificationReject",
"parameters": [
{
"name": "userId",
"in": "path",
"description": "教練使用者 ID",
"required": true,
"schema": {
"type": "integer"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"required": [
"reason"
],
"properties": {
"reason": {
"type": "string",
"maxLength": 500,
"example": "證照影像不清晰,請重新拍攝上傳"
}
},
"type": "object"
}
}
}
},
"responses": {
"200": {
"description": "已駁回"
},
"403": {
"description": "非 admin 角色",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorResponse"
}
}
}
},
"404": {
"description": "教練不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorResponse"
}
}
}
},
"422": {
"description": "原因未填或狀態不可駁回",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorResponse"
}
}
}
}
},
"security": [
@@ -3021,133 +3195,6 @@
]
}
},
"/admin/register": {
"post": {
"tags": [
"管理員"
],
"summary": "管理員註冊",
"description": "建立新的管理員帳號",
"operationId": "registerAdmin",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"required": [
"name",
"email",
"password",
"password_confirmation"
],
"properties": {
"name": {
"description": "使用者姓名",
"type": "string",
"example": "張管理"
},
"email": {
"description": "電子郵件",
"type": "string",
"format": "email",
"example": "admin@example.com"
},
"password": {
"description": "密碼",
"type": "string",
"format": "password",
"example": "password123"
},
"password_confirmation": {
"description": "確認密碼",
"type": "string",
"format": "password",
"example": "password123"
},
"phone": {
"description": "電話號碼",
"type": "string",
"example": "0912345678"
},
"position": {
"description": "職位",
"type": "string",
"example": "系統管理員"
},
"department": {
"description": "部門",
"type": "string",
"example": "IT部門"
}
},
"type": "object"
}
}
}
},
"responses": {
"201": {
"description": "管理員註冊成功",
"content": {
"application/json": {
"schema": {
"properties": {
"status": {
"type": "boolean",
"example": true
},
"message": {
"type": "string",
"example": "管理員註冊成功"
},
"data": {
"properties": {
"user": {
"$ref": "#/components/schemas/User"
},
"token": {
"type": "string",
"example": "1|abcdef1234567890"
},
"token_type": {
"type": "string",
"example": "Bearer"
}
},
"type": "object"
}
},
"type": "object"
}
}
}
},
"422": {
"description": "驗證失敗",
"content": {
"application/json": {
"schema": {
"properties": {
"status": {
"type": "boolean",
"example": false
},
"message": {
"type": "string",
"example": "驗證失敗"
},
"errors": {
"type": "object"
}
},
"type": "object"
}
}
}
}
}
}
},
"/admin/login": {
"post": {
"tags": [
@@ -6993,8 +7040,19 @@
"type": "string",
"example": "週一至週五 09:00-18:00,週六日 08:00-19:00"
},
"verification_status": {
"description": "審核狀態:unsubmitted / pending / approved / rejected",
"type": "string",
"example": "approved"
},
"rejection_reason": {
"description": "駁回原因(rejected 時有值)",
"type": "string",
"example": null,
"nullable": true
},
"is_verified": {
"description": "是否通過平台驗證",
"description": "是否通過平台驗證(相容欄位,= verification_status 為 approved",
"type": "boolean",
"example": true
},