[feature] migrate to monorepo
Some checks failed
Build Backend / Build Docker Image (push) Successful in 3m33s
Test Backend / test (push) Failing after 31s

This commit is contained in:
CDN 2025-02-21 00:49:20 +08:00
commit 05ddc1f783
Signed by: CDN
GPG key ID: 0C656827F9F80080
267 changed files with 75165 additions and 0 deletions

View file

@ -0,0 +1,54 @@
login:
post:
tags:
- auth
summary: 用户登录
operationId: login
security: [] # 登录接口不需要认证
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- email
- password
properties:
email:
type: string
format: email
password:
type: string
format: password
responses:
'200':
description: 登录成功
content:
application/json:
schema:
type: object
required:
- token
- user
properties:
token:
type: string
user:
$ref: '../components/schemas.yaml#/User'
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'422':
$ref: '../components/responses.yaml#/ValidationError'
logout:
post:
tags:
- auth
summary: 用户登出
operationId: logout
responses:
'204':
description: 登出成功
'401':
$ref: '../components/responses.yaml#/Unauthorized'

View file

@ -0,0 +1,165 @@
categories:
get:
tags:
- categories
summary: 获取分类列表
operationId: listCategories
parameters:
- $ref: '../components/parameters.yaml#/Page'
- $ref: '../components/parameters.yaml#/PerPage'
- $ref: '../components/parameters.yaml#/Language'
- $ref: '../components/parameters.yaml#/Sort'
responses:
'200':
description: 成功获取分类列表
content:
application/json:
schema:
allOf:
- $ref: '../components/schemas.yaml#/Response'
- type: object
properties:
data:
type: array
items:
$ref: '../components/schemas.yaml#/Category'
post:
tags:
- categories
summary: 创建新分类
operationId: createCategory
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- contents
properties:
contents:
type: array
items:
$ref: '../components/schemas.yaml#/CategoryContent'
responses:
'201':
description: 分类创建成功
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/Category'
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'403':
$ref: '../components/responses.yaml#/Forbidden'
'422':
$ref: '../components/responses.yaml#/ValidationError'
category_slug:
parameters:
- $ref: '../components/parameters.yaml#/Slug'
get:
tags:
- categories
summary: 获取分类详情
operationId: getCategory
parameters:
- $ref: '../components/parameters.yaml#/Language'
responses:
'200':
description: 成功获取分类详情
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/Category'
'404':
$ref: '../components/responses.yaml#/NotFound'
put:
tags:
- categories
summary: 更新分类
operationId: updateCategory
parameters:
- $ref: '../components/parameters.yaml#/Slug'
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
contents:
type: array
items:
$ref: '../components/schemas.yaml#/CategoryContent'
responses:
'200':
description: 分类更新成功
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/Category'
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'403':
$ref: '../components/responses.yaml#/Forbidden'
'404':
$ref: '../components/responses.yaml#/NotFound'
'422':
$ref: '../components/responses.yaml#/ValidationError'
delete:
tags:
- categories
summary: 删除分类
operationId: deleteCategory
parameters:
- $ref: '../components/parameters.yaml#/Slug'
responses:
'204':
description: 分类删除成功
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'403':
$ref: '../components/responses.yaml#/Forbidden'
'404':
$ref: '../components/responses.yaml#/NotFound'
category_posts:
parameters:
- $ref: '../components/parameters.yaml#/Slug'
get:
tags:
- categories
summary: 获取分类下的文章列表
operationId: getCategoryPosts
parameters:
- $ref: '../components/parameters.yaml#/Page'
- $ref: '../components/parameters.yaml#/PerPage'
- $ref: '../components/parameters.yaml#/Language'
- $ref: '../components/parameters.yaml#/Sort'
- $ref: '../components/parameters.yaml#/Status'
responses:
'200':
description: 成功获取文章列表
content:
application/json:
schema:
allOf:
- $ref: '../components/schemas.yaml#/Response'
- type: object
properties:
data:
type: array
items:
$ref: '../components/schemas.yaml#/Post'
'404':
$ref: '../components/responses.yaml#/NotFound'

View file

