- 前端: React 18 + TypeScript + Vite + Tailwind CSS + shadcn/ui - 后端: Go + Gin + GORM + JWT (golang-jwt/jwt/v5) - 功能: 服务器管理、K8s集群、监控告警、CI/CD、自动化运维、审批流程、审计日志 - 文档: 设计文档(ROADMAP/PDD/架构/模块)
99 lines
3.4 KiB
Go
99 lines
3.4 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// NavigationGroup 导航分组模型
|
|
type NavigationGroup struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
Name string `gorm:"size:64;not null" json:"name"`
|
|
Code string `gorm:"size:64;uniqueIndex;not null" json:"code"`
|
|
Description string `gorm:"size:255" json:"description"`
|
|
Icon string `gorm:"size:64" json:"icon"`
|
|
Sort int `gorm:"default:0" json:"sort"`
|
|
Enabled bool `gorm:"default:true" json:"enabled"`
|
|
LinkCount int `gorm:"default:0" json:"link_count"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
|
}
|
|
|
|
// TableName 表名
|
|
func (NavigationGroup) TableName() string {
|
|
return "navigation_groups"
|
|
}
|
|
|
|
// NavigationLink 导航链接模型
|
|
type NavigationLink struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
GroupID uint `json:"group_id"`
|
|
Name string `gorm:"size:128;not null" json:"name"`
|
|
URL string `gorm:"size:500;not null" json:"url"`
|
|
Description string `gorm:"size:255" json:"description"`
|
|
Icon string `gorm:"size:64" json:"icon"`
|
|
Tags string `gorm:"type:text" json:"tags"` // JSON
|
|
IsFavorite bool `gorm:"default:false" json:"is_favorite"`
|
|
Sort int `gorm:"default:0" json:"sort"`
|
|
Enabled bool `gorm:"default:true" json:"enabled"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
|
|
|
// 关联
|
|
Group *NavigationGroup `json:"group,omitempty"`
|
|
}
|
|
|
|
// TableName 表名
|
|
func (NavigationLink) TableName() string {
|
|
return "navigation_links"
|
|
}
|
|
|
|
// CreateNavigationGroupRequest 创建导航分组请求
|
|
type CreateNavigationGroupRequest struct {
|
|
Name string `json:"name" binding:"required"`
|
|
Code string `json:"code" binding:"required"`
|
|
Description string `json:"description"`
|
|
Icon string `json:"icon"`
|
|
Sort int `json:"sort"`
|
|
}
|
|
|
|
// UpdateNavigationGroupRequest 更新导航分组请求
|
|
type UpdateNavigationGroupRequest struct {
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
Icon string `json:"icon"`
|
|
Sort int `json:"sort"`
|
|
Enabled *bool `json:"enabled"`
|
|
}
|
|
|
|
// CreateNavigationLinkRequest 创建导航链接请求
|
|
type CreateNavigationLinkRequest struct {
|
|
GroupID uint `json:"group_id" binding:"required"`
|
|
Name string `json:"name" binding:"required"`
|
|
URL string `json:"url" binding:"required,url"`
|
|
Description string `json:"description"`
|
|
Icon string `json:"icon"`
|
|
Tags []string `json:"tags"`
|
|
Sort int `json:"sort"`
|
|
}
|
|
|
|
// UpdateNavigationLinkRequest 更新导航链接请求
|
|
type UpdateNavigationLinkRequest struct {
|
|
GroupID uint `json:"group_id"`
|
|
Name string `json:"name"`
|
|
URL string `json:"url" binding:"omitempty,url"`
|
|
Description string `json:"description"`
|
|
Icon string `json:"icon"`
|
|
Tags []string `json:"tags"`
|
|
Sort int `json:"sort"`
|
|
Enabled *bool `json:"enabled"`
|
|
}
|
|
|
|
// ToggleFavoriteRequest 切换收藏请求
|
|
type ToggleFavoriteRequest struct {
|
|
IsFavorite bool `json:"is_favorite"`
|
|
}
|