初始化
This commit is contained in:
33
server/models/operation_log.go
Normal file
33
server/models/operation_log.go
Normal file
@@ -0,0 +1,33 @@
|
||||
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"`
|
||||
}
|
||||
|
||||
// OperationLogResponse 操作日志响应模型
|
||||
type OperationLogResponse 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 string `json:"createdAt"`
|
||||
}
|
||||
25
server/models/permission.go
Normal file
25
server/models/permission.go
Normal file
@@ -0,0 +1,25 @@
|
||||
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"`
|
||||
}
|
||||
|
||||
// PermissionResponse 权限响应模型
|
||||
type PermissionResponse struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Resource string `json:"resource"`
|
||||
Action string `json:"action"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
UpdatedAt string `json:"updatedAt"`
|
||||
}
|
||||
75
server/models/post.go
Normal file
75
server/models/post.go
Normal file
@@ -0,0 +1,75 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Post 博客文章模型
|
||||
type Post struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Category string `json:"category"`
|
||||
Date time.Time `json:"date"`
|
||||
Excerpt string `json:"excerpt"`
|
||||
Content string `json:"content"`
|
||||
ReadCount uint `json:"readCount"`
|
||||
IsPublished int `json:"isPublished"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
// PostResponse 博客文章响应模型
|
||||
type PostResponse struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Category string `json:"category"`
|
||||
Date string `json:"date"`
|
||||
Excerpt string `json:"excerpt,omitempty"`
|
||||
Content string `json:"content,omitempty"`
|
||||
}
|
||||
|
||||
// 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"`
|
||||
}
|
||||
|
||||
// PostTag 文章标签关联模型
|
||||
type PostTag struct {
|
||||
PostID string `json:"postId"`
|
||||
TagID uint `json:"tagId"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
}
|
||||
|
||||
// PostHistory 文章历史记录模型
|
||||
type PostHistory struct {
|
||||
ID uint `json:"id"`
|
||||
PostID string `json:"postId"`
|
||||
Version uint `json:"version"`
|
||||
Title string `json:"title"`
|
||||
Category string `json:"category"`
|
||||
Date time.Time `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"`
|
||||
}
|
||||
|
||||
// PostHistoryResponse 文章历史记录响应模型
|
||||
type PostHistoryResponse struct {
|
||||
ID uint `json:"id"`
|
||||
PostID string `json:"postId"`
|
||||
Version uint `json:"version"`
|
||||
Title string `json:"title"`
|
||||
Category string `json:"category"`
|
||||
Date string `json:"date"`
|
||||
IsPublished int `json:"isPublished"`
|
||||
ModifiedBy uint `json:"modifiedBy"`
|
||||
ModifiedAt string `json:"modifiedAt"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
}
|
||||
25
server/models/role.go
Normal file
25
server/models/role.go
Normal file
@@ -0,0 +1,25 @@
|
||||
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"`
|
||||
}
|
||||
|
||||
// RoleResponse 角色响应模型
|
||||
type RoleResponse struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Permissions []PermissionResponse `json:"permissions,omitempty"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
UpdatedAt string `json:"updatedAt"`
|
||||
}
|
||||
25
server/models/setting.go
Normal file
25
server/models/setting.go
Normal file
@@ -0,0 +1,25 @@
|
||||
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"`
|
||||
}
|
||||
|
||||
// SettingResponse 系统配置响应模型
|
||||
type SettingResponse struct {
|
||||
ID uint `json:"id"`
|
||||
KeyName string `json:"keyName"`
|
||||
Value string `json:"value"`
|
||||
Description string `json:"description"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
UpdatedAt string `json:"updatedAt"`
|
||||
}
|
||||
25
server/models/snippet.go
Normal file
25
server/models/snippet.go
Normal file
@@ -0,0 +1,25 @@
|
||||
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"`
|
||||
}
|
||||
|
||||
// SnippetResponse 代码片段响应模型
|
||||
type SnippetResponse struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Code string `json:"code"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
43
server/models/user.go
Normal file
43
server/models/user.go
Normal file
@@ -0,0 +1,43 @@
|
||||
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"`
|
||||
}
|
||||
|
||||
// UserResponse 用户响应模型
|
||||
type UserResponse struct {
|
||||
ID uint `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
RoleID uint `json:"roleId"`
|
||||
Role string `json:"role"`
|
||||
IsActive int `json:"isActive"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
UpdatedAt string `json:"updatedAt"`
|
||||
}
|
||||
|
||||
// LoginRequest 登录请求模型
|
||||
type LoginRequest struct {
|
||||
Username string `json:"username" binding:"required"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
}
|
||||
|
||||
// LoginResponse 登录响应模型
|
||||
type LoginResponse struct {
|
||||
Token string `json:"token"`
|
||||
User UserResponse `json:"user"`
|
||||
Expire int64 `json:"expire"`
|
||||
}
|
||||
51
server/models/work.go
Normal file
51
server/models/work.go
Normal file
@@ -0,0 +1,51 @@
|
||||
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"`
|
||||
}
|
||||
|
||||
// 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"`
|
||||
}
|
||||
|
||||
// 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"`
|
||||
}
|
||||
|
||||
// WorkResponse 作品响应模型,包含关联数据
|
||||
type WorkResponse struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Category string `json:"category"`
|
||||
Year string `json:"year"`
|
||||
HeroImg string `json:"heroImg"`
|
||||
Desc string `json:"desc"`
|
||||
TechStack []map[string]interface{} `json:"techStack"`
|
||||
Gallery []string `json:"gallery"`
|
||||
Links map[string]interface{} `json:"links"`
|
||||
Next string `json:"next"`
|
||||
}
|
||||
Reference in New Issue
Block a user