Align backend workbench API with prototype

This commit is contained in:
2026-07-19 21:46:43 +08:00
parent 1fcec3e0b5
commit 03a5c52b72
8 changed files with 644 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ func (h *Handler) Register(router gin.IRouter) {
router.POST("/projects", h.createProject)
router.GET("/projects", h.listProjects)
router.GET("/projects/:id/dashboard", h.dashboard)
router.GET("/projects/:id/workspace", h.workspace)
}
func (h *Handler) createProject(c *gin.Context) {
@@ -76,3 +77,22 @@ func (h *Handler) dashboard(c *gin.Context) {
}
c.JSON(http.StatusOK, dashboard)
}
func (h *Handler) workspace(c *gin.Context) {
userID, ok := auth.CurrentUserID(c)
if !ok {
c.JSON(http.StatusUnauthorized, gin.H{"error": "missing current user"})
return
}
projectID, err := strconv.ParseUint(c.Param("id"), 10, 64)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid project id"})
return
}
workspace, err := h.service.Workspace(userID, uint(projectID))
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to load workspace"})
return
}
c.JSON(http.StatusOK, workspace)
}