
Features: - Complete project management system with Epic/Story/Task hierarchy - Vue.js 3 + Element Plus frontend with kanban board - Go backend with Gin framework and GORM - OAuth2 integration with Gitea - Docker containerization with MySQL - RESTful API for project, task, and user management - JWT authentication and authorization - Responsive web interface with dashboard
81 lines
2.1 KiB
Go
81 lines
2.1 KiB
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"giteapm/internal/models"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func (h *Handlers) ListSprints(c *gin.Context) {
|
|
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
|
|
limit, _ := strconv.Atoi(c.DefaultQuery("limit", "20"))
|
|
offset := (page - 1) * limit
|
|
|
|
filters := make(map[string]interface{})
|
|
if projectID := c.Query("project_id"); projectID != "" {
|
|
if id, err := strconv.ParseUint(projectID, 10, 32); err == nil {
|
|
filters["project_id"] = uint(id)
|
|
}
|
|
}
|
|
|
|
sprints, total, err := models.ListSprints(offset, limit, filters)
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, ErrorResponse(500, "获取迭代列表失败"))
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, PaginatedSuccessResponse(sprints, total, page, limit))
|
|
}
|
|
|
|
func (h *Handlers) CreateSprint(c *gin.Context) {
|
|
c.JSON(http.StatusNotImplemented, ErrorResponse(501, "功能暂未实现"))
|
|
}
|
|
|
|
func (h *Handlers) GetSprint(c *gin.Context) {
|
|
id, err := strconv.ParseUint(c.Param("id"), 10, 32)
|
|
if err != nil {
|
|
c.JSON(http.StatusBadRequest, ErrorResponse(400, "无效的迭代ID"))
|
|
return
|
|
}
|
|
|
|
sprint, err := models.GetSprintByID(uint(id))
|
|
if err != nil {
|
|
c.JSON(http.StatusNotFound, ErrorResponse(404, "迭代不存在"))
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, SuccessResponse(sprint))
|
|
}
|
|
|
|
func (h *Handlers) UpdateSprint(c *gin.Context) {
|
|
c.JSON(http.StatusNotImplemented, ErrorResponse(501, "功能暂未实现"))
|
|
}
|
|
|
|
func (h *Handlers) DeleteSprint(c *gin.Context) {
|
|
c.JSON(http.StatusNotImplemented, ErrorResponse(501, "功能暂未实现"))
|
|
}
|
|
|
|
func (h *Handlers) GetSprintBurndown(c *gin.Context) {
|
|
id, err := strconv.ParseUint(c.Param("id"), 10, 32)
|
|
if err != nil {
|
|
c.JSON(http.StatusBadRequest, ErrorResponse(400, "无效的迭代ID"))
|
|
return
|
|
}
|
|
|
|
sprint, err := models.GetSprintByID(uint(id))
|
|
if err != nil {
|
|
c.JSON(http.StatusNotFound, ErrorResponse(404, "迭代不存在"))
|
|
return
|
|
}
|
|
|
|
burndownData, err := sprint.GetBurndownData()
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, ErrorResponse(500, "获取燃尽图数据失败"))
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, SuccessResponse(burndownData))
|
|
} |