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
63bd941d
authored
Oct 14, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: able to delete all disabled channels
parent
f6811a11
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
8 deletions
+13
-8
controller/channel.go
+2
-2
model/channel.go
+5
-0
router/api-router.go
+1
-1
web/src/components/ChannelsTable.js
+5
-5
No files found.
controller/channel.go
View file @
63bd941d
...
...
@@ -127,8 +127,8 @@ func DeleteChannel(c *gin.Context) {
return
}
func
Delete
Manually
DisabledChannel
(
c
*
gin
.
Context
)
{
rows
,
err
:=
model
.
Delete
ChannelByStatus
(
common
.
ChannelStatusManuallyDisabled
)
func
DeleteDisabledChannel
(
c
*
gin
.
Context
)
{
rows
,
err
:=
model
.
Delete
DisabledChannel
(
)
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
false
,
...
...
model/channel.go
View file @
63bd941d
...
...
@@ -181,3 +181,8 @@ func DeleteChannelByStatus(status int64) (int64, error) {
result
:=
DB
.
Where
(
"status = ?"
,
status
)
.
Delete
(
&
Channel
{})
return
result
.
RowsAffected
,
result
.
Error
}
func
DeleteDisabledChannel
()
(
int64
,
error
)
{
result
:=
DB
.
Where
(
"status = ? or status = ?"
,
common
.
ChannelStatusAutoDisabled
,
common
.
ChannelStatusManuallyDisabled
)
.
Delete
(
&
Channel
{})
return
result
.
RowsAffected
,
result
.
Error
}
router/api-router.go
View file @
63bd941d
...
...
@@ -74,7 +74,7 @@ func SetApiRouter(router *gin.Engine) {
channelRoute
.
GET
(
"/update_balance/:id"
,
controller
.
UpdateChannelBalance
)
channelRoute
.
POST
(
"/"
,
controller
.
AddChannel
)
channelRoute
.
PUT
(
"/"
,
controller
.
UpdateChannel
)
channelRoute
.
DELETE
(
"/
manually_disabled"
,
controller
.
DeleteManually
DisabledChannel
)
channelRoute
.
DELETE
(
"/
disabled"
,
controller
.
Delete
DisabledChannel
)
channelRoute
.
DELETE
(
"/:id"
,
controller
.
DeleteChannel
)
}
tokenRoute
:=
apiRouter
.
Group
(
"/token"
)
...
...
web/src/components/ChannelsTable.js
View file @
63bd941d
...
...
@@ -240,11 +240,11 @@ const ChannelsTable = () => {
}
};
const
deleteAll
Manually
DisabledChannels
=
async
()
=>
{
const
res
=
await
API
.
delete
(
`/api/channel/
manually_
disabled`
);
const
deleteAllDisabledChannels
=
async
()
=>
{
const
res
=
await
API
.
delete
(
`/api/channel/disabled`
);
const
{
success
,
message
,
data
}
=
res
.
data
;
if
(
success
)
{
showSuccess
(
`已删除所有
手动
禁用渠道,共计
${
data
}
个`
);
showSuccess
(
`已删除所有禁用渠道,共计
${
data
}
个`
);
await
refresh
();
}
else
{
showError
(
message
);
...
...
@@ -531,14 +531,14 @@ const ChannelsTable = () => {
<
Popup
trigger
=
{
<
Button
size
=
'small'
loading
=
{
loading
}
>
删除
所有手动
禁用渠道
删除禁用渠道
<
/Button
>
}
on
=
'click'
flowing
hoverable
>
<
Button
size
=
'small'
loading
=
{
loading
}
negative
onClick
=
{
deleteAll
Manually
DisabledChannels
}
>
<
Button
size
=
'small'
loading
=
{
loading
}
negative
onClick
=
{
deleteAllDisabledChannels
}
>
确认删除
<
/Button
>
<
/Popup
>
...
...
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