diff --git a/controller/channel.go b/controller/channel.go index 41a55550..904abc23 100644 --- a/controller/channel.go +++ b/controller/channel.go @@ -127,8 +127,8 @@ func DeleteChannel(c *gin.Context) { return } -func DeleteManuallyDisabledChannel(c *gin.Context) { - rows, err := model.DeleteChannelByStatus(common.ChannelStatusManuallyDisabled) +func DeleteDisabledChannel(c *gin.Context) { + rows, err := model.DeleteDisabledChannel() if err != nil { c.JSON(http.StatusOK, gin.H{ "success": false, diff --git a/model/channel.go b/model/channel.go index 36bb78a5..091a0d71 100644 --- a/model/channel.go +++ b/model/channel.go @@ -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 +} diff --git a/router/api-router.go b/router/api-router.go index 5ec385dc..da3f9e61 100644 --- a/router/api-router.go +++ b/router/api-router.go @@ -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.DeleteManuallyDisabledChannel) + channelRoute.DELETE("/disabled", controller.DeleteDisabledChannel) channelRoute.DELETE("/:id", controller.DeleteChannel) } tokenRoute := apiRouter.Group("/token") diff --git a/web/src/components/ChannelsTable.js b/web/src/components/ChannelsTable.js index b9eb3c0f..732189cb 100644 --- a/web/src/components/ChannelsTable.js +++ b/web/src/components/ChannelsTable.js @@ -240,11 +240,11 @@ const ChannelsTable = () => { } }; - const deleteAllManuallyDisabledChannels = 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 = () => { - 删除所有手动禁用渠道 + 删除禁用渠道 } on='click' flowing hoverable > -