Files
gitpm/internal/api/router.go
huxunan 885fad6c64 Initial commit: Gitea Project Management System
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
2025-09-22 14:53:53 +08:00

112 lines
2.8 KiB
Go

package api
import (
"giteapm/config"
"giteapm/internal/api/handlers"
"giteapm/internal/middleware"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
func SetupRoutes(router *gin.Engine, db *gorm.DB, cfg *config.Config) {
h := handlers.NewHandlers(db, cfg)
v1 := router.Group("/api/v1")
{
auth := v1.Group("/auth")
{
auth.GET("/login", h.GiteaLogin)
auth.GET("/callback", h.GiteaCallback)
auth.POST("/logout", h.Logout)
}
v1.Use(middleware.AuthMiddleware(cfg))
{
users := v1.Group("/users")
{
users.GET("", h.ListUsers)
users.GET("/:id", h.GetUser)
users.PUT("/:id", h.UpdateUser)
users.DELETE("/:id", middleware.RequireRole("admin"), h.DeleteUser)
users.GET("/me", h.GetCurrentUser)
users.PUT("/me", h.UpdateCurrentUser)
}
projects := v1.Group("/projects")
{
projects.GET("", h.ListProjects)
projects.POST("", h.CreateProject)
projects.GET("/:id", h.GetProject)
projects.PUT("/:id", h.UpdateProject)
projects.DELETE("/:id", h.DeleteProject)
projects.POST("/:id/members", h.AddProjectMember)
projects.DELETE("/:id/members/:user_id", h.RemoveProjectMember)
projects.GET("/:id/members", h.GetProjectMembers)
}
epics := v1.Group("/epics")
{
epics.GET("", h.ListEpics)
epics.POST("", h.CreateEpic)
epics.GET("/:id", h.GetEpic)
epics.PUT("/:id", h.UpdateEpic)
epics.DELETE("/:id", h.DeleteEpic)
}
stories := v1.Group("/stories")
{
stories.GET("", h.ListStories)
stories.POST("", h.CreateStory)
stories.GET("/:id", h.GetStory)
stories.PUT("/:id", h.UpdateStory)
stories.DELETE("/:id", h.DeleteStory)
}
tasks := v1.Group("/tasks")
{
tasks.GET("", h.ListTasks)
tasks.POST("", h.CreateTask)
tasks.GET("/:id", h.GetTask)
tasks.PUT("/:id", h.UpdateTask)
tasks.DELETE("/:id", h.DeleteTask)
tasks.POST("/:id/time-logs", h.LogTime)
tasks.GET("/:id/time-logs", h.GetTimeLogs)
tasks.POST("/:id/gitea-relations", h.LinkGiteaObject)
tasks.GET("/:id/gitea-relations", h.GetGiteaRelations)
}
sprints := v1.Group("/sprints")
{
sprints.GET("", h.ListSprints)
sprints.POST("", h.CreateSprint)
sprints.GET("/:id", h.GetSprint)
sprints.PUT("/:id", h.UpdateSprint)
sprints.DELETE("/:id", h.DeleteSprint)
sprints.GET("/:id/burndown", h.GetSprintBurndown)
}
comments := v1.Group("/comments")
{
comments.GET("", h.GetComments)
comments.POST("", h.CreateComment)
comments.PUT("/:id", h.UpdateComment)
comments.DELETE("/:id", h.DeleteComment)
}
tags := v1.Group("/tags")
{
tags.GET("", h.ListTags)
tags.POST("", h.CreateTag)
tags.PUT("/:id", h.UpdateTag)
tags.DELETE("/:id", h.DeleteTag)
}
webhooks := v1.Group("/webhooks")
{
webhooks.POST("/gitea", h.HandleGiteaWebhook)
}
}
}
}