feat: able to delete all disabled channels
This commit is contained in:
parent
fbe9985f57
commit
824444244b
@ -127,8 +127,8 @@ func DeleteChannel(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteManuallyDisabledChannel(c *gin.Context) {
|
func DeleteDisabledChannel(c *gin.Context) {
|
||||||
rows, err := model.DeleteChannelByStatus(common.ChannelStatusManuallyDisabled)
|
rows, err := model.DeleteDisabledChannel()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
|
@ -181,3 +181,8 @@ func DeleteChannelByStatus(status int64) (int64, error) {
|
|||||||
result := DB.Where("status = ?", status).Delete(&Channel{})
|
result := DB.Where("status = ?", status).Delete(&Channel{})
|
||||||
return result.RowsAffected, result.Error
|
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
|
||||||
|
}
|
||||||
|
@ -74,7 +74,7 @@ func SetApiRouter(router *gin.Engine) {
|
|||||||
channelRoute.GET("/update_balance/:id", controller.UpdateChannelBalance)
|
channelRoute.GET("/update_balance/:id", controller.UpdateChannelBalance)
|
||||||
channelRoute.POST("/", controller.AddChannel)
|
channelRoute.POST("/", controller.AddChannel)
|
||||||
channelRoute.PUT("/", controller.UpdateChannel)
|
channelRoute.PUT("/", controller.UpdateChannel)
|
||||||
channelRoute.DELETE("/manually_disabled", controller.DeleteManuallyDisabledChannel)
|
channelRoute.DELETE("/disabled", controller.DeleteDisabledChannel)
|
||||||
channelRoute.DELETE("/:id", controller.DeleteChannel)
|
channelRoute.DELETE("/:id", controller.DeleteChannel)
|
||||||
}
|
}
|
||||||
tokenRoute := apiRouter.Group("/token")
|
tokenRoute := apiRouter.Group("/token")
|
||||||
|
@ -240,11 +240,11 @@ const ChannelsTable = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteAllManuallyDisabledChannels = async () => {
|
const deleteAllDisabledChannels = async () => {
|
||||||
const res = await API.delete(`/api/channel/manually_disabled`);
|
const res = await API.delete(`/api/channel/disabled`);
|
||||||
const { success, message, data } = res.data;
|
const { success, message, data } = res.data;
|
||||||
if (success) {
|
if (success) {
|
||||||
showSuccess(`已删除所有手动禁用渠道,共计 ${data} 个`);
|
showSuccess(`已删除所有禁用渠道,共计 ${data} 个`);
|
||||||
await refresh();
|
await refresh();
|
||||||
} else {
|
} else {
|
||||||
showError(message);
|
showError(message);
|
||||||
@ -531,14 +531,14 @@ const ChannelsTable = () => {
|
|||||||
<Popup
|
<Popup
|
||||||
trigger={
|
trigger={
|
||||||
<Button size='small' loading={loading}>
|
<Button size='small' loading={loading}>
|
||||||
删除所有手动禁用渠道
|
删除禁用渠道
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
on='click'
|
on='click'
|
||||||
flowing
|
flowing
|
||||||
hoverable
|
hoverable
|
||||||
>
|
>
|
||||||
<Button size='small' loading={loading} negative onClick={deleteAllManuallyDisabledChannels}>
|
<Button size='small' loading={loading} negative onClick={deleteAllDisabledChannels}>
|
||||||
确认删除
|
确认删除
|
||||||
</Button>
|
</Button>
|
||||||
</Popup>
|
</Popup>
|
||||||
|
Loading…
Reference in New Issue
Block a user