Files
go_blog/models/comment_config.go
kevin f307781f58 docs: 全部 Go 代码注释汉化
- 48 个 Go 文件所有注释(行注释/块注释/行尾注释,含 _test.go)翻译为中文
- 保留技术标识符:SECURITY_TODO(n)、unsafe-inline、sqlite/mysql、路由参数等
- 代码、字符串字面量、日志消息保持英文原文,零逻辑改动
- go build/vet 通过,go test -count=1 ./... 全绿
2026-08-27 19:03:03 +08:00

34 lines
1.4 KiB
Go
Raw Permalink 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"
// CommentConfig 保存单例(id=1)的全局评论策略。
type CommentConfig struct {
ID uint `gorm:"primarykey" json:"id"`
Enabled bool `gorm:"default:true" json:"enabled"` // 评论系统的总开关
AllowGuest bool `gorm:"default:true" json:"allow_guest"` // 是否允许匿名(非登录)评论
GuestRequireApproval bool `gorm:"default:false" json:"guest_require_approval"` // 将访客评论置于审核队列
// SECURITY_TODO #15Gravatar 可通过反向查询暴露 MD5(邮箱);
// 新部署默认关闭(管理员可显式重新启用)。
UseGravatar bool `gorm:"default:false" json:"use_gravatar"` // 为 false 时,头像显示为文本首字母占位
UpdatedBy uint `gorm:"index" json:"updated_by"`
UpdatedAt time.Time `json:"updated_at"`
}
// TableName 覆盖 GORM 默认的表名。
func (CommentConfig) TableName() string {
return "comment_configs"
}
// defaultCommentConfig 返回数据库行被初始化之前使用的内存回退值,
// 与初始化种子默认值保持一致。
func defaultCommentConfig() *CommentConfig {
return &CommentConfig{
ID: 1,
Enabled: true,
AllowGuest: true,
GuestRequireApproval: false,
UseGravatar: false,
}
}