mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-02 06:56:36 +08:00
feat(storage): implement user-group level file management dashboard and APIs
- Expose user-scoped CRUD APIs under `/api/v1/upload` (my files query, stats, rename, delete) - Update backend handlers and routers with ownership validation checks - Create a dedicated frontend personal file manager card-list and upload button under `/files` - Add comprehensive backend test coverage and update API docs
This commit is contained in:
+225
@@ -3944,6 +3944,195 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/upload/my": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"SessionCookie": []
|
||||
}
|
||||
],
|
||||
"description": "分页获取当前登录用户上传的文件,支持文件名关键词、业务类型、扩展名过滤",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"upload"
|
||||
],
|
||||
"summary": "获取我的文件列表",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "页码(默认 1)",
|
||||
"name": "page",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "每页数量(默认 20,最大 100)",
|
||||
"name": "page_size",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "文件名关键词(模糊匹配)",
|
||||
"name": "keyword",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "业务分类过滤",
|
||||
"name": "type",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "扩展名过滤",
|
||||
"name": "extension",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "查询成功",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/util.ResponseAny"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/upload.listMyFilesResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "未登录",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/util.ResponseAny"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/upload/{id}": {
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"SessionCookie": []
|
||||
}
|
||||
],
|
||||
"description": "更新当前用户本人的文件名或访问权限模式 (AccessMode)",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"upload"
|
||||
],
|
||||
"summary": "更新我的文件信息",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "文件 ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "更新字段",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/upload.updateMyFileRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "更新成功",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/util.ResponseAny"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/model.Upload"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "无权操作",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/util.ResponseAny"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "文件不存在",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/util.ResponseAny"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"SessionCookie": []
|
||||
}
|
||||
],
|
||||
"description": "将当前用户本人的文件状态置为 deleted(软删除)",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"upload"
|
||||
],
|
||||
"summary": "删除我的文件",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "文件 ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "删除成功",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/util.ResponseAny"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "无权操作",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/util.ResponseAny"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "文件不存在",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/util.ResponseAny"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/user-info": {
|
||||
"get": {
|
||||
"security": [
|
||||
@@ -6022,6 +6211,26 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"upload.listMyFilesResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"items": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/model.Upload"
|
||||
}
|
||||
},
|
||||
"page": {
|
||||
"type": "integer"
|
||||
},
|
||||
"page_size": {
|
||||
"type": "integer"
|
||||
},
|
||||
"total": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"upload.trendItem": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -6036,6 +6245,22 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"upload.updateMyFileRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"access_mode": {
|
||||
"type": "integer",
|
||||
"enum": [
|
||||
0,
|
||||
1
|
||||
]
|
||||
},
|
||||
"file_name": {
|
||||
"type": "string",
|
||||
"maxLength": 255
|
||||
}
|
||||
}
|
||||
},
|
||||
"user.changePasswordRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -3937,6 +3937,195 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/upload/my": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"SessionCookie": []
|
||||
}
|
||||
],
|
||||
"description": "分页获取当前登录用户上传的文件,支持文件名关键词、业务类型、扩展名过滤",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"upload"
|
||||
],
|
||||
"summary": "获取我的文件列表",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "页码(默认 1)",
|
||||
"name": "page",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "每页数量(默认 20,最大 100)",
|
||||
"name": "page_size",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "文件名关键词(模糊匹配)",
|
||||
"name": "keyword",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "业务分类过滤",
|
||||
"name": "type",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "扩展名过滤",
|
||||
"name": "extension",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "查询成功",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/util.ResponseAny"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/upload.listMyFilesResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "未登录",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/util.ResponseAny"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/upload/{id}": {
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"SessionCookie": []
|
||||
}
|
||||
],
|
||||
"description": "更新当前用户本人的文件名或访问权限模式 (AccessMode)",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"upload"
|
||||
],
|
||||
"summary": "更新我的文件信息",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "文件 ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "更新字段",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/upload.updateMyFileRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "更新成功",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/util.ResponseAny"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/model.Upload"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "无权操作",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/util.ResponseAny"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "文件不存在",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/util.ResponseAny"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"SessionCookie": []
|
||||
}
|
||||
],
|
||||
"description": "将当前用户本人的文件状态置为 deleted(软删除)",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"upload"
|
||||
],
|
||||
"summary": "删除我的文件",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "文件 ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "删除成功",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/util.ResponseAny"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "无权操作",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/util.ResponseAny"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "文件不存在",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/util.ResponseAny"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/user-info": {
|
||||
"get": {
|
||||
"security": [
|
||||
@@ -6015,6 +6204,26 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"upload.listMyFilesResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"items": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/model.Upload"
|
||||
}
|
||||
},
|
||||
"page": {
|
||||
"type": "integer"
|
||||
},
|
||||
"page_size": {
|
||||
"type": "integer"
|
||||
},
|
||||
"total": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"upload.trendItem": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -6029,6 +6238,22 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"upload.updateMyFileRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"access_mode": {
|
||||
"type": "integer",
|
||||
"enum": [
|
||||
0,
|
||||
1
|
||||
]
|
||||
},
|
||||
"file_name": {
|
||||
"type": "string",
|
||||
"maxLength": 255
|
||||
}
|
||||
}
|
||||
},
|
||||
"user.changePasswordRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -938,6 +938,19 @@ definitions:
|
||||
total:
|
||||
type: integer
|
||||
type: object
|
||||
upload.listMyFilesResponse:
|
||||
properties:
|
||||
items:
|
||||
items:
|
||||
$ref: '#/definitions/model.Upload'
|
||||
type: array
|
||||
page:
|
||||
type: integer
|
||||
page_size:
|
||||
type: integer
|
||||
total:
|
||||
type: integer
|
||||
type: object
|
||||
upload.trendItem:
|
||||
properties:
|
||||
count:
|
||||
@@ -947,6 +960,17 @@ definitions:
|
||||
size:
|
||||
type: integer
|
||||
type: object
|
||||
upload.updateMyFileRequest:
|
||||
properties:
|
||||
access_mode:
|
||||
enum:
|
||||
- 0
|
||||
- 1
|
||||
type: integer
|
||||
file_name:
|
||||
maxLength: 255
|
||||
type: string
|
||||
type: object
|
||||
user.changePasswordRequest:
|
||||
properties:
|
||||
new_password:
|
||||
@@ -3470,6 +3494,121 @@ paths:
|
||||
summary: 上传文件
|
||||
tags:
|
||||
- upload
|
||||
/api/v1/upload/{id}:
|
||||
delete:
|
||||
description: 将当前用户本人的文件状态置为 deleted(软删除)
|
||||
parameters:
|
||||
- description: 文件 ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 删除成功
|
||||
schema:
|
||||
$ref: '#/definitions/util.ResponseAny'
|
||||
"403":
|
||||
description: 无权操作
|
||||
schema:
|
||||
$ref: '#/definitions/util.ResponseAny'
|
||||
"404":
|
||||
description: 文件不存在
|
||||
schema:
|
||||
$ref: '#/definitions/util.ResponseAny'
|
||||
security:
|
||||
- SessionCookie: []
|
||||
summary: 删除我的文件
|
||||
tags:
|
||||
- upload
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 更新当前用户本人的文件名或访问权限模式 (AccessMode)
|
||||
parameters:
|
||||
- description: 文件 ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
- description: 更新字段
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/upload.updateMyFileRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 更新成功
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/util.ResponseAny'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/model.Upload'
|
||||
type: object
|
||||
"403":
|
||||
description: 无权操作
|
||||
schema:
|
||||
$ref: '#/definitions/util.ResponseAny'
|
||||
"404":
|
||||
description: 文件不存在
|
||||
schema:
|
||||
$ref: '#/definitions/util.ResponseAny'
|
||||
security:
|
||||
- SessionCookie: []
|
||||
summary: 更新我的文件信息
|
||||
tags:
|
||||
- upload
|
||||
/api/v1/upload/my:
|
||||
get:
|
||||
description: 分页获取当前登录用户上传的文件,支持文件名关键词、业务类型、扩展名过滤
|
||||
parameters:
|
||||
- description: 页码(默认 1)
|
||||
in: query
|
||||
name: page
|
||||
type: integer
|
||||
- description: 每页数量(默认 20,最大 100)
|
||||
in: query
|
||||
name: page_size
|
||||
type: integer
|
||||
- description: 文件名关键词(模糊匹配)
|
||||
in: query
|
||||
name: keyword
|
||||
type: string
|
||||
- description: 业务分类过滤
|
||||
in: query
|
||||
name: type
|
||||
type: string
|
||||
- description: 扩展名过滤
|
||||
in: query
|
||||
name: extension
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 查询成功
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/util.ResponseAny'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/upload.listMyFilesResponse'
|
||||
type: object
|
||||
"401":
|
||||
description: 未登录
|
||||
schema:
|
||||
$ref: '#/definitions/util.ResponseAny'
|
||||
security:
|
||||
- SessionCookie: []
|
||||
summary: 获取我的文件列表
|
||||
tags:
|
||||
- upload
|
||||
/api/v1/user-info:
|
||||
get:
|
||||
description: 返回当前登录用户的基本信息及余额数据,需要登录。包括用户 ID、用户名、信任等级、各类余额信息等。
|
||||
|
||||
Reference in New Issue
Block a user