Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
62962c05
Commit
62962c05
authored
Apr 09, 2026
by
IanShaw027
Browse files
fix(lint): 修复 CI 中的 ineffassign 和 unused 代码告警,修正 group 排序集成测试兼容性
parent
5f8e60a1
Changes
8
Hide whitespace changes
Inline
Side-by-side
backend/internal/handler/admin/usage_handler_request_type_test.go
View file @
62962c05
...
...
@@ -17,7 +17,6 @@ type adminUsageRepoCapture struct {
service
.
UsageLogRepository
listParams
pagination
.
PaginationParams
listFilters
usagestats
.
UsageLogFilters
statsParams
pagination
.
PaginationParams
statsFilters
usagestats
.
UsageLogFilters
}
...
...
backend/internal/repository/api_key_repo.go
View file @
62962c05
...
...
@@ -390,7 +390,7 @@ func apiKeyListOrder(params pagination.PaginationParams) []func(*entsql.Selector
sortBy
:=
strings
.
ToLower
(
strings
.
TrimSpace
(
params
.
SortBy
))
sortOrder
:=
params
.
NormalizedSortOrder
(
pagination
.
SortOrderDesc
)
field
:=
apikey
.
FieldID
var
field
string
switch
sortBy
{
case
"name"
:
field
=
apikey
.
FieldName
...
...
@@ -402,8 +402,6 @@ func apiKeyListOrder(params pagination.PaginationParams) []func(*entsql.Selector
field
=
apikey
.
FieldLastUsedAt
case
"created_at"
:
field
=
apikey
.
FieldCreatedAt
case
"id"
,
""
:
field
=
apikey
.
FieldID
default
:
field
=
apikey
.
FieldID
}
...
...
backend/internal/repository/channel_repo.go
View file @
62962c05
...
...
@@ -250,7 +250,7 @@ func channelListOrderBy(params pagination.PaginationParams) string {
sortBy
:=
strings
.
ToLower
(
strings
.
TrimSpace
(
params
.
SortBy
))
sortOrder
:=
strings
.
ToUpper
(
params
.
NormalizedSortOrder
(
pagination
.
SortOrderAsc
))
column
:=
"c.id"
var
column
string
switch
sortBy
{
case
""
:
column
=
"c.id"
...
...
backend/internal/repository/group_repo.go
View file @
62962c05
...
...
@@ -319,7 +319,7 @@ func groupListOrder(params pagination.PaginationParams) []func(*entsql.Selector)
sortBy
:=
strings
.
ToLower
(
strings
.
TrimSpace
(
params
.
SortBy
))
sortOrder
:=
params
.
NormalizedSortOrder
(
pagination
.
SortOrderAsc
)
field
:=
group
.
FieldSortOrder
var
field
string
tieField
:=
group
.
FieldID
defaultOrder
:=
true
switch
sortBy
{
...
...
backend/internal/repository/group_repo_sort_integration_test.go
View file @
62962c05
...
...
@@ -13,11 +13,17 @@ func (s *GroupRepoSuite) TestList_DefaultSortBySortOrderAsc() {
s
.
Require
()
.
NoError
(
s
.
repo
.
Create
(
s
.
ctx
,
g1
))
s
.
Require
()
.
NoError
(
s
.
repo
.
Create
(
s
.
ctx
,
g2
))
groups
,
_
,
err
:=
s
.
repo
.
List
(
s
.
ctx
,
pagination
.
PaginationParams
{
Page
:
1
,
PageSize
:
10
})
groups
,
_
,
err
:=
s
.
repo
.
List
(
s
.
ctx
,
pagination
.
PaginationParams
{
Page
:
1
,
PageSize
:
10
0
})
s
.
Require
()
.
NoError
(
err
)
s
.
Require
()
.
Len
(
groups
,
2
)
s
.
Require
()
.
Equal
(
g2
.
ID
,
groups
[
0
]
.
ID
)
s
.
Require
()
.
Equal
(
g1
.
ID
,
groups
[
1
]
.
ID
)
s
.
Require
()
.
GreaterOrEqual
(
len
(
groups
),
2
)
indexByID
:=
make
(
map
[
int64
]
int
,
len
(
groups
))
for
i
,
g
:=
range
groups
{
indexByID
[
g
.
ID
]
=
i
}
s
.
Require
()
.
Contains
(
indexByID
,
g1
.
ID
)
s
.
Require
()
.
Contains
(
indexByID
,
g2
.
ID
)
// g2 has SortOrder=10, g1 has SortOrder=20; ascending means g2 comes first
s
.
Require
()
.
Less
(
indexByID
[
g2
.
ID
],
indexByID
[
g1
.
ID
])
}
func
(
s
*
GroupRepoSuite
)
TestList_SortBySortOrderDesc
()
{
...
...
backend/internal/repository/promo_code_repo.go
View file @
62962c05
...
...
@@ -161,7 +161,7 @@ func promoCodeListOrder(params pagination.PaginationParams) []func(*entsql.Selec
sortBy
:=
strings
.
ToLower
(
strings
.
TrimSpace
(
params
.
SortBy
))
sortOrder
:=
params
.
NormalizedSortOrder
(
pagination
.
SortOrderDesc
)
field
:=
promocode
.
FieldID
var
field
string
switch
sortBy
{
case
"bonus_amount"
:
field
=
promocode
.
FieldBonusAmount
...
...
@@ -173,8 +173,6 @@ func promoCodeListOrder(params pagination.PaginationParams) []func(*entsql.Selec
field
=
promocode
.
FieldCreatedAt
case
"code"
:
field
=
promocode
.
FieldCode
case
"id"
,
""
:
field
=
promocode
.
FieldID
default
:
field
=
promocode
.
FieldID
}
...
...
backend/internal/repository/usage_log_repo.go
View file @
62962c05
...
...
@@ -3812,14 +3812,12 @@ func usageLogOrderBy(params pagination.PaginationParams) string {
sortBy
:=
strings
.
ToLower
(
strings
.
TrimSpace
(
params
.
SortBy
))
sortOrder
:=
strings
.
ToUpper
(
params
.
NormalizedSortOrder
(
pagination
.
SortOrderDesc
))
column
:=
"id"
var
column
string
switch
sortBy
{
case
"model"
:
column
=
"COALESCE(NULLIF(TRIM(requested_model), ''), model)"
case
"created_at"
:
column
=
"created_at"
case
"id"
,
""
:
column
=
"id"
default
:
column
=
"id"
}
...
...
backend/internal/service/setting_service.go
View file @
62962c05
...
...
@@ -1109,14 +1109,6 @@ func normalizeTablePreferences(defaultPageSize int, options []int) (int, []int)
return
defaultPageSize
,
normalizedOptions
}
func
containsInt
(
values
[]
int
,
target
int
)
bool
{
for
_
,
value
:=
range
values
{
if
value
==
target
{
return
true
}
}
return
false
}
// getStringOrDefault 获取字符串值或默认值
func
(
s
*
SettingService
)
getStringOrDefault
(
settings
map
[
string
]
string
,
key
,
defaultValue
string
)
string
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment