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:
88
internal/models/gitea.go
Normal file
88
internal/models/gitea.go
Normal file
@@ -0,0 +1,88 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type GiteaRelation struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
TaskID uint `json:"task_id"`
|
||||
GiteaRepoID uint `json:"gitea_repo_id"`
|
||||
GiteaRepoName string `json:"gitea_repo_name"`
|
||||
RelationType string `json:"relation_type" gorm:"type:varchar(50)"`
|
||||
GiteaObjectID string `json:"gitea_object_id" gorm:"type:varchar(255)"`
|
||||
GiteaObjectNumber *uint `json:"gitea_object_number"`
|
||||
GiteaObjectTitle string `json:"gitea_object_title"`
|
||||
GiteaObjectURL string `json:"gitea_object_url"`
|
||||
Task Task `json:"task" gorm:"foreignKey:TaskID"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type GiteaRelationType string
|
||||
|
||||
const (
|
||||
RelationTypeBranch GiteaRelationType = "branch"
|
||||
RelationTypeCommit GiteaRelationType = "commit"
|
||||
RelationTypePullRequest GiteaRelationType = "pull_request"
|
||||
RelationTypeIssue GiteaRelationType = "issue"
|
||||
)
|
||||
|
||||
type WebhookConfig struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
ProjectID uint `json:"project_id"`
|
||||
GiteaRepoID uint `json:"gitea_repo_id"`
|
||||
GiteaRepoName string `json:"gitea_repo_name"`
|
||||
WebhookURL string `json:"webhook_url"`
|
||||
Secret string `json:"secret"`
|
||||
Events string `json:"events"` // JSON string
|
||||
Active bool `json:"active" gorm:"default:true"`
|
||||
Project Project `json:"project" gorm:"foreignKey:ProjectID"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func CreateGiteaRelation(relation *GiteaRelation) error {
|
||||
return DB.Create(relation).Error
|
||||
}
|
||||
|
||||
func GetGiteaRelationsByTask(taskID uint) ([]GiteaRelation, error) {
|
||||
var relations []GiteaRelation
|
||||
err := DB.Where("task_id = ?", taskID).Find(&relations).Error
|
||||
return relations, err
|
||||
}
|
||||
|
||||
func GetGiteaRelationsByRepo(repoID uint, relationType string) ([]GiteaRelation, error) {
|
||||
var relations []GiteaRelation
|
||||
query := DB.Where("gitea_repo_id = ?", repoID)
|
||||
if relationType != "" {
|
||||
query = query.Where("relation_type = ?", relationType)
|
||||
}
|
||||
err := query.Preload("Task").Find(&relations).Error
|
||||
return relations, err
|
||||
}
|
||||
|
||||
func UpdateGiteaRelation(relation *GiteaRelation) error {
|
||||
return DB.Save(relation).Error
|
||||
}
|
||||
|
||||
func DeleteGiteaRelation(id uint) error {
|
||||
return DB.Delete(&GiteaRelation{}, id).Error
|
||||
}
|
||||
|
||||
func CreateWebhookConfig(config *WebhookConfig) error {
|
||||
return DB.Create(config).Error
|
||||
}
|
||||
|
||||
func GetWebhookConfigByRepo(repoID uint) (*WebhookConfig, error) {
|
||||
var config WebhookConfig
|
||||
err := DB.Where("gitea_repo_id = ?", repoID).First(&config).Error
|
||||
return &config, err
|
||||
}
|
||||
|
||||
func UpdateWebhookConfig(config *WebhookConfig) error {
|
||||
return DB.Save(config).Error
|
||||
}
|
||||
|
||||
func DeleteWebhookConfig(id uint) error {
|
||||
return DB.Delete(&WebhookConfig{}, id).Error
|
||||
}
|
Reference in New Issue
Block a user