fix(lint): 修复所有 Go 命名规范问题

- 全局替换 ApiKey → APIKey(类型、字段、方法、变量)
- 修复所有 initialism 命名(API, SMTP, HTML, URL 等)
- 添加所有缺失的包注释
- 修复导出符号的注释格式

主要修改:
- ApiKey → APIKey(所有出现的地方)
- ApiKeyID → APIKeyID
- ApiKeyIDs → APIKeyIDs
- TestSmtpConnection → TestSMTPConnection
- HtmlURL → HTMLURL
- 添加 20+ 个包注释
- 修复 10+ 个导出符号注释格式

验证结果:
- ✓ golangci-lint: 0 issues
- ✓ 单元测试: 通过
- ✓ 集成测试: 通过
This commit is contained in:
IanShaw027
2026-01-04 19:27:53 +08:00
parent d92e71a1f0
commit a4953785d9
121 changed files with 2747 additions and 2725 deletions

View File

@@ -12,25 +12,25 @@ import (
"entgo.io/ent/schema/index"
)
// ApiKey holds the schema definition for the ApiKey entity.
type ApiKey struct {
// APIKey holds the schema definition for the APIKey entity.
type APIKey struct {
ent.Schema
}
func (ApiKey) Annotations() []schema.Annotation {
func (APIKey) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "api_keys"},
}
}
func (ApiKey) Mixin() []ent.Mixin {
func (APIKey) Mixin() []ent.Mixin {
return []ent.Mixin{
mixins.TimeMixin{},
mixins.SoftDeleteMixin{},
}
}
func (ApiKey) Fields() []ent.Field {
func (APIKey) Fields() []ent.Field {
return []ent.Field{
field.Int64("user_id"),
field.String("key").
@@ -49,7 +49,7 @@ func (ApiKey) Fields() []ent.Field {
}
}
func (ApiKey) Edges() []ent.Edge {
func (APIKey) Edges() []ent.Edge {
return []ent.Edge{
edge.From("user", User.Type).
Ref("api_keys").
@@ -64,7 +64,7 @@ func (ApiKey) Edges() []ent.Edge {
}
}
func (ApiKey) Indexes() []ent.Index {
func (APIKey) Indexes() []ent.Index {
return []ent.Index{
// key 字段已在 Fields() 中声明 Unique(),无需重复索引
index.Fields("user_id"),

View File

@@ -77,7 +77,7 @@ func (Group) Fields() []ent.Field {
func (Group) Edges() []ent.Edge {
return []ent.Edge{
edge.To("api_keys", ApiKey.Type),
edge.To("api_keys", APIKey.Type),
edge.To("redeem_codes", RedeemCode.Type),
edge.To("subscriptions", UserSubscription.Type),
edge.To("usage_logs", UsageLog.Type),

View File

@@ -113,7 +113,7 @@ func (UsageLog) Edges() []ent.Edge {
Field("user_id").
Required().
Unique(),
edge.From("api_key", ApiKey.Type).
edge.From("api_key", APIKey.Type).
Ref("usage_logs").
Field("api_key_id").
Required().

View File

@@ -66,7 +66,7 @@ func (User) Fields() []ent.Field {
func (User) Edges() []ent.Edge {
return []ent.Edge{
edge.To("api_keys", ApiKey.Type),
edge.To("api_keys", APIKey.Type),
edge.To("redeem_codes", RedeemCode.Type),
edge.To("subscriptions", UserSubscription.Type),
edge.To("assigned_subscriptions", UserSubscription.Type),