Files
voidraft/internal/models/document.go
2025-07-02 12:10:46 +08:00

33 lines
801 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package models
import (
"time"
)
// Document represents a document in the system
type Document struct {
ID int64 `json:"id" db:"id"`
Title string `json:"title" db:"title"`
Content string `json:"content" db:"content"`
CreatedAt time.Time `json:"createdAt" db:"created_at"`
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
IsDeleted bool `json:"is_deleted"`
}
// NewDocument 创建新文档不需要传ID由数据库自增
func NewDocument(title, content string) *Document {
now := time.Now()
return &Document{
Title: title,
Content: content,
CreatedAt: now,
UpdatedAt: now,
IsDeleted: false,
}
}
// NewDefaultDocument 创建默认文档
func NewDefaultDocument() *Document {
return NewDocument("default", "∞∞∞text-a\n")
}