From 16e3107d23b4bc536d509c2dd832d10366fb895e Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Mon, 24 Apr 2023 15:07:11 +0330 Subject: Better client delete + api Co-Authored-By: Alireza Ahmadi --- web/controller/api.go | 2 +- web/controller/inbound.go | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'web/controller') diff --git a/web/controller/api.go b/web/controller/api.go index c8ad2a67..b8da9243 100644 --- a/web/controller/api.go +++ b/web/controller/api.go @@ -26,7 +26,7 @@ func (a *APIController) initRouter(g *gin.RouterGroup) { g.POST("/clientIps/:email", a.getClientIps) g.POST("/clearClientIps/:email", a.clearClientIps) g.POST("/addClient/", a.addInboundClient) - g.POST("/delClient/:email", a.delInboundClient) + g.POST("/:id/delClient/:clientId", a.delInboundClient) g.POST("/updateClient/:index", a.updateInboundClient) g.POST("/:id/resetClientTraffic/:email", a.resetClientTraffic) g.POST("/resetAllTraffics", a.resetAllTraffics) diff --git a/web/controller/inbound.go b/web/controller/inbound.go index f32cb766..ec37dcc7 100644 --- a/web/controller/inbound.go +++ b/web/controller/inbound.go @@ -34,7 +34,7 @@ func (a *InboundController) initRouter(g *gin.RouterGroup) { g.POST("/clientIps/:email", a.getClientIps) g.POST("/clearClientIps/:email", a.clearClientIps) g.POST("/addClient", a.addInboundClient) - g.POST("/delClient/:email", a.delInboundClient) + g.POST("/:id/delClient/:clientId", a.delInboundClient) g.POST("/updateClient/:index", a.updateInboundClient) g.POST("/:id/resetClientTraffic/:email", a.resetClientTraffic) g.POST("/resetAllTraffics", a.resetAllTraffics) @@ -155,7 +155,7 @@ func (a *InboundController) clearClientIps(c *gin.Context) { err := a.inboundService.ClearClientIps(email) if err != nil { - jsonMsg(c, "修改", err) + jsonMsg(c, "Revise", err) return } jsonMsg(c, "Log Cleared", nil) @@ -180,15 +180,14 @@ func (a *InboundController) addInboundClient(c *gin.Context) { } func (a *InboundController) delInboundClient(c *gin.Context) { - email := c.Param("email") - inbound := &model.Inbound{} - err := c.ShouldBind(inbound) + id, err := strconv.Atoi(c.Param("id")) if err != nil { jsonMsg(c, I18n(c, "pages.inbounds.revise"), err) return } + clientId := c.Param("clientId") - err = a.inboundService.DelInboundClient(inbound, email) + err = a.inboundService.DelInboundClient(id, clientId) if err != nil { jsonMsg(c, "something worng!", err) return -- cgit v1.2.3