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:
@@ -30,7 +30,7 @@ type UserQuery struct {
|
||||
order []user.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.User
|
||||
withAPIKeys *ApiKeyQuery
|
||||
withAPIKeys *APIKeyQuery
|
||||
withRedeemCodes *RedeemCodeQuery
|
||||
withSubscriptions *UserSubscriptionQuery
|
||||
withAssignedSubscriptions *UserSubscriptionQuery
|
||||
@@ -75,8 +75,8 @@ func (_q *UserQuery) Order(o ...user.OrderOption) *UserQuery {
|
||||
}
|
||||
|
||||
// QueryAPIKeys chains the current query on the "api_keys" edge.
|
||||
func (_q *UserQuery) QueryAPIKeys() *ApiKeyQuery {
|
||||
query := (&ApiKeyClient{config: _q.config}).Query()
|
||||
func (_q *UserQuery) QueryAPIKeys() *APIKeyQuery {
|
||||
query := (&APIKeyClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
@@ -458,8 +458,8 @@ func (_q *UserQuery) Clone() *UserQuery {
|
||||
|
||||
// WithAPIKeys tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "api_keys" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *UserQuery) WithAPIKeys(opts ...func(*ApiKeyQuery)) *UserQuery {
|
||||
query := (&ApiKeyClient{config: _q.config}).Query()
|
||||
func (_q *UserQuery) WithAPIKeys(opts ...func(*APIKeyQuery)) *UserQuery {
|
||||
query := (&APIKeyClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
@@ -653,8 +653,8 @@ func (_q *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e
|
||||
}
|
||||
if query := _q.withAPIKeys; query != nil {
|
||||
if err := _q.loadAPIKeys(ctx, query, nodes,
|
||||
func(n *User) { n.Edges.APIKeys = []*ApiKey{} },
|
||||
func(n *User, e *ApiKey) { n.Edges.APIKeys = append(n.Edges.APIKeys, e) }); err != nil {
|
||||
func(n *User) { n.Edges.APIKeys = []*APIKey{} },
|
||||
func(n *User, e *APIKey) { n.Edges.APIKeys = append(n.Edges.APIKeys, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -712,7 +712,7 @@ func (_q *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (_q *UserQuery) loadAPIKeys(ctx context.Context, query *ApiKeyQuery, nodes []*User, init func(*User), assign func(*User, *ApiKey)) error {
|
||||
func (_q *UserQuery) loadAPIKeys(ctx context.Context, query *APIKeyQuery, nodes []*User, init func(*User), assign func(*User, *APIKey)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[int64]*User)
|
||||
for i := range nodes {
|
||||
@@ -725,7 +725,7 @@ func (_q *UserQuery) loadAPIKeys(ctx context.Context, query *ApiKeyQuery, nodes
|
||||
if len(query.ctx.Fields) > 0 {
|
||||
query.ctx.AppendFieldOnce(apikey.FieldUserID)
|
||||
}
|
||||
query.Where(predicate.ApiKey(func(s *sql.Selector) {
|
||||
query.Where(predicate.APIKey(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(user.APIKeysColumn), fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
|
||||
Reference in New Issue
Block a user