Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a09d62f1
authored
Aug 09, 2024
by
Calcium-Ion
Committed by
GitHub
Aug 09, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #425 from dalefengs/fix_group
fix: 渠道多分组查询 sqlite 查询兼容
parents
07bc4878
276cced9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
model/channel.go
+5
-4
No files found.
model/channel.go
View file @
a09d62f1
...
@@ -108,10 +108,11 @@ func SearchChannels(keyword string, group string, model string) ([]*Channel, err
...
@@ -108,10 +108,11 @@ func SearchChannels(keyword string, group string, model string) ([]*Channel, err
var
args
[]
interface
{}
var
args
[]
interface
{}
if
group
!=
""
&&
group
!=
"null"
{
if
group
!=
""
&&
group
!=
"null"
{
var
groupCondition
string
var
groupCondition
string
if
common
.
UsingPostgreSQL
{
if
common
.
UsingMySQL
{
groupCondition
=
`(',' || `
+
groupCol
+
` || ',') LIKE ?`
}
else
{
groupCondition
=
`CONCAT(',', `
+
groupCol
+
`, ',') LIKE ?`
groupCondition
=
`CONCAT(',', `
+
groupCol
+
`, ',') LIKE ?`
}
else
{
// sqlite, PostgreSQL
groupCondition
=
`(',' || `
+
groupCol
+
` || ',') LIKE ?`
}
}
whereClause
=
"(id = ? OR name LIKE ? OR "
+
keyCol
+
" = ?) AND "
+
modelsCol
+
` LIKE ? AND `
+
groupCondition
whereClause
=
"(id = ? OR name LIKE ? OR "
+
keyCol
+
" = ?) AND "
+
modelsCol
+
` LIKE ? AND `
+
groupCondition
args
=
append
(
args
,
common
.
String2Int
(
keyword
),
"%"
+
keyword
+
"%"
,
keyword
,
"%"
+
model
+
"%"
,
"%,"
+
group
+
",%"
)
args
=
append
(
args
,
common
.
String2Int
(
keyword
),
"%"
+
keyword
+
"%"
,
keyword
,
"%"
+
model
+
"%"
,
"%,"
+
group
+
",%"
)
...
@@ -121,7 +122,7 @@ func SearchChannels(keyword string, group string, model string) ([]*Channel, err
...
@@ -121,7 +122,7 @@ func SearchChannels(keyword string, group string, model string) ([]*Channel, err
}
}
// 执行查询
// 执行查询
err
:=
baseQuery
.
Where
(
whereClause
,
args
...
)
.
Find
(
&
channels
)
.
Error
err
:=
baseQuery
.
Where
(
whereClause
,
args
...
)
.
Order
(
"priority desc"
)
.
Find
(
&
channels
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
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