first commit

Co-Authored-By: Codex <noreply@openai.com>
This commit is contained in:
HouYunFei
2026-05-19 07:53:53 +08:00
commit 472bf8b732
133 changed files with 16869 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
package model
type AssetType string
const (
AssetTypeText AssetType = "text"
AssetTypeImage AssetType = "image"
)
// Asset 素材记录。
type Asset struct {
ID string `json:"id" gorm:"primaryKey"`
Title string `json:"title"`
Type AssetType `json:"type"`
CoverURL string `json:"coverUrl"`
Tags []string `json:"tags" gorm:"serializer:json"`
Category string `json:"category"`
Description string `json:"description"`
Content string `json:"content,omitempty"`
URL string `json:"url,omitempty"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
// AssetList 素材分页结果。
type AssetList struct {
Items []Asset `json:"items"`
Tags []string `json:"tags"`
Total int `json:"total"`
}
+33
View File
@@ -0,0 +1,33 @@
package model
// Prompt 提示词记录。
type Prompt struct {
ID string `json:"id" gorm:"primaryKey"`
Title string `json:"title"`
CoverURL string `json:"coverUrl"`
Prompt string `json:"prompt"`
Tags []string `json:"tags" gorm:"serializer:json"`
Category string `json:"category" gorm:"index"`
GithubURL string `json:"githubUrl" gorm:"-"`
Preview string `json:"preview"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
// PromptList 提示词分页结果。
type PromptList struct {
Items []Prompt `json:"items"`
Tags []string `json:"tags"`
Categories []string `json:"categories"`
Total int `json:"total"`
}
// PromptCategory 提示词分类。
type PromptCategory struct {
Category string `json:"category" gorm:"primaryKey"`
Name string `json:"name"`
Description string `json:"description"`
GithubURL string `json:"githubUrl"`
Remote bool `json:"remote"`
UpdatedAt string `json:"updatedAt"`
}
+29
View File
@@ -0,0 +1,29 @@
package model
const MaxPageSize = 500
// Query 列表筛选和分页参数。
type Query struct {
Keyword string
Tags []string
Category string
Type string
Page int
PageSize int
}
func (q *Query) Normalize() {
if q.Page < 1 {
q.Page = 1
}
if q.PageSize < 1 {
q.PageSize = 20
}
if q.PageSize > MaxPageSize {
q.PageSize = MaxPageSize
}
}
func (q *Query) Offset() int {
return (q.Page - 1) * q.PageSize
}
+50
View File
@@ -0,0 +1,50 @@
package model
type UserRole string
const (
UserRoleGuest UserRole = "guest"
UserRoleUser UserRole = "user"
UserRoleAdmin UserRole = "admin"
)
// User 系统用户。
type User struct {
ID string `json:"id" gorm:"primaryKey"`
Username string `json:"username" gorm:"uniqueIndex"`
Password string `json:"password,omitempty"`
Role UserRole `json:"role"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
// UserList 用户分页结果。
type UserList struct {
Items []User `json:"items"`
Total int `json:"total"`
}
// AuthUser 用户公开信息。
type AuthUser struct {
ID string `json:"id"`
Username string `json:"username"`
Role UserRole `json:"role"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
// AuthSession 登录会话信息。
type AuthSession struct {
Token string `json:"token"`
User AuthUser `json:"user"`
}
func PublicUser(user User) AuthUser {
return AuthUser{
ID: user.ID,
Username: user.Username,
Role: user.Role,
CreatedAt: user.CreatedAt,
UpdatedAt: user.UpdatedAt,
}
}