
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
64 lines
1.7 KiB
Go
64 lines
1.7 KiB
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"giteapm/internal/models"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func (h *Handlers) ListStories(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)
|
|
}
|
|
}
|
|
if epicID := c.Query("epic_id"); epicID != "" {
|
|
if id, err := strconv.ParseUint(epicID, 10, 32); err == nil {
|
|
filters["epic_id"] = uint(id)
|
|
}
|
|
}
|
|
|
|
stories, total, err := models.ListStories(offset, limit, filters)
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, ErrorResponse(500, "获取Story列表失败"))
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, PaginatedSuccessResponse(stories, total, page, limit))
|
|
}
|
|
|
|
func (h *Handlers) CreateStory(c *gin.Context) {
|
|
c.JSON(http.StatusNotImplemented, ErrorResponse(501, "功能暂未实现"))
|
|
}
|
|
|
|
func (h *Handlers) GetStory(c *gin.Context) {
|
|
id, err := strconv.ParseUint(c.Param("id"), 10, 32)
|
|
if err != nil {
|
|
c.JSON(http.StatusBadRequest, ErrorResponse(400, "无效的Story ID"))
|
|
return
|
|
}
|
|
|
|
story, err := models.GetStoryByID(uint(id))
|
|
if err != nil {
|
|
c.JSON(http.StatusNotFound, ErrorResponse(404, "Story不存在"))
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, SuccessResponse(story))
|
|
}
|
|
|
|
func (h *Handlers) UpdateStory(c *gin.Context) {
|
|
c.JSON(http.StatusNotImplemented, ErrorResponse(501, "功能暂未实现"))
|
|
}
|
|
|
|
func (h *Handlers) DeleteStory(c *gin.Context) {
|
|
c.JSON(http.StatusNotImplemented, ErrorResponse(501, "功能暂未实现"))
|
|
} |