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
276cced9
authored
Aug 09, 2024
by
FENG
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: sqlite group 查询兼容
parent
07bc4878
Hide 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 @
276cced9
...
...
@@ -108,10 +108,11 @@ func SearchChannels(keyword string, group string, model string) ([]*Channel, err
var
args
[]
interface
{}
if
group
!=
""
&&
group
!=
"null"
{
var
groupCondition
string
if
common
.
UsingPostgreSQL
{
groupCondition
=
`(',' || `
+
groupCol
+
` || ',') LIKE ?`
}
else
{
if
common
.
UsingMySQL
{
groupCondition
=
`CONCAT(',', `
+
groupCol
+
`, ',') LIKE ?`
}
else
{
// sqlite, PostgreSQL
groupCondition
=
`(',' || `
+
groupCol
+
` || ',') LIKE ?`
}
whereClause
=
"(id = ? OR name LIKE ? OR "
+
keyCol
+
" = ?) AND "
+
modelsCol
+
` LIKE ? AND `
+
groupCondition
args
=
append
(
args
,
common
.
String2Int
(
keyword
),
"%"
+
keyword
+
"%"
,
keyword
,
"%"
+
model
+
"%"
,
"%,"
+
group
+
",%"
)
...
...
@@ -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
{
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