@ -0,0 +1,139 @@
contributors:
get:
tags:
- contributors
summary: 获取贡献者列表
operationId: listContributors
parameters:
- $ref: '../components/parameters.yaml#/Page'
- $ref: '../components/parameters.yaml#/PerPage'
- $ref: '../components/parameters.yaml#/Sort'
responses:
'200':
description: 成功获取贡献者列表
content:
application/json:
schema:
allOf:
- $ref: '../components/schemas.yaml#/Response'
- type: object
properties:
data:
type: array
items:
$ref: '../components/schemas.yaml#/Contributor'
post:
tags:
- contributors
summary: 创建新贡献者
operationId: createContributor
requestBody:
required: true
content:
application/json:
schema:
$ref: '../components/schemas.yaml#/Contributor'
responses:
'201':
description: 贡献者创建成功
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/Contributor'
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'403':
$ref: '../components/responses.yaml#/Forbidden'
'422':
$ref: '../components/responses.yaml#/ValidationError'
contributor_id:
parameters:
- $ref: '../components/parameters.yaml#/Id'
get:
tags:
- contributors
summary: 获取贡献者详情
operationId: getContributor
responses:
'200':
description: 成功获取贡献者详情
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/Contributor'
'404':
$ref: '../components/responses.yaml#/NotFound'
put:
tags:
- contributors
summary: 更新贡献者信息
operationId: updateContributor
parameters:
- $ref: '../components/parameters.yaml#/Id'
requestBody:
required: true
content:
application/json:
schema:
$ref: '../components/schemas.yaml#/Contributor'
responses:
'200':
description: 贡献者信息更新成功
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/Contributor'
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'403':
$ref: '../components/responses.yaml#/Forbidden'
'404':
$ref: '../components/responses.yaml#/NotFound'
'422':
$ref: '../components/responses.yaml#/ValidationError'
contributor_posts:
parameters:
- $ref: '../components/parameters.yaml#/Id'
get:
tags:
- contributors
summary: 获取贡献者参与的文章列表
operationId: getContributorPosts
parameters:
- $ref: '../components/parameters.yaml#/Page'
- $ref: '../components/parameters.yaml#/PerPage'
- $ref: '../components/parameters.yaml#/Language'
- $ref: '../components/parameters.yaml#/Sort'
- $ref: '../components/parameters.yaml#/Status'
- name: role
in: query
schema:
type: string
description: 按贡献者角色筛选
responses:
'200':
description: 成功获取文章列表
content:
application/json:
schema:
allOf:
- $ref: '../components/schemas.yaml#/Response'
- type: object
properties:
data:
type: array
items:
$ref: '../components/schemas.yaml#/Post'
'404':
$ref: '../components/responses.yaml#/NotFound'

View file

@ -0,0 +1,170 @@
daily:
get:
tags:
- daily
summary: 获取每日一图列表
operationId: listDaily
parameters:
- $ref: '../components/parameters.yaml#/Page'
- $ref: '../components/parameters.yaml#/PerPage'
- $ref: '../components/parameters.yaml#/Sort'
- $ref: '../components/parameters.yaml#/Language'
- name: category_id
in: query
schema:
type: integer
description: 按分类ID筛选
responses:
'200':
description: 成功获取每日一图列表
content:
application/json:
schema:
allOf:
- $ref: '../components/schemas.yaml#/Response'
- type: object
properties:
data:
type: array
items:
$ref: '../components/schemas.yaml#/Daily'
post:
tags:
- daily
summary: 创建每日一图
operationId: createDaily
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- id
- category_id
- image_url
- contents
properties:
id:
type: string
pattern: '^\d{6}$'
examples:
- '250206'
category_id:
type: integer
image_url:
type: string
format: uri
contents:
type: array
items:
type: object
required:
- language_code
- quote
properties:
language_code:
type: string
enum:
- en
- zh-Hans
- zh-Hant
quote:
type: string
responses:
'201':
description: 每日一图创建成功
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/Daily'
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'403':
$ref: '../components/responses.yaml#/Forbidden'
'422':
$ref: '../components/responses.yaml#/ValidationError'
daily_id:
parameters:
- name: id
in: path
required: true
schema:
type: string
pattern: '^\d{6}$'
examples:
- '250206'
get:
tags:
- daily
summary: 获取每日一图详情
operationId: getDaily
parameters:
- $ref: '../components/parameters.yaml#/Language'
responses:
'200':
description: 成功获取每日一图详情
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/Daily'
'404':
$ref: '../components/responses.yaml#/NotFound'
put:
tags:
- daily
summary: 更新每日一图
operationId: updateDaily
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
category_id:
type: integer
image_url:
type: string
format: uri
contents:
type: array
items:
type: object
required:
- language_code
- quote
properties:
language_code:
type: string
enum:
- en
- zh-Hans
- zh-Hant
quote:
type: string
responses:
'200':
description: 每日一图更新成功
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/Daily'
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'403':
$ref: '../components/responses.yaml#/Forbidden'
'404':
$ref: '../components/responses.yaml#/NotFound'
'422':
$ref: '../components/responses.yaml#/ValidationError'

