feat: Add CodeSnippet entity and related functionality

- Introduced CodeSnippet schema with fields for snippet details and relationships to WorkspaceFile.
- Enhanced WorkspaceFileUpdate and WorkspaceFileUpdateOne to manage snippets, including adding, removing, and clearing snippet relationships.
- Updated Swagger documentation to include new API endpoints for CLI command execution and workspace file management.
- Implemented domain structures for handling code files and AST parsing results.
- Refactored Workspace and WorkspaceFile use cases to support new functionalities.
- Adjusted CLI command execution to handle code file information in JSON format.
- Improved error handling and logging throughout the workspace and file management processes.
This commit is contained in:
Haoxin Li
2025-07-25 19:35:00 +08:00
parent 0d8673a54d
commit 9388e149d6
33 changed files with 8023 additions and 106 deletions

View File

@@ -92,17 +92,20 @@ func (h *WorkspaceFileHandler) GetByID(c *web.Context, req struct {
return c.Success(file)
}
// GetAndSave
// @Tags WorkspaceFile
// @Summary 获取并保存工作区文件
// @param ctx
// @param req
// @return error
// GetAndSave
//
// @Tags WorkspaceFile
// @Summary 获取并保存工作区文件
// @Accept json
// @Produce json
// @Param req body domain.GetAndSaveReq true "请求参数"
// @Success 200 {object} web.Resp{}
// @Router /api/v1/workspace/files/get-and-save [post]
func (h *WorkspaceFileHandler) GetAndSave(ctx *web.Context, req *domain.GetAndSaveReq) error {
err := h.usecase.GetAndSave(ctx.Request().Context(), req)
err := h.usecase.GetAndSave(ctx.Request().Context(), req)
if err != nil {
h.logger.Error("failed to get and save workspace files", "error", err, "count", len(req.CodeFiles.Files))
return err
return err
}
return ctx.Success(nil)
}