feat: 官网 + 管理端 + Gin/GORM 后端首个完整版本

- web/: 产品官网(Hero 事件流终端、功能矩阵、架构、快速开始、下载、博客 + Markdown 详情页),青瓷绿双主题
- admin/: 内容管理(JWT 登录、文章分页/搜索/CRUD、草稿与发布),embed 挂 /admin
- server/: Gin + GORM,MySQL(DSN 走 .env,SQLite 兜底);规范落地:sundynix_ 表前缀、字符串雪花主键、snake_case 列名、统一响应信封、公共分页参数
- 双 SPA embed 单二进制部署,make build 一键出包

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Blizzard
2026-07-17 11:03:31 +08:00
parent d46267dde1
commit 5abc705eae
53 changed files with 5774 additions and 38 deletions
+25
View File
@@ -0,0 +1,25 @@
package model
import (
"time"
"gorm.io/gorm"
"git.sundynix.cn/Blizzard/sundynix-site/server/internal/pkg/idgen"
)
// BaseModel 所有表的公共字段:字符串雪花主键 + 时间戳。
// 列名由 GORM NamingStrategy 统一转 snake_case。
type BaseModel struct {
ID string `gorm:"primaryKey;size:20" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// BeforeCreate 主键为空时自动生成雪花 ID。
func (m *BaseModel) BeforeCreate(*gorm.DB) error {
if m.ID == "" {
m.ID = idgen.Next()
}
return nil
}
+27
View File
@@ -0,0 +1,27 @@
package model
import "time"
// Post 博客文章,表名 sundynix_postNamingStrategy 统一加前缀)。
// Content 为 Markdown 原文,渲染交给前端;PublishedAt 为空即草稿。
type Post struct {
BaseModel
Slug string `gorm:"uniqueIndex;size:128" json:"slug"`
Title string `gorm:"size:256" json:"title"`
Category string `gorm:"size:64;index" json:"category"`
Summary string `gorm:"size:512" json:"summary"`
Content string `gorm:"type:text" json:"content,omitempty"`
PublishedAt *time.Time `gorm:"index" json:"published_at"`
}
// PostListItem 列表项投影,不带正文。
type PostListItem struct {
ID string `json:"id"`
Slug string `json:"slug"`
Title string `json:"title"`
Category string `json:"category"`
Summary string `json:"summary"`
PublishedAt *time.Time `json:"published_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}