View file

@ -0,0 +1,111 @@
media:
get:
tags:
- media
summary: 获取媒体文件列表
operationId: listMedia
parameters:
- $ref: '../components/parameters.yaml#/Page'
- $ref: '../components/parameters.yaml#/PerPage'
- $ref: '../components/parameters.yaml#/Sort'
- name: mime_type
in: query
schema:
type: string
description: 按 MIME 类型筛选
responses:
'200':
description: 成功获取媒体文件列表
content:
application/json:
schema:
allOf:
- $ref: '../components/schemas.yaml#/Response'
- type: object
properties:
data:
type: array
items:
$ref: '../components/schemas.yaml#/Media'
'401':
$ref: '../components/responses.yaml#/Unauthorized'
post:
tags:
- media
summary: 上传媒体文件
description: |
上传媒体文件。对于图片文件:
- 支持的输入格式JPEG、PNG、GIF
- 所有图片将自动转换为 WebP 格式
- 使用无损压缩以保持图片质量
- 保持原始图片尺寸
operationId: uploadMedia
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
required:
- file
properties:
file:
type: string
format: binary
description: |
要上传的文件。
对于图片文件,将自动转换为 WebP 格式。
支持的图片格式image/jpeg, image/png, image/gif
responses:
'201':
description: 媒体文件上传成功
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/Media'
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'403':
$ref: '../components/responses.yaml#/Forbidden'
'422':
$ref: '../components/responses.yaml#/ValidationError'
media_id:
parameters:
- $ref: '../components/parameters.yaml#/Id'
get:
tags:
- media
summary: 获取媒体文件详情
operationId: getMedia
responses:
'200':
description: 成功获取媒体文件详情
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/Media'
'404':
$ref: '../components/responses.yaml#/NotFound'
delete:
tags:
- media
summary: 删除媒体文件
operationId: deleteMedia
parameters:
- $ref: '../components/parameters.yaml#/Id'
responses:
'204':
description: 媒体文件删除成功
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'403':
$ref: '../components/responses.yaml#/Forbidden'
'404':
$ref: '../components/responses.yaml#/NotFound'

View file

@ -0,0 +1,198 @@
posts:
get:
tags:
- posts
summary: 获取文章列表
operationId: listPosts
parameters:
- $ref: '../components/parameters.yaml#/Page'
- $ref: '../components/parameters.yaml#/PerPage'
- $ref: '../components/parameters.yaml#/Language'
- $ref: '../components/parameters.yaml#/Sort'
- $ref: '../components/parameters.yaml#/Status'
- name: category
in: query
schema:
type: string
description: 按分类筛选
responses:
'200':
description: 成功获取文章列表
content:
application/json:
schema:
allOf:
- $ref: '../components/schemas.yaml#/Response'
- type: object
properties:
data:
type: array
items:
$ref: '../components/schemas.yaml#/Post'
'401':
$ref: '../components/responses.yaml#/Unauthorized'
post:
tags:
- posts
summary: 创建新文章
operationId: createPost
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- slug
- contents
properties:
slug:
type: string
status:
type: string
enum:
- draft
- published
default: draft
contents:
type: array
items:
$ref: '../components/schemas.yaml#/PostContent'
category_ids:
type: array
items:
type: integer
responses:
'201':
description: 文章创建成功
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/Post'
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'403':
$ref: '../components/responses.yaml#/Forbidden'
'422':
$ref: '../components/responses.yaml#/ValidationError'
post_slug:
parameters:
- $ref: '../components/parameters.yaml#/Slug'
get:
tags:
- posts
summary: 获取文章详情
operationId: getPost
parameters:
- $ref: '../components/parameters.yaml#/Language'
responses:
'200':
description: 成功获取文章详情
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/Post'
'404':
$ref: '../components/responses.yaml#/NotFound'
put:
tags:
- posts
summary: 更新文章
operationId: updatePost
parameters:
- $ref: '../components/parameters.yaml#/Slug'
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
status:
type: string
enum:
- draft
- published
contents:
type: array
items:
$ref: '../components/schemas.yaml#/PostContent'
category_ids:
type: array
items:
type: integer
responses:
'200':
description: 文章更新成功
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/Post'
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'403':
$ref: '../components/responses.yaml#/Forbidden'
'404':
$ref: '../components/responses.yaml#/NotFound'
'422':
$ref: '../components/responses.yaml#/ValidationError'
delete:
tags:
- posts
summary: 删除文章
operationId: deletePost
parameters:
- $ref: '../components/parameters.yaml#/Slug'
responses:
'204':
description: 文章删除成功
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'403':
$ref: '../components/responses.yaml#/Forbidden'
'404':
$ref: '../components/responses.yaml#/NotFound'
post_contributors:
parameters:
- $ref: '../components/parameters.yaml#/Slug'
get:
tags:
- posts
summary: 获取文章贡献者列表
operationId: getPostContributors
responses:
'200':
description: 成功获取贡献者列表
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
type: object
properties:
contributor:
$ref: '../components/schemas.yaml#/Contributor'
role:
type: string
language_code:
type: string
enum:
- en
- zh-Hans
- zh-Hant
'404':
$ref: '../components/responses.yaml#/NotFound'

