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
b01c1522
authored
Aug 05, 2024
by
FENG
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 渠道多分组,优化分组 like 查询
parent
cba830e5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
6 deletions
+5
-6
model/channel.go
+3
-5
web/src/components/ChannelsTable.js
+2
-1
No files found.
model/channel.go
View file @
b01c1522
...
@@ -90,13 +90,11 @@ func GetAllChannels(startIdx int, num int, selectAll bool, idSort bool) ([]*Chan
...
@@ -90,13 +90,11 @@ func GetAllChannels(startIdx int, num int, selectAll bool, idSort bool) ([]*Chan
func
SearchChannels
(
keyword
string
,
group
string
,
model
string
)
([]
*
Channel
,
error
)
{
func
SearchChannels
(
keyword
string
,
group
string
,
model
string
)
([]
*
Channel
,
error
)
{
var
channels
[]
*
Channel
var
channels
[]
*
Channel
keyCol
:=
"`key`"
keyCol
:=
"`key`"
groupCol
:=
"`group`"
modelsCol
:=
"`models`"
modelsCol
:=
"`models`"
// 如果是 PostgreSQL,使用双引号
// 如果是 PostgreSQL,使用双引号
if
common
.
UsingPostgreSQL
{
if
common
.
UsingPostgreSQL
{
keyCol
=
`"key"`
keyCol
=
`"key"`
groupCol
=
`"group"`
modelsCol
=
`"models"`
modelsCol
=
`"models"`
}
}
...
@@ -106,9 +104,9 @@ func SearchChannels(keyword string, group string, model string) ([]*Channel, err
...
@@ -106,9 +104,9 @@ func SearchChannels(keyword string, group string, model string) ([]*Channel, err
// 构造WHERE子句
// 构造WHERE子句
var
whereClause
string
var
whereClause
string
var
args
[]
interface
{}
var
args
[]
interface
{}
if
group
!=
""
{
if
group
!=
""
&&
group
!=
"null"
{
whereClause
=
"(id = ? OR name LIKE ? OR "
+
keyCol
+
" = ?) AND "
+
groupCol
+
" = ? AND "
+
modelsCol
+
" LIKE ?"
whereClause
=
"(id = ? OR name LIKE ? OR "
+
keyCol
+
" = ?) AND "
+
modelsCol
+
` LIKE ? AND (',' || "group" || ',') LIKE ?`
args
=
append
(
args
,
common
.
String2Int
(
keyword
),
"%"
+
keyword
+
"%"
,
keyword
,
group
,
"%"
+
model
+
"
%"
)
args
=
append
(
args
,
common
.
String2Int
(
keyword
),
"%"
+
keyword
+
"%"
,
keyword
,
"%"
+
model
+
"%"
,
"%,"
+
group
+
",
%"
)
}
else
{
}
else
{
whereClause
=
"(id = ? OR name LIKE ? OR "
+
keyCol
+
" = ?) AND "
+
modelsCol
+
" LIKE ?"
whereClause
=
"(id = ? OR name LIKE ? OR "
+
keyCol
+
" = ?) AND "
+
modelsCol
+
" LIKE ?"
args
=
append
(
args
,
common
.
String2Int
(
keyword
),
"%"
+
keyword
+
"%"
,
keyword
,
"%"
+
model
+
"%"
)
args
=
append
(
args
,
common
.
String2Int
(
keyword
),
"%"
+
keyword
+
"%"
,
keyword
,
"%"
+
model
+
"%"
)
...
...
web/src/components/ChannelsTable.js
View file @
b01c1522
...
@@ -745,7 +745,8 @@ const ChannelsTable = () => {
...
@@ -745,7 +745,8 @@ const ChannelsTable = () => {
<
Form
.
Select
<
Form
.
Select
field
=
'group'
field
=
'group'
label
=
'分组'
label
=
'分组'
optionList
=
{
groupOptions
}
optionList
=
{[{
label
:
'选择分组'
,
value
:
null
},
...
groupOptions
]}
initValue
=
{
null
}
onChange
=
{(
v
)
=>
{
onChange
=
{(
v
)
=>
{
setSearchGroup
(
v
);
setSearchGroup
(
v
);
searchChannels
(
searchKeyword
,
v
,
searchModel
);
searchChannels
(
searchKeyword
,
v
,
searchModel
);
...
...
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