leaf-library-3/internal/dto/document.go
2024-12-10 18:22:14 +08:00

72 lines
2.0 KiB
Go

package dto
// CreateDocumentRequest 创建文档请求
type CreateDocumentRequest struct {
Name string `json:"name" validate:"required|minLen:1"`
WorkspaceID EntityId `json:"workspace_id" validate:"required"`
CollectionID EntityId `json:"collection_id" validate:"required"`
ParentID *EntityId `json:"parent_id,omitempty"`
}
// GetDocumentRequest 获取文档请求
type GetDocumentRequest struct {
ID EntityId `params:"id"`
}
// DeleteDocumentRequest 删除文档请求
type DeleteDocumentRequest struct {
ID EntityId `params:"id"`
}
// UpdateDocumentRequest 更新文档请求
type UpdateDocumentRequest struct {
Name string `json:"name" validate:"required|minLen:1"`
}
// ListDocumentsPathParam 列出文档的路径参数
type ListDocumentsPathParam struct {
CollectionID EntityId `params:"collection_id"`
}
// ListDocumentsQueryParam 列出文档的查询参数
type ListDocumentsQueryParam struct {
ParentID *EntityId `query:"parent_id,omitempty"`
}
// CreateBlockRequest 创建文档块请求
type CreateBlockRequest struct {
Type string `json:"type" validate:"required"`
Content string `json:"content"`
AfterBlockID *EntityId `json:"after_block_id,omitempty"`
}
// GetBlockRequest 获取文档块请求
type GetBlockRequest struct {
ID EntityId `params:"block_id"`
}
// UpdateBlockRequest 更新文档块请求
type UpdateBlockRequest struct {
Content string `json:"content" validate:"required"`
}
// MoveBlockRequest 移动文档块请求
type MoveBlockRequest struct {
AfterBlockID *EntityId `json:"after_block_id,omitempty"`
}
// ListBlocksRequest 列出文档下的块请求
type ListBlocksRequest struct {
DocumentID EntityId `params:"document_id"`
}
// DocumentDTO 文档数据传输对象
type DocumentDTO struct {
BaseDTO
Name string `json:"name"`
WorkspaceID EntityId `json:"workspace_id"`
CollectionID EntityId `json:"collection_id"`
ParentID *EntityId `json:"parent_id,omitempty"`
HasChildren bool `json:"has_children"`
}