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
This commit is contained in:
66
cmd/main.go
Normal file
66
cmd/main.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"giteapm/config"
|
||||
"giteapm/internal/api"
|
||||
"giteapm/internal/models"
|
||||
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var configPath string
|
||||
flag.StringVar(&configPath, "config", "config/config.yaml", "配置文件路径")
|
||||
flag.Parse()
|
||||
|
||||
cfg, err := config.Load(configPath)
|
||||
if err != nil {
|
||||
log.Fatalf("加载配置失败: %v", err)
|
||||
}
|
||||
|
||||
db, err := models.InitDB(cfg.Database)
|
||||
if err != nil {
|
||||
log.Fatalf("数据库初始化失败: %v", err)
|
||||
}
|
||||
|
||||
if cfg.Server.Mode == "release" {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
|
||||
router := gin.Default()
|
||||
|
||||
router.Use(cors.New(cors.Config{
|
||||
AllowOrigins: cfg.CORS.AllowOrigins,
|
||||
AllowMethods: cfg.CORS.AllowMethods,
|
||||
AllowHeaders: cfg.CORS.AllowHeaders,
|
||||
AllowCredentials: cfg.CORS.AllowCredentials,
|
||||
}))
|
||||
|
||||
router.Static("/static", "web/static")
|
||||
|
||||
router.GET("/", func(c *gin.Context) {
|
||||
log.Printf("访问首页")
|
||||
c.File("web/templates/index.html")
|
||||
})
|
||||
|
||||
// 添加测试路由来验证OAuth配置
|
||||
router.GET("/test-oauth", func(c *gin.Context) {
|
||||
authURL := fmt.Sprintf("http://218.84.152.14:65001/login/oauth/authorize?client_id=%s&redirect_uri=%s&response_type=code&scope=read:user&state=test-state",
|
||||
cfg.Gitea.ClientID,
|
||||
"http://localhost:8080/api/v1/auth/callback")
|
||||
c.Redirect(302, authURL)
|
||||
})
|
||||
|
||||
api.SetupRoutes(router, db, cfg)
|
||||
|
||||
addr := fmt.Sprintf("%s:%d", cfg.Server.Host, cfg.Server.Port)
|
||||
log.Printf("服务启动在 %s", addr)
|
||||
if err := router.Run(addr); err != nil {
|
||||
log.Fatalf("服务启动失败: %v", err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user