View file

@ -0,0 +1,240 @@
users:
get:
tags:
- users
summary: 获取用户列表
operationId: listUsers
parameters:
- $ref: '../components/parameters.yaml#/Page'
- $ref: '../components/parameters.yaml#/PerPage'
- $ref: '../components/parameters.yaml#/Sort'
- name: role
in: query
schema:
type: string
enum:
- admin
- editor
description: 按角色筛选
- name: status
in: query
schema:
type: string
enum:
- active
- inactive
description: 按状态筛选
- name: email
in: query
schema:
type: string
description: 按邮箱搜索
responses:
'200':
description: 成功获取用户列表
content:
application/json:
schema:
allOf:
- $ref: '../components/schemas.yaml#/Response'
- type: object
properties:
data:
type: array
items:
$ref: '../components/schemas.yaml#/User'
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'403':
$ref: '../components/responses.yaml#/Forbidden'
post:
tags:
- users
summary: 创建新用户
operationId: createUser
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- email
- password
- role
properties:
email:
type: string
format: email
password:
type: string
minLength: 8
role:
type: string
enum:
- admin
- editor
responses:
'201':
description: 用户创建成功
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/User'
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'403':
$ref: '../components/responses.yaml#/Forbidden'
'422':
$ref: '../components/responses.yaml#/ValidationError'
user_id:
parameters:
- name: id
in: path
required: true
schema:
type: integer
get:
tags:
- users
summary: 获取用户详情
operationId: getUser
responses:
'200':
description: 成功获取用户详情
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/User'
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'403':
$ref: '../components/responses.yaml#/Forbidden'
'404':
$ref: '../components/responses.yaml#/NotFound'
put:
tags:
- users
summary: 更新用户信息
operationId: updateUser
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
email:
type: string
format: email
password:
type: string
minLength: 8
role:
type: string
enum:
- admin
- editor
status:
type: string
enum:
- active
- inactive
responses:
'200':
description: 用户更新成功
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/User'
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'403':
$ref: '../components/responses.yaml#/Forbidden'
'404':
$ref: '../components/responses.yaml#/NotFound'
'422':
$ref: '../components/responses.yaml#/ValidationError'
delete:
tags:
- users
summary: 删除用户
operationId: deleteUser
responses:
'204':
description: 用户删除成功
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'403':
$ref: '../components/responses.yaml#/Forbidden'
'404':
$ref: '../components/responses.yaml#/NotFound'
'422':
description: 验证错误,例如用户还有关联的内容
content:
application/json:
schema:
$ref: '../components/schemas.yaml#/Error'
user_me:
get:
tags:
- users
summary: 获取当前用户信息
operationId: getCurrentUser
responses:
'200':
description: 成功获取当前用户信息
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/User'
'401':
$ref: '../components/responses.yaml#/Unauthorized'
put:
tags:
- users
summary: 更新当前用户信息
operationId: updateCurrentUser
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
email:
type: string
format: email
current_password:
type: string
new_password:
type: string
minLength: 8
responses:
'200':
description: 用户信息更新成功
content:
application/json:
schema:
type: object
properties:
data:
$ref: '../components/schemas.yaml#/User'
'401':
$ref: '../components/responses.yaml#/Unauthorized'
'422':
$ref: '../components/responses.yaml#/ValidationError'