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
727236e6
authored
Dec 09, 2024
by
CalciumIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 渠道标签开启下使用ID排序出错
parent
10789e49
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
9 deletions
+16
-9
controller/channel.go
+2
-2
main.go
+1
-1
model/channel.go
+13
-6
No files found.
controller/channel.go
View file @
727236e6
...
@@ -63,7 +63,7 @@ func GetAllChannels(c *gin.Context) {
...
@@ -63,7 +63,7 @@ func GetAllChannels(c *gin.Context) {
}
}
for
_
,
tag
:=
range
tags
{
for
_
,
tag
:=
range
tags
{
if
tag
!=
nil
&&
*
tag
!=
""
{
if
tag
!=
nil
&&
*
tag
!=
""
{
tagChannel
,
err
:=
model
.
GetChannelsByTag
(
*
tag
)
tagChannel
,
err
:=
model
.
GetChannelsByTag
(
*
tag
,
idSort
)
if
err
==
nil
{
if
err
==
nil
{
channelData
=
append
(
channelData
,
tagChannel
...
)
channelData
=
append
(
channelData
,
tagChannel
...
)
}
}
...
@@ -181,7 +181,7 @@ func SearchChannels(c *gin.Context) {
...
@@ -181,7 +181,7 @@ func SearchChannels(c *gin.Context) {
}
}
for
_
,
tag
:=
range
tags
{
for
_
,
tag
:=
range
tags
{
if
tag
!=
nil
&&
*
tag
!=
""
{
if
tag
!=
nil
&&
*
tag
!=
""
{
tagChannel
,
err
:=
model
.
GetChannelsByTag
(
*
tag
)
tagChannel
,
err
:=
model
.
GetChannelsByTag
(
*
tag
,
idSort
)
if
err
==
nil
{
if
err
==
nil
{
channelData
=
append
(
channelData
,
tagChannel
...
)
channelData
=
append
(
channelData
,
tagChannel
...
)
}
}
...
...
main.go
View file @
727236e6
...
@@ -33,7 +33,7 @@ var indexPage []byte
...
@@ -33,7 +33,7 @@ var indexPage []byte
func
main
()
{
func
main
()
{
err
:=
godotenv
.
Load
(
".env"
)
err
:=
godotenv
.
Load
(
".env"
)
if
err
!=
nil
{
if
err
!=
nil
{
common
.
Sys
Log
(
"Can't load .env file"
)
common
.
Sys
Error
(
"failed to load .env file: "
+
err
.
Error
()
)
}
}
common
.
SetupLogger
()
common
.
SetupLogger
()
...
...
model/channel.go
View file @
727236e6
...
@@ -100,9 +100,13 @@ func GetAllChannels(startIdx int, num int, selectAll bool, idSort bool) ([]*Chan
...
@@ -100,9 +100,13 @@ func GetAllChannels(startIdx int, num int, selectAll bool, idSort bool) ([]*Chan
return
channels
,
err
return
channels
,
err
}
}
func
GetChannelsByTag
(
tag
string
)
([]
*
Channel
,
error
)
{
func
GetChannelsByTag
(
tag
string
,
idSort
bool
)
([]
*
Channel
,
error
)
{
var
channels
[]
*
Channel
var
channels
[]
*
Channel
err
:=
DB
.
Where
(
"tag = ?"
,
tag
)
.
Find
(
&
channels
)
.
Error
order
:=
"priority desc"
if
idSort
{
order
=
"id desc"
}
err
:=
DB
.
Where
(
"tag = ?"
,
tag
)
.
Order
(
order
)
.
Find
(
&
channels
)
.
Error
return
channels
,
err
return
channels
,
err
}
}
...
@@ -362,7 +366,7 @@ func EditChannelByTag(tag string, newTag *string, modelMapping *string, models *
...
@@ -362,7 +366,7 @@ func EditChannelByTag(tag string, newTag *string, modelMapping *string, models *
return
err
return
err
}
}
if
shouldReCreateAbilities
{
if
shouldReCreateAbilities
{
channels
,
err
:=
GetChannelsByTag
(
updatedTag
)
channels
,
err
:=
GetChannelsByTag
(
updatedTag
,
false
)
if
err
==
nil
{
if
err
==
nil
{
for
_
,
channel
:=
range
channels
{
for
_
,
channel
:=
range
channels
{
err
=
channel
.
UpdateAbilities
()
err
=
channel
.
UpdateAbilities
()
...
@@ -450,10 +454,13 @@ func SearchTags(keyword string, group string, model string, idSort bool) ([]*str
...
@@ -450,10 +454,13 @@ func SearchTags(keyword string, group string, model string, idSort bool) ([]*str
args
=
append
(
args
,
common
.
String2Int
(
keyword
),
"%"
+
keyword
+
"%"
,
keyword
,
"%"
+
model
+
"%"
)
args
=
append
(
args
,
common
.
String2Int
(
keyword
),
"%"
+
keyword
+
"%"
,
keyword
,
"%"
+
model
+
"%"
)
}
}
err
:=
baseQuery
.
Where
(
whereClause
,
args
...
)
.
subQuery
:=
baseQuery
.
Where
(
whereClause
,
args
...
)
.
Select
(
"
DISTINCT
tag"
)
.
Select
(
"tag"
)
.
Where
(
"tag != ''"
)
.
Where
(
"tag != ''"
)
.
Order
(
order
)
.
Order
(
order
)
err
:=
DB
.
Table
(
"(?) as sub"
,
subQuery
)
.
Select
(
"DISTINCT tag"
)
.
Find
(
&
tags
)
.
Error
Find
(
&
tags
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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