Преглед на файлове

refactor(gateway-ip): 重构网关 IP 管理功能

- 更新 GatewayIp 结构,移除不必要的字段
- 添加新的 GatewayIpAdmin 相关的接口和处理函数
- 修改现有的 GatewayIp 相关接口路径
- 更新 wire_gen.go 以支持新的 GatewayIpAdmin 服务和处理程序
fusu преди 3 седмици
родител
ревизия
1d86b6c04b
променени са 3 файла, в които са добавени 13 реда и са изтрити 12 реда
  1. 1 3
      api/v1/admin/gatewayIp.go
  2. 4 1
      cmd/server/wire/wire_gen.go
  3. 8 8
      internal/server/http.go

+ 1 - 3
api/v1/admin/gatewayIp.go

@@ -15,11 +15,9 @@ type SearchGatewayIpParams struct {
 }
 
 type GatewayIp struct {
-	Id int `json:"id" form:"id" validate:"required"`
-	Uid int `json:"uid" form:"uid"`
+	Id int `json:"id" form:"id" validate:"required min=1" `
 }
 
 type DeleteGatewayIpRequest struct {
 	Ids []int64 `json:"ids" form:"ids" validate:"required,min=1,dive,required"`
-	Uid int `json:"uid" form:"uid" `
 }

+ 4 - 1
cmd/server/wire/wire_gen.go

@@ -103,11 +103,14 @@ func NewWire(viperViper *viper.Viper, logger *log.Logger) (*app.App, func(), err
 	gateWayGroupIpRepository := repository.NewGateWayGroupIpRepository(repositoryRepository)
 	gateWayGroupIpService := service.NewGateWayGroupIpService(serviceService, gateWayGroupIpRepository, gatewayGroupRepository, requestService)
 	gateWayGroupIpHandler := handler.NewGateWayGroupIpHandler(handlerHandler, gateWayGroupIpService)
+	gatewayIpAdminRepository := admin.NewGatewayIpAdminRepository(repositoryRepository)
+	gatewayIpAdminService := admin2.NewGatewayIpAdminService(serviceService, gatewayIpAdminRepository)
+	gatewayIpAdminHandler := admin3.NewGatewayIpAdminHandler(handlerHandler, gatewayIpAdminService)
 	allowAndDenyIpHandler := waf3.NewAllowAndDenyIpHandler(handlerHandler, allowAndDenyIpService)
 	ccRepository := repository.NewCcRepository(repositoryRepository)
 	ccService := service.NewCcService(serviceService, ccRepository, webForwardingRepository, cdnService)
 	ccHandler := handler.NewCcHandler(handlerHandler, ccService)
-	httpServer := server.NewHTTPServer(logger, viperViper, jwtJWT, syncedEnforcer, limiterLimiter, handlerFunc, userHandler, gameShieldHandler, gameShieldBackendHandler, webForwardingHandler, tcpforwardingHandler, udpForWardingHandler, globalLimitHandler, adminHandler, gatewayGroupHandler, gateWayGroupIpHandler, allowAndDenyIpHandler, ccHandler, logService)
+	httpServer := server.NewHTTPServer(logger, viperViper, jwtJWT, syncedEnforcer, limiterLimiter, handlerFunc, userHandler, gameShieldHandler, gameShieldBackendHandler, webForwardingHandler, tcpforwardingHandler, udpForWardingHandler, globalLimitHandler, adminHandler, gatewayGroupHandler, gateWayGroupIpHandler, gatewayIpAdminHandler, allowAndDenyIpHandler, ccHandler, logService)
 	appApp := newApp(httpServer)
 	return appApp, func() {
 		cleanup()

+ 8 - 8
internal/server/http.go

@@ -36,6 +36,7 @@ func NewHTTPServer(
 	adminHandler *admin.AdminHandler,
 	gatewayHandler *handler.GatewayGroupHandler,
 	gatewayIpHandler *handler.GateWayGroupIpHandler,
+	gatewayIpAdminHandler *admin.GatewayIpAdminHandler,
 	allowAnddenyHandler *waf.AllowAndDenyIpHandler,
 	ccHandler *handler.CcHandler,
 	logService service.LogService,
@@ -171,15 +172,14 @@ func NewHTTPServer(
 			strictAuthRouter.PUT("/admin/api", adminHandler.ApiUpdate)
 			strictAuthRouter.DELETE("/admin/api", adminHandler.ApiDelete)
 
-			strictAuthRouter.GET("/gateway/list", gatewayHandler.GetGatewayGroupList)
-			strictAuthRouter.POST("/gateway/add", gatewayHandler.AddGatewayGroup)
-			strictAuthRouter.PUT("/gateway/edit", gatewayHandler.EditGatewayGroup)
-			strictAuthRouter.DELETE("/gateway/del", gatewayHandler.DeleteGatewayGroup)
 
-			strictAuthRouter.GET("/gatewayIp/get", gatewayIpHandler.GetGateWayGroupIpList)
-			strictAuthRouter.POST("/gatewayIp/add", gatewayIpHandler.AddGateWayGroupIp)
-			strictAuthRouter.PUT("/gatewayIp/edit", gatewayIpHandler.EditGateWayGroupIp)
-			strictAuthRouter.DELETE("/gatewayIp/del", gatewayIpHandler.DeleteGateWayGroupIp)
+			strictAuthRouter.GET("/gatewayIp/get", gatewayIpAdminHandler.GetGatewayIpAdmin)
+			strictAuthRouter.GET("/gatewayIp/getList", gatewayIpAdminHandler.GetGatewayIpAdminList)
+			strictAuthRouter.POST("/gatewayIp/add", gatewayIpAdminHandler.AddGatewayIpAdmin)
+			strictAuthRouter.PUT("/gatewayIp/edit", gatewayIpAdminHandler.EditGatewayIpAdmin)
+			strictAuthRouter.DELETE("/gatewayIp/del", gatewayIpAdminHandler.DeleteGatewayIpAdmin)
+			strictAuthRouter.DELETE("/gatewayIp/delList", gatewayIpAdminHandler.DeleteGatewayIpsAdmin)
+
 		}
 	}