|
@@ -2,7 +2,9 @@ package handler
|
|
|
|
|
|
import (
|
|
|
"github.com/gin-gonic/gin"
|
|
|
+ v1 "github.com/go-nunu/nunu-layout-advanced/api/v1"
|
|
|
"github.com/go-nunu/nunu-layout-advanced/internal/service"
|
|
|
+ "net/http"
|
|
|
)
|
|
|
|
|
|
type GateWayGroupIpHandler struct {
|
|
@@ -23,3 +25,66 @@ func NewGateWayGroupIpHandler(
|
|
|
func (h *GateWayGroupIpHandler) GetGateWayGroupIp(ctx *gin.Context) {
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+func (h *GateWayGroupIpHandler) GetGateWayGroupIpByGatewayGroupId(ctx *gin.Context) {
|
|
|
+ req := new(v1.GetGateWayGroupIpByGatewayGroupIdRequest)
|
|
|
+ if err := ctx.ShouldBind(req); err != nil {
|
|
|
+ v1.HandleError(ctx, http.StatusBadRequest, v1.ErrBadRequest,nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ res, err := h.gateWayGroupIpService.GetGateWayGroupIpByGatewayGroupId(ctx, req.GatewayGroupId)
|
|
|
+ if err != nil {
|
|
|
+ v1.HandleError(ctx, http.StatusInternalServerError, err, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ v1.HandleSuccess(ctx, res)
|
|
|
+}
|
|
|
+
|
|
|
+func (h *GateWayGroupIpHandler) AddGateWayGroupIp(ctx *gin.Context) {
|
|
|
+ req := new(v1.GateWayGroupIpRequest)
|
|
|
+ if err := ctx.ShouldBind(req); err != nil {
|
|
|
+ v1.HandleError(ctx, http.StatusBadRequest, v1.ErrBadRequest, err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ err := h.gateWayGroupIpService.AddGateWayGroupIp(ctx, req)
|
|
|
+ if err != nil {
|
|
|
+ v1.HandleError(ctx, http.StatusInternalServerError, err, err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ v1.HandleSuccess(ctx, nil)
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func (h *GateWayGroupIpHandler) EditGateWayGroupIp(ctx *gin.Context) {
|
|
|
+ req := new(v1.GateWayGroupIpRequest)
|
|
|
+ if err := ctx.ShouldBind(req); err != nil {
|
|
|
+ v1.HandleError(ctx, http.StatusBadRequest, v1.ErrBadRequest, err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ err := h.gateWayGroupIpService.EditGateWayGroupIp(ctx, req)
|
|
|
+ if err != nil {
|
|
|
+ v1.HandleError(ctx, http.StatusInternalServerError, err, err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ v1.HandleSuccess(ctx, nil)
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func (h *GateWayGroupIpHandler) DeleteGateWayGroupIp(ctx *gin.Context) {
|
|
|
+ req := new(v1.DeleteGateWayGroupIpRequest)
|
|
|
+ if err := ctx.ShouldBind(req); err != nil {
|
|
|
+ v1.HandleError(ctx, http.StatusBadRequest, v1.ErrBadRequest, err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ err := h.gateWayGroupIpService.DeleteGateWayGroupIp(ctx, req)
|
|
|
+ if err != nil {
|
|
|
+ v1.HandleError(ctx, http.StatusInternalServerError, err, err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ v1.HandleSuccess(ctx, nil)
|
|
|
+
|
|
|
+}
|