fix: GetAllChannels ignores group filter parameter (#4847)
When users filter channels by group without entering a search keyword, the frontend calls GetAllChannels (GET /api/channel/) instead of SearchChannels. However, GetAllChannels did not process the group query parameter, causing the filter to have no effect. Added group filtering logic to GetAllChannels for both normal mode and tag mode, using the same CONCAT/|| pattern as SearchChannels for cross-database compatibility (MySQL, PostgreSQL, SQLite).
This commit is contained in:
parent
6f8668e4c3
commit
132d7b9f94
@ -85,6 +85,8 @@ func GetAllChannels(c *gin.Context) {
|
||||
typeFilter = t
|
||||
}
|
||||
}
|
||||
// group filter
|
||||
groupFilter := c.Query("group")
|
||||
|
||||
var total int64
|
||||
|
||||
@ -114,6 +116,11 @@ func GetAllChannels(c *gin.Context) {
|
||||
if typeFilter >= 0 && ch.Type != typeFilter {
|
||||
continue
|
||||
}
|
||||
if groupFilter != "" && groupFilter != "null" {
|
||||
if !strings.Contains(","+ch.Group+",", ","+groupFilter+",") {
|
||||
continue
|
||||
}
|
||||
}
|
||||
filtered = append(filtered, ch)
|
||||
}
|
||||
channelData = append(channelData, filtered...)
|
||||
@ -129,6 +136,14 @@ func GetAllChannels(c *gin.Context) {
|
||||
} else if statusFilter == 0 {
|
||||
baseQuery = baseQuery.Where("status != ?", common.ChannelStatusEnabled)
|
||||
}
|
||||
if groupFilter != "" && groupFilter != "null" {
|
||||
if common.UsingMySQL {
|
||||
baseQuery = baseQuery.Where("CONCAT(',', `group`, ',') LIKE ?", "%,"+groupFilter+",%")
|
||||
} else {
|
||||
// SQLite, PostgreSQL
|
||||
baseQuery = baseQuery.Where("(',' || \"group\" || ',') LIKE ?", "%,"+groupFilter+",%")
|
||||
}
|
||||
}
|
||||
|
||||
baseQuery.Count(&total)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user