Skip to content

Commit 9d4ecde

Browse files
committed
fix lint errors
1 parent 9b81a99 commit 9d4ecde

3 files changed

Lines changed: 26 additions & 22 deletions

File tree

.github/workflows/server.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ jobs:
5151
- name: Generate code (ent & swagger)
5252
run: go generate ./...
5353

54+
- name: Vet
55+
run: go vet ./...
56+
5457
- name: golangci-lint
5558
uses: golangci/golangci-lint-action@v6
5659
with:

server/repository/dict_repository.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ func (dr *entDictRepository) CreateItem(ctx context.Context, dictItem *domain.Di
302302
}
303303
defer func() {
304304
if v := recover(); v != nil {
305-
tx.Rollback()
305+
_ = tx.Rollback()
306306
panic(v)
307307
}
308308
}()
@@ -313,7 +313,7 @@ func (dr *entDictRepository) CreateItem(ctx context.Context, dictItem *domain.Di
313313
return tx.Rollback()
314314
}
315315
if !typeExists {
316-
tx.Rollback()
316+
_ = tx.Rollback()
317317
return domain.ErrDictTypeNotFound
318318
}
319319

@@ -325,7 +325,7 @@ func (dr *entDictRepository) CreateItem(ctx context.Context, dictItem *domain.Di
325325
return tx.Rollback()
326326
}
327327
if valueExists {
328-
tx.Rollback()
328+
_ = tx.Rollback()
329329
return domain.ErrDictItemValueExists
330330
}
331331

@@ -489,7 +489,7 @@ func (dr *entDictRepository) UpdateItem(ctx context.Context, id string, updates
489489
}
490490
defer func() {
491491
if v := recover(); v != nil {
492-
tx.Rollback()
492+
_ = tx.Rollback()
493493
panic(v)
494494
}
495495
}()
@@ -498,7 +498,7 @@ func (dr *entDictRepository) UpdateItem(ctx context.Context, id string, updates
498498
currentItem, err := tx.DictItem.Query().Where(dictitem.ID(id)).First(ctx)
499499
if err != nil {
500500
if ent.IsNotFound(err) {
501-
tx.Rollback()
501+
_ = tx.Rollback()
502502
return domain.ErrDictItemNotFound
503503
}
504504
return tx.Rollback()
@@ -519,7 +519,7 @@ func (dr *entDictRepository) UpdateItem(ctx context.Context, id string, updates
519519
return tx.Rollback()
520520
}
521521
if valueExists {
522-
tx.Rollback()
522+
_ = tx.Rollback()
523523
return domain.ErrDictItemValueExists
524524
}
525525
updateQuery = updateQuery.SetValue(*updates.Value)

server/repository/menu_repository.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,28 @@ func (mr *entMenuRepository) GetMenuTree(ctx context.Context) ([]domain.MenuTree
3535
var allNodes []domain.MenuTreeNode
3636
for _, m := range menus {
3737
// Extract API resource IDs
38-
var apiResourceIDs []string
38+
apiResourceIDs := make([]string, 0, len(m.Edges.APIResources))
3939
for _, apiResource := range m.Edges.APIResources {
4040
apiResourceIDs = append(apiResourceIDs, apiResource.ID)
4141
}
4242

4343
node := domain.MenuTreeNode{
44-
ID: m.ID,
45-
Name: m.Name,
46-
Sequence: m.Sequence,
47-
Type: m.Type,
48-
Path: stringToPtr(m.Path),
49-
Icon: m.Icon,
50-
Component: stringToPtr(m.Component),
51-
RouteName: stringToPtr(m.RouteName),
52-
Query: stringToPtr(m.Query),
53-
IsFrame: m.IsFrame,
54-
Visible: m.Visible,
55-
Permissions: stringToPtr(m.Permissions),
56-
Status: m.Status,
57-
ParentID: m.ParentID,
58-
Children: []domain.MenuTreeNode{},
44+
ID: m.ID,
45+
Name: m.Name,
46+
Sequence: m.Sequence,
47+
Type: m.Type,
48+
Path: stringToPtr(m.Path),
49+
Icon: m.Icon,
50+
Component: stringToPtr(m.Component),
51+
RouteName: stringToPtr(m.RouteName),
52+
Query: stringToPtr(m.Query),
53+
IsFrame: m.IsFrame,
54+
Visible: m.Visible,
55+
Permissions: stringToPtr(m.Permissions),
56+
Status: m.Status,
57+
ParentID: m.ParentID,
58+
Children: []domain.MenuTreeNode{},
59+
ApiResources: apiResourceIDs,
5960
}
6061
allNodes = append(allNodes, node)
6162
}

0 commit comments

Comments
 (0)