|
@@ -2,6 +2,7 @@ package service
|
|
|
|
|
|
import (
|
|
import (
|
|
"context"
|
|
"context"
|
|
|
|
+ v1 "github.com/go-nunu/nunu-layout-advanced/api/v1"
|
|
|
|
|
|
"github.com/go-nunu/nunu-layout-advanced/internal/model"
|
|
"github.com/go-nunu/nunu-layout-advanced/internal/model"
|
|
"github.com/go-nunu/nunu-layout-advanced/internal/repository"
|
|
"github.com/go-nunu/nunu-layout-advanced/internal/repository"
|
|
@@ -10,9 +11,9 @@ import (
|
|
type GateWayGroupIpService interface {
|
|
type GateWayGroupIpService interface {
|
|
GetGateWayGroupIp(ctx context.Context, id int64) (*model.GateWayGroupIp, error)
|
|
GetGateWayGroupIp(ctx context.Context, id int64) (*model.GateWayGroupIp, error)
|
|
GetGateWayGroupIpByGatewayGroupId(ctx context.Context, gatewayGroupId int) (*[]model.GateWayGroupIp, error)
|
|
GetGateWayGroupIpByGatewayGroupId(ctx context.Context, gatewayGroupId int) (*[]model.GateWayGroupIp, error)
|
|
- AddGateWayGroupIp(ctx context.Context, req *model.GateWayGroupIp) error
|
|
|
|
- EditGateWayGroupIp(ctx context.Context, req *model.GateWayGroupIp) error
|
|
|
|
- DeleteGateWayGroupIp(ctx context.Context, req *model.GateWayGroupIp) error
|
|
|
|
|
|
+ AddGateWayGroupIp(ctx context.Context, req *v1.GateWayGroupIpRequest) error
|
|
|
|
+ EditGateWayGroupIp(ctx context.Context, req *v1.GateWayGroupIpRequest) error
|
|
|
|
+ DeleteGateWayGroupIp(ctx context.Context, req *v1.DeleteGateWayGroupIpRequest) error
|
|
}
|
|
}
|
|
|
|
|
|
func NewGateWayGroupIpService(
|
|
func NewGateWayGroupIpService(
|
|
@@ -42,22 +43,37 @@ func (s *gateWayGroupIpService) GetGateWayGroupIpByGatewayGroupId(ctx context.Co
|
|
return &res, nil
|
|
return &res, nil
|
|
}
|
|
}
|
|
|
|
|
|
-func (s *gateWayGroupIpService) AddGateWayGroupIp(ctx context.Context, req *model.GateWayGroupIp) error {
|
|
|
|
- if err := s.gateWayGroupIpRepository.AddGateWayGroupIp(ctx, req); err != nil {
|
|
|
|
|
|
+func (s *gateWayGroupIpService) AddGateWayGroupIp(ctx context.Context, req *v1.GateWayGroupIpRequest) error {
|
|
|
|
+ if err := s.gateWayGroupIpRepository.AddGateWayGroupIp(ctx, &model.GateWayGroupIp{
|
|
|
|
+ GatewayGroupId: req.GatewayGroupId,
|
|
|
|
+ Ip: req.Ip,
|
|
|
|
+ Tag: req.Tag,
|
|
|
|
+ Comment: req.Comment,
|
|
|
|
+ OriginPlace: req.OriginPlace,
|
|
|
|
+ }); err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
-func (s *gateWayGroupIpService) EditGateWayGroupIp(ctx context.Context, req *model.GateWayGroupIp) error {
|
|
|
|
- if err := s.gateWayGroupIpRepository.EditGateWayGroupIp(ctx, req); err != nil {
|
|
|
|
|
|
+func (s *gateWayGroupIpService) EditGateWayGroupIp(ctx context.Context, req *v1.GateWayGroupIpRequest) error {
|
|
|
|
+ if err := s.gateWayGroupIpRepository.EditGateWayGroupIp(ctx, &model.GateWayGroupIp{
|
|
|
|
+ Id: req.Id,
|
|
|
|
+ GatewayGroupId: req.GatewayGroupId,
|
|
|
|
+ Ip: req.Ip,
|
|
|
|
+ Tag: req.Tag,
|
|
|
|
+ Comment: req.Comment,
|
|
|
|
+ OriginPlace: req.OriginPlace,
|
|
|
|
+ }); err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
-func (s *gateWayGroupIpService) DeleteGateWayGroupIp(ctx context.Context, req *model.GateWayGroupIp) error {
|
|
|
|
- if err := s.gateWayGroupIpRepository.DeleteGateWayGroupIp(ctx, req); err != nil {
|
|
|
|
|
|
+func (s *gateWayGroupIpService) DeleteGateWayGroupIp(ctx context.Context, req *v1.DeleteGateWayGroupIpRequest) error {
|
|
|
|
+ if err := s.gateWayGroupIpRepository.DeleteGateWayGroupIp(ctx, &model.GateWayGroupIp{
|
|
|
|
+ Id: req.Id,
|
|
|
|
+ }); err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
return nil
|