update
This commit is contained in:
parent
0ebd0d6cb6
commit
c94220d13e
479
docs/docs.go
479
docs/docs.go
@ -15,6 +15,190 @@ const docTemplate = `{
|
|||||||
"host": "{{.Host}}",
|
"host": "{{.Host}}",
|
||||||
"basePath": "{{.BasePath}}",
|
"basePath": "{{.BasePath}}",
|
||||||
"paths": {
|
"paths": {
|
||||||
|
"/blocks/{block_id}": {
|
||||||
|
"put": {
|
||||||
|
"description": "更新文档块的内容",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Document"
|
||||||
|
],
|
||||||
|
"summary": "更新文档块",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "文档块ID",
|
||||||
|
"name": "block_id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "更新文档块请求",
|
||||||
|
"name": "request",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.UpdateBlockRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"$ref": "#/definitions/entity.DocumentBlock"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "参数验证失败",
|
||||||
|
"schema": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/dto.ValidateError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "文档块不存在",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"delete": {
|
||||||
|
"description": "删除指定的文档块",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Document"
|
||||||
|
],
|
||||||
|
"summary": "删除文档块",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "文档块ID",
|
||||||
|
"name": "block_id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "文档块不存在",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/blocks/{block_id}/move": {
|
||||||
|
"post": {
|
||||||
|
"description": "移动文档块的位置",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Document"
|
||||||
|
],
|
||||||
|
"summary": "移动文档块",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "文档块ID",
|
||||||
|
"name": "block_id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "移动文档块请求",
|
||||||
|
"name": "request",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.MoveBlockRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "参数验证失败",
|
||||||
|
"schema": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/dto.ValidateError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "文档块不存在",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/collections": {
|
"/collections": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "在工作空间下创建新的集合",
|
"description": "在工作空间下创建新的集合",
|
||||||
@ -169,7 +353,7 @@ const docTemplate = `{
|
|||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"description": "集合ID",
|
"description": "集<EFBFBD><EFBFBD>ID",
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"required": true
|
"required": true
|
||||||
@ -202,6 +386,84 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"put": {
|
||||||
|
"description": "更新集合的名称等信息",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Collection"
|
||||||
|
],
|
||||||
|
"summary": "更新集合",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "集合ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "更新集合请求",
|
||||||
|
"name": "request",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.UpdateCollectionRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"$ref": "#/definitions/leafdev_top_Leaf_leaf-library-3_internal_entity.Collection"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "参数验证失败",
|
||||||
|
"schema": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/dto.ValidateError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "集合不存在",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"description": "删除指定的集合",
|
"description": "删除指定的集合",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
@ -320,7 +582,7 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"/documents/{document_id}/blocks": {
|
"/documents/{document_id}/blocks": {
|
||||||
"get": {
|
"get": {
|
||||||
"description": "获取指文档下的所有文档块",
|
"description": "获取指定文档下的所有文档块",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
@ -449,211 +711,6 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/documents/{document_id}/blocks/{block_id}": {
|
|
||||||
"put": {
|
|
||||||
"description": "更新文档块的内容",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Document"
|
|
||||||
],
|
|
||||||
"summary": "更新文档块",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "文档ID",
|
|
||||||
"name": "document_id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "文档块ID",
|
|
||||||
"name": "block_id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "更新文档块请求",
|
|
||||||
"name": "request",
|
|
||||||
"in": "body",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/dto.UpdateBlockRequest"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"allOf": [
|
|
||||||
{
|
|
||||||
"$ref": "#/definitions/dto.Response"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"data": {
|
|
||||||
"$ref": "#/definitions/entity.DocumentBlock"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "参数验证失败",
|
|
||||||
"schema": {
|
|
||||||
"allOf": [
|
|
||||||
{
|
|
||||||
"$ref": "#/definitions/dto.Response"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"data": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/dto.ValidateError"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"404": {
|
|
||||||
"description": "文档块不存在",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/dto.Response"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"delete": {
|
|
||||||
"description": "删除指定的文档块",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Document"
|
|
||||||
],
|
|
||||||
"summary": "删除文档块",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "文档ID",
|
|
||||||
"name": "document_id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "文档块ID",
|
|
||||||
"name": "block_id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/dto.Response"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"404": {
|
|
||||||
"description": "文档块不存在",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/dto.Response"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/documents/{document_id}/blocks/{block_id}/move": {
|
|
||||||
"post": {
|
|
||||||
"description": "移动文档块的位置",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Document"
|
|
||||||
],
|
|
||||||
"summary": "移动文档块",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "文档ID",
|
|
||||||
"name": "document_id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "文档块ID",
|
|
||||||
"name": "block_id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "移动文档块请求",
|
|
||||||
"name": "request",
|
|
||||||
"in": "body",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/dto.MoveBlockRequest"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/dto.Response"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "参数验证失败",
|
|
||||||
"schema": {
|
|
||||||
"allOf": [
|
|
||||||
{
|
|
||||||
"$ref": "#/definitions/dto.Response"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"data": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/dto.ValidateError"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"404": {
|
|
||||||
"description": "文档块不存在",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/dto.Response"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/documents/{id}": {
|
"/documents/{id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"description": "根据文档ID获取文档详情",
|
"description": "根据文档ID获取文档详情",
|
||||||
@ -1322,6 +1379,14 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"dto.UpdateCollectionRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"dto.UpdateDocumentRequest": {
|
"dto.UpdateDocumentRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -6,6 +6,190 @@
|
|||||||
"version": "1.0"
|
"version": "1.0"
|
||||||
},
|
},
|
||||||
"paths": {
|
"paths": {
|
||||||
|
"/blocks/{block_id}": {
|
||||||
|
"put": {
|
||||||
|
"description": "更新文档块的内容",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Document"
|
||||||
|
],
|
||||||
|
"summary": "更新文档块",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "文档块ID",
|
||||||
|
"name": "block_id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "更新文档块请求",
|
||||||
|
"name": "request",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.UpdateBlockRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"$ref": "#/definitions/entity.DocumentBlock"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "参数验证失败",
|
||||||
|
"schema": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/dto.ValidateError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "文档块不存在",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"delete": {
|
||||||
|
"description": "删除指定的文档块",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Document"
|
||||||
|
],
|
||||||
|
"summary": "删除文档块",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "文档块ID",
|
||||||
|
"name": "block_id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "文档块不存在",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/blocks/{block_id}/move": {
|
||||||
|
"post": {
|
||||||
|
"description": "移动文档块的位置",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Document"
|
||||||
|
],
|
||||||
|
"summary": "移动文档块",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "文档块ID",
|
||||||
|
"name": "block_id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "移动文档块请求",
|
||||||
|
"name": "request",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.MoveBlockRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "参数验证失败",
|
||||||
|
"schema": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/dto.ValidateError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "文档块不存在",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/collections": {
|
"/collections": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "在工作空间下创建新的集合",
|
"description": "在工作空间下创建新的集合",
|
||||||
@ -160,7 +344,7 @@
|
|||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"description": "集合ID",
|
"description": "集<EFBFBD><EFBFBD>ID",
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"required": true
|
"required": true
|
||||||
@ -193,6 +377,84 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"put": {
|
||||||
|
"description": "更新集合的名称等信息",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Collection"
|
||||||
|
],
|
||||||
|
"summary": "更新集合",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "集合ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "更新集合请求",
|
||||||
|
"name": "request",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.UpdateCollectionRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"$ref": "#/definitions/leafdev_top_Leaf_leaf-library-3_internal_entity.Collection"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "参数验证失败",
|
||||||
|
"schema": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/dto.ValidateError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "集合不存在",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.Response"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"description": "删除指定的集合",
|
"description": "删除指定的集合",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
@ -311,7 +573,7 @@
|
|||||||
},
|
},
|
||||||
"/documents/{document_id}/blocks": {
|
"/documents/{document_id}/blocks": {
|
||||||
"get": {
|
"get": {
|
||||||
"description": "获取指文档下的所有文档块",
|
"description": "获取指定文档下的所有文档块",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
@ -440,211 +702,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/documents/{document_id}/blocks/{block_id}": {
|
|
||||||
"put": {
|
|
||||||
"description": "更新文档块的内容",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Document"
|
|
||||||
],
|
|
||||||
"summary": "更新文档块",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "文档ID",
|
|
||||||
"name": "document_id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "文档块ID",
|
|
||||||
"name": "block_id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "更新文档块请求",
|
|
||||||
"name": "request",
|
|
||||||
"in": "body",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/dto.UpdateBlockRequest"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"allOf": [
|
|
||||||
{
|
|
||||||
"$ref": "#/definitions/dto.Response"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"data": {
|
|
||||||
"$ref": "#/definitions/entity.DocumentBlock"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "参数验证失败",
|
|
||||||
"schema": {
|
|
||||||
"allOf": [
|
|
||||||
{
|
|
||||||
"$ref": "#/definitions/dto.Response"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"data": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/dto.ValidateError"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"404": {
|
|
||||||
"description": "文档块不存在",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/dto.Response"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"delete": {
|
|
||||||
"description": "删除指定的文档块",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Document"
|
|
||||||
],
|
|
||||||
"summary": "删除文档块",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "文档ID",
|
|
||||||
"name": "document_id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "文档块ID",
|
|
||||||
"name": "block_id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/dto.Response"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"404": {
|
|
||||||
"description": "文档块不存在",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/dto.Response"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/documents/{document_id}/blocks/{block_id}/move": {
|
|
||||||
"post": {
|
|
||||||
"description": "移动文档块的位置",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Document"
|
|
||||||
],
|
|
||||||
"summary": "移动文档块",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "文档ID",
|
|
||||||
"name": "document_id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "文档块ID",
|
|
||||||
"name": "block_id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "移动文档块请求",
|
|
||||||
"name": "request",
|
|
||||||
"in": "body",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/dto.MoveBlockRequest"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/dto.Response"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "参数验证失败",
|
|
||||||
"schema": {
|
|
||||||
"allOf": [
|
|
||||||
{
|
|
||||||
"$ref": "#/definitions/dto.Response"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"data": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/dto.ValidateError"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"404": {
|
|
||||||
"description": "文档块不存在",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/dto.Response"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/documents/{id}": {
|
"/documents/{id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"description": "根据文档ID获取文档详情",
|
"description": "根据文档ID获取文档详情",
|
||||||
@ -1313,6 +1370,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"dto.UpdateCollectionRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"dto.UpdateDocumentRequest": {
|
"dto.UpdateDocumentRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -79,6 +79,11 @@ definitions:
|
|||||||
required:
|
required:
|
||||||
- content
|
- content
|
||||||
type: object
|
type: object
|
||||||
|
dto.UpdateCollectionRequest:
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
dto.UpdateDocumentRequest:
|
dto.UpdateDocumentRequest:
|
||||||
properties:
|
properties:
|
||||||
name:
|
name:
|
||||||
@ -201,6 +206,119 @@ info:
|
|||||||
title: API Docs
|
title: API Docs
|
||||||
version: "1.0"
|
version: "1.0"
|
||||||
paths:
|
paths:
|
||||||
|
/blocks/{block_id}:
|
||||||
|
delete:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: 删除指定的文档块
|
||||||
|
parameters:
|
||||||
|
- description: 文档块ID
|
||||||
|
in: path
|
||||||
|
name: block_id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/dto.Response'
|
||||||
|
"404":
|
||||||
|
description: 文档块不存在
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/dto.Response'
|
||||||
|
summary: 删除文档块
|
||||||
|
tags:
|
||||||
|
- Document
|
||||||
|
put:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: 更新文档块的内容
|
||||||
|
parameters:
|
||||||
|
- description: 文档块ID
|
||||||
|
in: path
|
||||||
|
name: block_id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
- description: 更新文档块请求
|
||||||
|
in: body
|
||||||
|
name: request
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/dto.UpdateBlockRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/dto.Response'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/entity.DocumentBlock'
|
||||||
|
type: object
|
||||||
|
"400":
|
||||||
|
description: 参数验证失败
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/dto.Response'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/dto.ValidateError'
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
|
"404":
|
||||||
|
description: 文档块不存在
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/dto.Response'
|
||||||
|
summary: 更新文档块
|
||||||
|
tags:
|
||||||
|
- Document
|
||||||
|
/blocks/{block_id}/move:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: 移动文档块的位置
|
||||||
|
parameters:
|
||||||
|
- description: 文档块ID
|
||||||
|
in: path
|
||||||
|
name: block_id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
- description: 移动文档块请求
|
||||||
|
in: body
|
||||||
|
name: request
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/dto.MoveBlockRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/dto.Response'
|
||||||
|
"400":
|
||||||
|
description: 参数验证失败
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/dto.Response'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/dto.ValidateError'
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
|
"404":
|
||||||
|
description: 文档块不存在
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/dto.Response'
|
||||||
|
summary: 移动文档块
|
||||||
|
tags:
|
||||||
|
- Document
|
||||||
/collections:
|
/collections:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
@ -313,7 +431,7 @@ paths:
|
|||||||
- application/json
|
- application/json
|
||||||
description: 根据集合ID获取集合详情
|
description: 根据集合ID获取集合详情
|
||||||
parameters:
|
parameters:
|
||||||
- description: 集合ID
|
- description: 集<EFBFBD><EFBFBD>ID
|
||||||
in: path
|
in: path
|
||||||
name: id
|
name: id
|
||||||
required: true
|
required: true
|
||||||
@ -337,6 +455,52 @@ paths:
|
|||||||
summary: 获取集合
|
summary: 获取集合
|
||||||
tags:
|
tags:
|
||||||
- Collection
|
- Collection
|
||||||
|
put:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: 更新集合的名称等信息
|
||||||
|
parameters:
|
||||||
|
- description: 集合ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
- description: 更新集合请求
|
||||||
|
in: body
|
||||||
|
name: request
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/dto.UpdateCollectionRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/dto.Response'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/leafdev_top_Leaf_leaf-library-3_internal_entity.Collection'
|
||||||
|
type: object
|
||||||
|
"400":
|
||||||
|
description: 参数验证失败
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/dto.Response'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/dto.ValidateError'
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
|
"404":
|
||||||
|
description: 集合不存在
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/dto.Response'
|
||||||
|
summary: 更新集合
|
||||||
|
tags:
|
||||||
|
- Collection
|
||||||
/documents:
|
/documents:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
@ -387,7 +551,7 @@ paths:
|
|||||||
get:
|
get:
|
||||||
consumes:
|
consumes:
|
||||||
- application/json
|
- application/json
|
||||||
description: 获取指文档下的所有文档块
|
description: 获取指定文档下的所有文档块
|
||||||
parameters:
|
parameters:
|
||||||
- description: 文档ID
|
- description: 文档ID
|
||||||
in: path
|
in: path
|
||||||
@ -461,134 +625,6 @@ paths:
|
|||||||
summary: 创建文档块
|
summary: 创建文档块
|
||||||
tags:
|
tags:
|
||||||
- Document
|
- Document
|
||||||
/documents/{document_id}/blocks/{block_id}:
|
|
||||||
delete:
|
|
||||||
consumes:
|
|
||||||
- application/json
|
|
||||||
description: 删除指定的文档块
|
|
||||||
parameters:
|
|
||||||
- description: 文档ID
|
|
||||||
in: path
|
|
||||||
name: document_id
|
|
||||||
required: true
|
|
||||||
type: integer
|
|
||||||
- description: 文档块ID
|
|
||||||
in: path
|
|
||||||
name: block_id
|
|
||||||
required: true
|
|
||||||
type: integer
|
|
||||||
produces:
|
|
||||||
- application/json
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: OK
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/dto.Response'
|
|
||||||
"404":
|
|
||||||
description: 文档块不存在
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/dto.Response'
|
|
||||||
summary: 删除文档块
|
|
||||||
tags:
|
|
||||||
- Document
|
|
||||||
put:
|
|
||||||
consumes:
|
|
||||||
- application/json
|
|
||||||
description: 更新文档块的内容
|
|
||||||
parameters:
|
|
||||||
- description: 文档ID
|
|
||||||
in: path
|
|
||||||
name: document_id
|
|
||||||
required: true
|
|
||||||
type: integer
|
|
||||||
- description: 文档块ID
|
|
||||||
in: path
|
|
||||||
name: block_id
|
|
||||||
required: true
|
|
||||||
type: integer
|
|
||||||
- description: 更新文档块请求
|
|
||||||
in: body
|
|
||||||
name: request
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/dto.UpdateBlockRequest'
|
|
||||||
produces:
|
|
||||||
- application/json
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: OK
|
|
||||||
schema:
|
|
||||||
allOf:
|
|
||||||
- $ref: '#/definitions/dto.Response'
|
|
||||||
- properties:
|
|
||||||
data:
|
|
||||||
$ref: '#/definitions/entity.DocumentBlock'
|
|
||||||
type: object
|
|
||||||
"400":
|
|
||||||
description: 参数验证失败
|
|
||||||
schema:
|
|
||||||
allOf:
|
|
||||||
- $ref: '#/definitions/dto.Response'
|
|
||||||
- properties:
|
|
||||||
data:
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/dto.ValidateError'
|
|
||||||
type: array
|
|
||||||
type: object
|
|
||||||
"404":
|
|
||||||
description: 文档块不存在
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/dto.Response'
|
|
||||||
summary: 更新文档块
|
|
||||||
tags:
|
|
||||||
- Document
|
|
||||||
/documents/{document_id}/blocks/{block_id}/move:
|
|
||||||
post:
|
|
||||||
consumes:
|
|
||||||
- application/json
|
|
||||||
description: 移动文档块的位置
|
|
||||||
parameters:
|
|
||||||
- description: 文档ID
|
|
||||||
in: path
|
|
||||||
name: document_id
|
|
||||||
required: true
|
|
||||||
type: integer
|
|
||||||
- description: 文档块ID
|
|
||||||
in: path
|
|
||||||
name: block_id
|
|
||||||
required: true
|
|
||||||
type: integer
|
|
||||||
- description: 移动文档块请求
|
|
||||||
in: body
|
|
||||||
name: request
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/dto.MoveBlockRequest'
|
|
||||||
produces:
|
|
||||||
- application/json
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: OK
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/dto.Response'
|
|
||||||
"400":
|
|
||||||
description: 参数验证失败
|
|
||||||
schema:
|
|
||||||
allOf:
|
|
||||||
- $ref: '#/definitions/dto.Response'
|
|
||||||
- properties:
|
|
||||||
data:
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/dto.ValidateError'
|
|
||||||
type: array
|
|
||||||
type: object
|
|
||||||
"404":
|
|
||||||
description: 文档块不存在
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/dto.Response'
|
|
||||||
summary: 移动文档块
|
|
||||||
tags:
|
|
||||||
- Document
|
|
||||||
/documents/{id}:
|
/documents/{id}:
|
||||||
delete:
|
delete:
|
||||||
consumes:
|
consumes:
|
||||||
|
@ -76,7 +76,7 @@ func (c *CollectionController) CreateCollection(ctx *fiber.Ctx) error {
|
|||||||
// @Tags Collection
|
// @Tags Collection
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param id path int true "集合ID"
|
// @Param id path int true "集<EFBFBD><EFBFBD>ID"
|
||||||
// @Success 200 {object} dto.Response{data=entity.Collection}
|
// @Success 200 {object} dto.Response{data=entity.Collection}
|
||||||
// @Failure 404 {object} dto.Response "集合不存在"
|
// @Failure 404 {object} dto.Response "集合不存在"
|
||||||
// @Router /collections/{id} [get]
|
// @Router /collections/{id} [get]
|
||||||
@ -118,7 +118,7 @@ func (c *CollectionController) ListCollections(ctx *fiber.Ctx) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查工作空间是否存在
|
// 检<EFBFBD><EFBFBD><EFBFBD>工作空间是否存在
|
||||||
exists, err := c.workspaceService.Exists(ctx.Context(), req.WorkspaceID)
|
exists, err := c.workspaceService.Exists(ctx.Context(), req.WorkspaceID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -135,6 +135,69 @@ func (c *CollectionController) ListCollections(ctx *fiber.Ctx) error {
|
|||||||
return dto.Ctx(ctx).Success(collections).Send()
|
return dto.Ctx(ctx).Success(collections).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateCollection 更新集合
|
||||||
|
// @Summary 更新集合
|
||||||
|
// @Description 更新集合的名称等信息
|
||||||
|
// @Tags Collection
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param id path int true "集合ID"
|
||||||
|
// @Param request body dto.UpdateCollectionRequest true "更新集合请求"
|
||||||
|
// @Success 200 {object} dto.Response{data=entity.Collection}
|
||||||
|
// @Failure 400 {object} dto.Response{data=[]dto.ValidateError} "参数验证失败"
|
||||||
|
// @Failure 404 {object} dto.Response "集合不存在"
|
||||||
|
// @Router /collections/{id} [put]
|
||||||
|
func (c *CollectionController) UpdateCollection(ctx *fiber.Ctx) error {
|
||||||
|
var params dto.CollectionIDParam
|
||||||
|
if err := ctx.ParamsParser(¶ms); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var req dto.UpdateCollectionRequest
|
||||||
|
if err := ctx.BodyParser(&req); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if validationErrors, ok, err := validator.Struct(req); !ok {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return dto.Ctx(ctx).Data(validationErrors).Status(fiber.StatusBadRequest).Send()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查集合是否存在
|
||||||
|
collection, err := c.collectionService.Get(ctx.Context(), params.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if collection == nil {
|
||||||
|
return dto.Ctx(ctx).Error(errs.ErrCollectionNotExists).Status(fiber.StatusNotFound).Send()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查用户是否有权限访问该集合
|
||||||
|
user := c.authService.GetUser(ctx)
|
||||||
|
workspace, err := c.workspaceService.Get(ctx.Context(), collection.WorkspaceId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
isMember, err := c.workspaceService.IsMember(ctx.Context(), user.ID, workspace)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !isMember {
|
||||||
|
return dto.Ctx(ctx).Error(errs.ErrNoPermission).Status(fiber.StatusForbidden).Send()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新集合
|
||||||
|
collection, err = c.collectionService.Update(ctx.Context(), params.ID, req.Name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return dto.Ctx(ctx).Success(collection).Send()
|
||||||
|
}
|
||||||
|
|
||||||
// DeleteCollection 删除集合
|
// DeleteCollection 删除集合
|
||||||
// @Summary 删除集合
|
// @Summary 删除集合
|
||||||
// @Description 删除指定的集合
|
// @Description 删除指定的集合
|
||||||
@ -146,20 +209,37 @@ func (c *CollectionController) ListCollections(ctx *fiber.Ctx) error {
|
|||||||
// @Failure 404 {object} dto.Response "集合不存在"
|
// @Failure 404 {object} dto.Response "集合不存在"
|
||||||
// @Router /collections/{id} [delete]
|
// @Router /collections/{id} [delete]
|
||||||
func (c *CollectionController) DeleteCollection(ctx *fiber.Ctx) error {
|
func (c *CollectionController) DeleteCollection(ctx *fiber.Ctx) error {
|
||||||
var req dto.DeleteCollectionRequest
|
var params dto.CollectionIDParam
|
||||||
if err := ctx.ParamsParser(&req); err != nil {
|
if err := ctx.ParamsParser(¶ms); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
exists, err := c.collectionService.Exists(ctx.Context(), req.ID)
|
// 检查集合是否存在
|
||||||
|
collection, err := c.collectionService.Get(ctx.Context(), params.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !exists {
|
if collection == nil {
|
||||||
return dto.Ctx(ctx).Error(errs.ErrCollectionNotExists).Status(fiber.StatusNotFound).Send()
|
return dto.Ctx(ctx).Error(errs.ErrCollectionNotExists).Status(fiber.StatusNotFound).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
err = c.collectionService.Delete(ctx.Context(), req.ID)
|
// 检查用户是否有权限访问该集合
|
||||||
|
user := c.authService.GetUser(ctx)
|
||||||
|
workspace, err := c.workspaceService.Get(ctx.Context(), collection.WorkspaceId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
isMember, err := c.workspaceService.IsMember(ctx.Context(), user.ID, workspace)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !isMember {
|
||||||
|
return dto.Ctx(ctx).Error(errs.ErrNoPermission).Status(fiber.StatusForbidden).Send()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除集合
|
||||||
|
err = c.collectionService.Delete(ctx.Context(), params.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -340,6 +340,34 @@ func (c *DocumentController) CreateBlock(ctx *fiber.Ctx) error {
|
|||||||
return dto.Ctx(ctx).Data(validationErrors).Status(fiber.StatusBadRequest).Send()
|
return dto.Ctx(ctx).Data(validationErrors).Status(fiber.StatusBadRequest).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查文档是否存在
|
||||||
|
doc, err := c.documentService.Get(ctx.Context(), params.DocumentID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if doc == nil {
|
||||||
|
return dto.Ctx(ctx).Error(errs.ErrDocumentNotExists).Status(fiber.StatusNotFound).Send()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查用户是否有权限访问该文档
|
||||||
|
user := c.authService.GetUser(ctx)
|
||||||
|
collection, err := c.collectionService.Get(ctx.Context(), doc.CollectionId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
workspace, err := c.workspaceService.Get(ctx.Context(), collection.WorkspaceId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
isMember, err := c.workspaceService.IsMember(ctx.Context(), user.ID, workspace)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !isMember {
|
||||||
|
return dto.Ctx(ctx).Error(errs.ErrNoPermission).Status(fiber.StatusForbidden).Send()
|
||||||
|
}
|
||||||
|
|
||||||
block, err := c.documentService.CreateBlock(ctx.Context(), params.DocumentID, req.Type, req.Content, req.AfterBlockID)
|
block, err := c.documentService.CreateBlock(ctx.Context(), params.DocumentID, req.Type, req.Content, req.AfterBlockID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -354,13 +382,12 @@ func (c *DocumentController) CreateBlock(ctx *fiber.Ctx) error {
|
|||||||
// @Tags Document
|
// @Tags Document
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param document_id path int true "文档ID"
|
|
||||||
// @Param block_id path int true "文档块ID"
|
// @Param block_id path int true "文档块ID"
|
||||||
// @Param request body dto.UpdateBlockRequest true "更新文档块请求"
|
// @Param request body dto.UpdateBlockRequest true "更新文档块请求"
|
||||||
// @Success 200 {object} dto.Response{data=entity.DocumentBlock}
|
// @Success 200 {object} dto.Response{data=entity.DocumentBlock}
|
||||||
// @Failure 400 {object} dto.Response{data=[]dto.ValidateError} "参数验证失败"
|
// @Failure 400 {object} dto.Response{data=[]dto.ValidateError} "参数验证失败"
|
||||||
// @Failure 404 {object} dto.Response "文档块不存在"
|
// @Failure 404 {object} dto.Response "文档块不存在"
|
||||||
// @Router /documents/{document_id}/blocks/{block_id} [put]
|
// @Router /blocks/{block_id} [put]
|
||||||
func (c *DocumentController) UpdateBlock(ctx *fiber.Ctx) error {
|
func (c *DocumentController) UpdateBlock(ctx *fiber.Ctx) error {
|
||||||
var params dto.BlockIDParam
|
var params dto.BlockIDParam
|
||||||
if err := ctx.ParamsParser(¶ms); err != nil {
|
if err := ctx.ParamsParser(¶ms); err != nil {
|
||||||
@ -379,7 +406,44 @@ func (c *DocumentController) UpdateBlock(ctx *fiber.Ctx) error {
|
|||||||
return dto.Ctx(ctx).Data(validationErrors).Status(fiber.StatusBadRequest).Send()
|
return dto.Ctx(ctx).Data(validationErrors).Status(fiber.StatusBadRequest).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
block, err := c.documentService.UpdateBlock(ctx.Context(), params.ID, req.Content)
|
// 获取块信息
|
||||||
|
block, err := c.documentService.GetBlock(ctx.Context(), params.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if block == nil {
|
||||||
|
return dto.Ctx(ctx).Error(errs.ErrBlockNotExists).Status(fiber.StatusNotFound).Send()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查文档是否存在
|
||||||
|
doc, err := c.documentService.Get(ctx.Context(), block.DocumentId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if doc == nil {
|
||||||
|
return dto.Ctx(ctx).Error(errs.ErrDocumentNotExists).Status(fiber.StatusNotFound).Send()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查用户是否有权限访问该文档
|
||||||
|
user := c.authService.GetUser(ctx)
|
||||||
|
collection, err := c.collectionService.Get(ctx.Context(), doc.CollectionId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
workspace, err := c.workspaceService.Get(ctx.Context(), collection.WorkspaceId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
isMember, err := c.workspaceService.IsMember(ctx.Context(), user.ID, workspace)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !isMember {
|
||||||
|
return dto.Ctx(ctx).Error(errs.ErrNoPermission).Status(fiber.StatusForbidden).Send()
|
||||||
|
}
|
||||||
|
|
||||||
|
block, err = c.documentService.UpdateBlock(ctx.Context(), params.ID, req.Content)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -387,24 +451,60 @@ func (c *DocumentController) UpdateBlock(ctx *fiber.Ctx) error {
|
|||||||
return dto.Ctx(ctx).Success(block).Send()
|
return dto.Ctx(ctx).Success(block).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteBlock 删除文档块
|
// DeleteBlock <EFBFBD><EFBFBD><EFBFBD>除文档块
|
||||||
// @Summary 删除文档块
|
// @Summary 删除文档块
|
||||||
// @Description 删除指定的文档块
|
// @Description 删除指定的文档块
|
||||||
// @Tags Document
|
// @Tags Document
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param document_id path int true "文档ID"
|
|
||||||
// @Param block_id path int true "文档块ID"
|
// @Param block_id path int true "文档块ID"
|
||||||
// @Success 200 {object} dto.Response
|
// @Success 200 {object} dto.Response
|
||||||
// @Failure 404 {object} dto.Response "文档块不存在"
|
// @Failure 404 {object} dto.Response "文档块不存在"
|
||||||
// @Router /documents/{document_id}/blocks/{block_id} [delete]
|
// @Router /blocks/{block_id} [delete]
|
||||||
func (c *DocumentController) DeleteBlock(ctx *fiber.Ctx) error {
|
func (c *DocumentController) DeleteBlock(ctx *fiber.Ctx) error {
|
||||||
var params dto.BlockIDParam
|
var params dto.BlockIDParam
|
||||||
if err := ctx.ParamsParser(¶ms); err != nil {
|
if err := ctx.ParamsParser(¶ms); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err := c.documentService.DeleteBlock(ctx.Context(), params.ID)
|
// 获取块信息
|
||||||
|
block, err := c.documentService.GetBlock(ctx.Context(), params.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if block == nil {
|
||||||
|
return dto.Ctx(ctx).Error(errs.ErrBlockNotExists).Status(fiber.StatusNotFound).Send()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查文档是否存在
|
||||||
|
doc, err := c.documentService.Get(ctx.Context(), block.DocumentId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if doc == nil {
|
||||||
|
return dto.Ctx(ctx).Error(errs.ErrDocumentNotExists).Status(fiber.StatusNotFound).Send()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查用户是否有权限访问该文档
|
||||||
|
user := c.authService.GetUser(ctx)
|
||||||
|
collection, err := c.collectionService.Get(ctx.Context(), doc.CollectionId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
workspace, err := c.workspaceService.Get(ctx.Context(), collection.WorkspaceId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
isMember, err := c.workspaceService.IsMember(ctx.Context(), user.ID, workspace)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !isMember {
|
||||||
|
return dto.Ctx(ctx).Error(errs.ErrNoPermission).Status(fiber.StatusForbidden).Send()
|
||||||
|
}
|
||||||
|
|
||||||
|
err = c.documentService.DeleteBlock(ctx.Context(), params.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -414,7 +514,7 @@ func (c *DocumentController) DeleteBlock(ctx *fiber.Ctx) error {
|
|||||||
|
|
||||||
// ListBlocks 列出文档下的所有块
|
// ListBlocks 列出文档下的所有块
|
||||||
// @Summary 列出文档块列表
|
// @Summary 列出文档块列表
|
||||||
// @Description 获取指文档下的所有文档块
|
// @Description 获取指定文档下的所有文档块
|
||||||
// @Tags Document
|
// @Tags Document
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
@ -428,6 +528,34 @@ func (c *DocumentController) ListBlocks(ctx *fiber.Ctx) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查文档是否存在
|
||||||
|
doc, err := c.documentService.Get(ctx.Context(), params.DocumentID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if doc == nil {
|
||||||
|
return dto.Ctx(ctx).Error(errs.ErrDocumentNotExists).Status(fiber.StatusNotFound).Send()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查用户是否有权限访问该文档
|
||||||
|
user := c.authService.GetUser(ctx)
|
||||||
|
collection, err := c.collectionService.Get(ctx.Context(), doc.CollectionId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
workspace, err := c.workspaceService.Get(ctx.Context(), collection.WorkspaceId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
isMember, err := c.workspaceService.IsMember(ctx.Context(), user.ID, workspace)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !isMember {
|
||||||
|
return dto.Ctx(ctx).Error(errs.ErrNoPermission).Status(fiber.StatusForbidden).Send()
|
||||||
|
}
|
||||||
|
|
||||||
blocks, err := c.documentService.ListBlocks(ctx.Context(), params.DocumentID)
|
blocks, err := c.documentService.ListBlocks(ctx.Context(), params.DocumentID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -442,13 +570,12 @@ func (c *DocumentController) ListBlocks(ctx *fiber.Ctx) error {
|
|||||||
// @Tags Document
|
// @Tags Document
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param document_id path int true "文档ID"
|
|
||||||
// @Param block_id path int true "文档块ID"
|
// @Param block_id path int true "文档块ID"
|
||||||
// @Param request body dto.MoveBlockRequest true "移动文档块请求"
|
// @Param request body dto.MoveBlockRequest true "移动文档块请求"
|
||||||
// @Success 200 {object} dto.Response
|
// @Success 200 {object} dto.Response
|
||||||
// @Failure 400 {object} dto.Response{data=[]dto.ValidateError} "参数验证失败"
|
// @Failure 400 {object} dto.Response{data=[]dto.ValidateError} "参数验证失败"
|
||||||
// @Failure 404 {object} dto.Response "文档块不存在"
|
// @Failure 404 {object} dto.Response "文档块不存在"
|
||||||
// @Router /documents/{document_id}/blocks/{block_id}/move [post]
|
// @Router /blocks/{block_id}/move [post]
|
||||||
func (c *DocumentController) MoveBlock(ctx *fiber.Ctx) error {
|
func (c *DocumentController) MoveBlock(ctx *fiber.Ctx) error {
|
||||||
var params dto.BlockIDParam
|
var params dto.BlockIDParam
|
||||||
if err := ctx.ParamsParser(¶ms); err != nil {
|
if err := ctx.ParamsParser(¶ms); err != nil {
|
||||||
@ -460,14 +587,44 @@ func (c *DocumentController) MoveBlock(ctx *fiber.Ctx) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if validationErrors, ok, err := validator.Struct(req); !ok {
|
// 获取块信息
|
||||||
if err != nil {
|
block, err := c.documentService.GetBlock(ctx.Context(), params.ID)
|
||||||
return err
|
if err != nil {
|
||||||
}
|
return err
|
||||||
return dto.Ctx(ctx).Data(validationErrors).Status(fiber.StatusBadRequest).Send()
|
}
|
||||||
|
if block == nil {
|
||||||
|
return dto.Ctx(ctx).Error(errs.ErrBlockNotExists).Status(fiber.StatusNotFound).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
err := c.documentService.MoveBlock(ctx.Context(), params.ID, req.AfterBlockID)
|
// 检查文档是否存在
|
||||||
|
doc, err := c.documentService.Get(ctx.Context(), block.DocumentId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if doc == nil {
|
||||||
|
return dto.Ctx(ctx).Error(errs.ErrDocumentNotExists).Status(fiber.StatusNotFound).Send()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查用户是否有权限访问该文档
|
||||||
|
user := c.authService.GetUser(ctx)
|
||||||
|
collection, err := c.collectionService.Get(ctx.Context(), doc.CollectionId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
workspace, err := c.workspaceService.Get(ctx.Context(), collection.WorkspaceId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
isMember, err := c.workspaceService.IsMember(ctx.Context(), user.ID, workspace)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !isMember {
|
||||||
|
return dto.Ctx(ctx).Error(errs.ErrNoPermission).Status(fiber.StatusForbidden).Send()
|
||||||
|
}
|
||||||
|
|
||||||
|
err = c.documentService.MoveBlock(ctx.Context(), params.ID, req.AfterBlockID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,8 @@ func (a *Api) V1(r fiber.Router) {
|
|||||||
{
|
{
|
||||||
collections.Post("/", a.HttpHandler.Collection.CreateCollection)
|
collections.Post("/", a.HttpHandler.Collection.CreateCollection)
|
||||||
collections.Get("/:id", a.HttpHandler.Collection.GetCollection)
|
collections.Get("/:id", a.HttpHandler.Collection.GetCollection)
|
||||||
|
collections.Put("/:id", a.HttpHandler.Collection.UpdateCollection)
|
||||||
|
collections.Delete("/:id", a.HttpHandler.Collection.DeleteCollection)
|
||||||
|
|
||||||
// 集合下的文档
|
// 集合下的文档
|
||||||
collections.Get("/:collection_id/documents", a.HttpHandler.Document.ListDocuments)
|
collections.Get("/:collection_id/documents", a.HttpHandler.Document.ListDocuments)
|
||||||
@ -73,9 +75,4 @@ func (a *Api) V1(r fiber.Router) {
|
|||||||
blocks.Post("/:block_id/move", a.HttpHandler.Document.MoveBlock)
|
blocks.Post("/:block_id/move", a.HttpHandler.Document.MoveBlock)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// guest := r.Group("/api/v1")
|
|
||||||
// {
|
|
||||||
// guest.Get("/guest_ping", a.HttpHandler.User.Test)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -254,3 +254,8 @@ func (s *Service) List(ctx context.Context, collectionId dto.EntityId, parentId
|
|||||||
|
|
||||||
return q.Find()
|
return q.Find()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetBlock 获取文档块
|
||||||
|
func (s *Service) GetBlock(ctx context.Context, blockId dto.EntityId) (*entity.DocumentBlock, error) {
|
||||||
|
return s.dao.DocumentBlock.Where(s.dao.DocumentBlock.ID.Eq(blockId.Uint())).First()
|
||||||
|
}
|
||||||
|
@ -20,3 +20,8 @@ type DeleteCollectionRequest struct {
|
|||||||
type ListCollectionsRequest struct {
|
type ListCollectionsRequest struct {
|
||||||
WorkspaceID EntityId `params:"workspace_id"`
|
WorkspaceID EntityId `params:"workspace_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateCollectionRequest 更新集合请求
|
||||||
|
type UpdateCollectionRequest struct {
|
||||||
|
Name string `json:"name" validate:"required|minLen:1"`
|
||||||
|
}
|
||||||
|
@ -8,4 +8,5 @@ var (
|
|||||||
ErrNoPermission = errors.New("no permission")
|
ErrNoPermission = errors.New("no permission")
|
||||||
ErrDocumentNotExists = errors.New("document not exists")
|
ErrDocumentNotExists = errors.New("document not exists")
|
||||||
ErrInvalidParentDocument = errors.New("invalid parent document")
|
ErrInvalidParentDocument = errors.New("invalid parent document")
|
||||||
|
ErrBlockNotExists = errors.New("block not exists")
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user