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
6463ad69
authored
Nov 19, 2024
by
CalciumIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: search channel #442
parent
325de987
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
model/channel.go
+7
-2
No files found.
model/channel.go
View file @
6463ad69
...
@@ -105,7 +105,7 @@ func GetChannelsByTag(tag string) ([]*Channel, error) {
...
@@ -105,7 +105,7 @@ func GetChannelsByTag(tag string) ([]*Channel, error) {
return
channels
,
err
return
channels
,
err
}
}
func
SearchChannels
(
keyword
string
,
group
string
,
model
string
)
([]
*
Channel
,
error
)
{
func
SearchChannels
(
keyword
string
,
group
string
,
model
string
,
idSort
bool
)
([]
*
Channel
,
error
)
{
var
channels
[]
*
Channel
var
channels
[]
*
Channel
keyCol
:=
"`key`"
keyCol
:=
"`key`"
groupCol
:=
"`group`"
groupCol
:=
"`group`"
...
@@ -118,6 +118,11 @@ func SearchChannels(keyword string, group string, model string) ([]*Channel, err
...
@@ -118,6 +118,11 @@ func SearchChannels(keyword string, group string, model string) ([]*Channel, err
modelsCol
=
`"models"`
modelsCol
=
`"models"`
}
}
order
:=
"priority desc"
if
idSort
{
order
=
"id desc"
}
// 构造基础查询
// 构造基础查询
baseQuery
:=
DB
.
Model
(
&
Channel
{})
.
Omit
(
keyCol
)
baseQuery
:=
DB
.
Model
(
&
Channel
{})
.
Omit
(
keyCol
)
...
@@ -140,7 +145,7 @@ func SearchChannels(keyword string, group string, model string) ([]*Channel, err
...
@@ -140,7 +145,7 @@ func SearchChannels(keyword string, group string, model string) ([]*Channel, err
}
}
// 执行查询
// 执行查询
err
:=
baseQuery
.
Where
(
whereClause
,
args
...
)
.
Order
(
"priority desc"
)
.
Find
(
&
channels
)
.
Error
err
:=
baseQuery
.
Where
(
whereClause
,
args
...
)
.
Order
(
order
)
.
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