数据结构优化
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Experience struct {
|
||||
Year string `json:"year"`
|
||||
Role string `json:"role"`
|
||||
Company string `json:"company"`
|
||||
}
|
||||
|
||||
// AboutProfile 关于我页面数据模型
|
||||
type AboutProfile struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
@@ -23,6 +20,7 @@ type AboutProfile struct {
|
||||
ExperiencesStr string `json:"-"` // Stored as string in DB
|
||||
ExperienceList []Experience `json:"experiences"` // Exposed as array in JSON
|
||||
IsPrimary bool `json:"isPrimary"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// AccessLog 访问日志 (用于统计流量)
|
||||
// AccessLog 访问日志模型
|
||||
type AccessLog struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
IP string `json:"ip"`
|
||||
UserAgent string `json:"user_agent"`
|
||||
Path string `json:"path"`
|
||||
Method string `json:"method"`
|
||||
StatusCode int `json:"status_code"`
|
||||
ResponseTime int64 `json:"response_time"` // 毫秒
|
||||
Region string `json:"region"` // IP归属地
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
IP string `json:"ip"`
|
||||
UserAgent string `json:"user_agent"`
|
||||
Path string `json:"path"`
|
||||
Method string `json:"method"`
|
||||
StatusCode int `json:"status_code"`
|
||||
ResponseTime int64 `json:"response_time"` // 毫秒
|
||||
Region string `json:"region"` // IP归属地
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
DeletedAt int64 `json:"deleted_at"`
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// Inquiry 合作咨询
|
||||
type Inquiry struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Company string `json:"company"`
|
||||
ContactMethod string `json:"contactMethod"` // email, wechat, phone
|
||||
ContactValue string `json:"contactValue"`
|
||||
Budget string `json:"budget"`
|
||||
Description string `json:"description"`
|
||||
Status int `json:"status"` // 0-Unread, 1-Read, 2-Contacted
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Company string `json:"company"`
|
||||
ContactMethod string `json:"contactMethod"` // email, wechat, phone
|
||||
ContactValue string `json:"contactValue"`
|
||||
Budget string `json:"budget"`
|
||||
Description string `json:"description"`
|
||||
Status int `json:"status"` // 0-Unread, 1-Read, 2-Contacted
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
// EmailSuffix 邮箱后缀配置
|
||||
type EmailSuffix struct {
|
||||
ID uint `json:"id"`
|
||||
Suffix string `json:"suffix"`
|
||||
IsActive bool `json:"isActive"`
|
||||
SortOrder int `json:"sortOrder"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID uint `json:"id"`
|
||||
Suffix string `json:"suffix"`
|
||||
IsActive bool `json:"isActive"`
|
||||
SortOrder int `json:"sortOrder"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// OperationLog 操作日志模型
|
||||
type OperationLog struct {
|
||||
ID uint `json:"id"`
|
||||
UserID uint `json:"userId"`
|
||||
Username string `json:"username"`
|
||||
IP string `json:"ip"`
|
||||
Path string `json:"path"`
|
||||
Method string `json:"method"`
|
||||
Params string `json:"params"`
|
||||
Status int `json:"status"`
|
||||
Duration int `json:"duration"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
ID uint `json:"id"`
|
||||
UserID uint `json:"userId"`
|
||||
Username string `json:"username"`
|
||||
IP string `json:"ip"`
|
||||
Path string `json:"path"`
|
||||
Method string `json:"method"`
|
||||
Params string `json:"params"`
|
||||
Status int `json:"status"`
|
||||
Duration int `json:"duration"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
// OperationLogResponse 操作日志响应模型
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Permission 权限模型
|
||||
type Permission struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Resource string `json:"resource"`
|
||||
Action string `json:"action"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Resource string `json:"resource"`
|
||||
Action string `json:"action"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
// PermissionResponse 权限响应模型
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Post 博客文章模型
|
||||
type Post struct {
|
||||
ID uint `json:"id"`
|
||||
OriginalID string `json:"originalId,omitempty"` // For backward compatibility
|
||||
Title string `json:"title"`
|
||||
Category string `json:"category"`
|
||||
Date string `json:"date"` // YYYY-MM-DD
|
||||
Excerpt string `json:"excerpt"`
|
||||
Content string `json:"content"`
|
||||
ReadCount uint `json:"readCount"`
|
||||
IsPublished int `json:"isPublished"` // 0: draft, 1: published
|
||||
Tags []Tag `json:"tags"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID uint `json:"id"`
|
||||
OriginalID string `json:"originalId,omitempty"` // For backward compatibility
|
||||
Title string `json:"title"`
|
||||
Category string `json:"category"`
|
||||
// Date Removed from DB
|
||||
Excerpt string `json:"excerpt"`
|
||||
Content string `json:"content"`
|
||||
ReadCount uint `json:"readCount"`
|
||||
IsPublished int `json:"isPublished"` // 0: draft, 1: published
|
||||
Tags []Tag `json:"tags"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
// PostResponse 博客文章响应模型
|
||||
@@ -32,34 +29,35 @@ type PostResponse struct {
|
||||
|
||||
// Tag 标签模型
|
||||
type Tag struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Slug string `json:"slug"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Slug string `json:"slug"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
// PostTag 文章标签关联模型
|
||||
type PostTag struct {
|
||||
PostID string `json:"postId"`
|
||||
TagID uint `json:"tagId"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
PostID string `json:"postId"`
|
||||
TagID uint `json:"tagId"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
}
|
||||
|
||||
// PostHistory 文章历史记录模型
|
||||
type PostHistory struct {
|
||||
ID uint `json:"id"`
|
||||
PostID uint `json:"postId"`
|
||||
Version int `json:"version"`
|
||||
Title string `json:"title"`
|
||||
Category string `json:"category"`
|
||||
Date string `json:"date"`
|
||||
Excerpt string `json:"excerpt"`
|
||||
Content string `json:"content"`
|
||||
IsPublished int `json:"isPublished"`
|
||||
ModifiedBy uint `json:"modifiedBy"`
|
||||
ModifiedAt time.Time `json:"modifiedAt"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
ID uint `json:"id"`
|
||||
PostID uint `json:"postId"`
|
||||
Version int `json:"version"`
|
||||
Title string `json:"title"`
|
||||
Category string `json:"category"`
|
||||
// Date Removed
|
||||
Excerpt string `json:"excerpt"`
|
||||
Content string `json:"content"`
|
||||
IsPublished int `json:"isPublished"`
|
||||
ModifiedBy uint `json:"modifiedBy"`
|
||||
ModifiedAt int64 `json:"modifiedAt"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
}
|
||||
|
||||
// PostHistoryResponse 文章历史记录响应模型
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Role 角色模型
|
||||
type Role struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Permissions []Permission `json:"permissions,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
// RoleResponse 角色响应模型
|
||||
|
||||
@@ -1,30 +1,28 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Testimonial 客户评价模型
|
||||
type Testimonial struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Role string `json:"role"`
|
||||
Content string `json:"content"`
|
||||
Avatar string `json:"avatar"`
|
||||
Rating uint8 `json:"rating"`
|
||||
SortOrder uint `json:"sortOrder"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Role string `json:"role"`
|
||||
Content string `json:"content"`
|
||||
Avatar string `json:"avatar"`
|
||||
Rating uint8 `json:"rating"`
|
||||
SortOrder uint `json:"sortOrder"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
// Partner 合作伙伴模型
|
||||
type Partner struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Logo string `json:"logo"`
|
||||
Description string `json:"description"`
|
||||
URL string `json:"url"`
|
||||
SortOrder uint `json:"sortOrder"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Logo string `json:"logo"`
|
||||
Description string `json:"description"`
|
||||
URL string `json:"url"`
|
||||
SortOrder uint `json:"sortOrder"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Setting 系统配置模型
|
||||
type Setting struct {
|
||||
ID uint `json:"id"`
|
||||
KeyName string `json:"keyName"`
|
||||
Value string `json:"value"`
|
||||
Description string `json:"description"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID uint `json:"id"`
|
||||
KeyName string `json:"keyName"`
|
||||
Value string `json:"value"`
|
||||
Description string `json:"description"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
// SettingResponse 系统配置响应模型
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Snippet 代码片段模型
|
||||
type Snippet struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Code string `json:"code"`
|
||||
Type string `json:"type"`
|
||||
Description string `json:"description"`
|
||||
ViewCount uint `json:"viewCount"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Code string `json:"code"`
|
||||
Type string `json:"type"`
|
||||
Description string `json:"description"`
|
||||
ViewCount uint `json:"viewCount"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
// SnippetResponse 代码片段响应模型
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// User 用户模型
|
||||
type User struct {
|
||||
ID uint `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
PasswordHash string `json:"-"`
|
||||
RoleID uint `json:"roleId"`
|
||||
Role string `json:"role"` // 保持兼容,或者作为Role Name
|
||||
IsActive int `json:"isActive"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID uint `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
PasswordHash string `json:"-"`
|
||||
RoleID uint `json:"roleId"`
|
||||
Role string `json:"role"` // 保持兼容,或者作为Role Name
|
||||
IsActive int `json:"isActive"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
// UserResponse 用户响应模型
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// UserAccessLog 用户访问记录模型
|
||||
// UserAccessLog 用户访问日志模型
|
||||
type UserAccessLog struct {
|
||||
ID uint `json:"id"`
|
||||
UserID uint `json:"user_id"` // 用户ID(未登录用户为0)
|
||||
UserIP string `json:"user_ip"` // 用户IP地址
|
||||
UserLocation string `json:"user_location"` // 用户归属地
|
||||
ArticleID uint `json:"article_id"` // 访问的文章ID
|
||||
AccessTime time.Time `json:"access_time"` // 访问时间
|
||||
ID uint `json:"id"`
|
||||
UserID uint `json:"user_id"` // 用户ID(未登录用户为0)
|
||||
UserIP string `json:"user_ip"` // 用户IP地址
|
||||
UserLocation string `json:"user_location"` // 用户归属地
|
||||
ArticleID uint `json:"article_id"` // 访问的文章ID
|
||||
AccessTime int64 `json:"access_time"` // 访问时间
|
||||
DeletedAt int64 `json:"deleted_at"`
|
||||
}
|
||||
|
||||
@@ -1,39 +1,38 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Work 作品模型
|
||||
type Work struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Category string `json:"category"`
|
||||
Year string `json:"year"`
|
||||
HeroImg string `json:"heroImg"`
|
||||
Description string `json:"desc"`
|
||||
IsFeatured int `json:"isFeatured"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Category string `json:"category"`
|
||||
Year string `json:"year"`
|
||||
HeroImg string `json:"heroImg"`
|
||||
Description string `json:"desc"`
|
||||
IsFeatured int `json:"isFeatured"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
// WorkTechStack 作品技术栈模型
|
||||
type WorkTechStack struct {
|
||||
ID uint `json:"id"`
|
||||
WorkID string `json:"workId"`
|
||||
Category string `json:"category"`
|
||||
Item string `json:"item"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
ID uint `json:"id"`
|
||||
WorkID string `json:"workId"`
|
||||
Category string `json:"category"`
|
||||
Item string `json:"item"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
// WorkGallery 作品图库模型
|
||||
type WorkGallery struct {
|
||||
ID uint `json:"id"`
|
||||
WorkID string `json:"workId"`
|
||||
ImageURL string `json:"imageUrl"`
|
||||
SortOrder uint `json:"sortOrder"`
|
||||
Description string `json:"description"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
ID uint `json:"id"`
|
||||
WorkID string `json:"workId"`
|
||||
ImageURL string `json:"imageUrl"`
|
||||
SortOrder uint `json:"sortOrder"`
|
||||
Description string `json:"description"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
// WorkResponse 作品响应模型,包含关联数据
|
||||
|
||||
Reference in New Issue
Block a user