
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
60 lines
1.1 KiB
Go
60 lines
1.1 KiB
Go
package handlers
|
|
|
|
import (
|
|
"giteapm/config"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Handlers struct {
|
|
DB *gorm.DB
|
|
Cfg *config.Config
|
|
}
|
|
|
|
func NewHandlers(db *gorm.DB, cfg *config.Config) *Handlers {
|
|
return &Handlers{
|
|
DB: db,
|
|
Cfg: cfg,
|
|
}
|
|
}
|
|
|
|
type Response struct {
|
|
Code int `json:"code"`
|
|
Message string `json:"message"`
|
|
Data interface{} `json:"data,omitempty"`
|
|
}
|
|
|
|
type PaginatedResponse struct {
|
|
Code int `json:"code"`
|
|
Message string `json:"message"`
|
|
Data interface{} `json:"data"`
|
|
Total int64 `json:"total"`
|
|
Page int `json:"page"`
|
|
Limit int `json:"limit"`
|
|
}
|
|
|
|
func SuccessResponse(data interface{}) Response {
|
|
return Response{
|
|
Code: 200,
|
|
Message: "success",
|
|
Data: data,
|
|
}
|
|
}
|
|
|
|
func ErrorResponse(code int, message string) Response {
|
|
return Response{
|
|
Code: code,
|
|
Message: message,
|
|
}
|
|
}
|
|
|
|
func PaginatedSuccessResponse(data interface{}, total int64, page, limit int) PaginatedResponse {
|
|
return PaginatedResponse{
|
|
Code: 200,
|
|
Message: "success",
|
|
Data: data,
|
|
Total: total,
|
|
Page: page,
|
|
Limit: limit,
|
|
}
|
|
} |