gatewaygroupip.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package service
  2. import (
  3. "context"
  4. "github.com/go-nunu/nunu-layout-advanced/internal/model"
  5. "github.com/go-nunu/nunu-layout-advanced/internal/repository"
  6. )
  7. type GateWayGroupIpService interface {
  8. GetGateWayGroupIp(ctx context.Context, id int64) (*model.GateWayGroupIp, error)
  9. GetGateWayGroupIpByGatewayGroupId(ctx context.Context, gatewayGroupId int) (*[]model.GateWayGroupIp, error)
  10. AddGateWayGroupIp(ctx context.Context, req *model.GateWayGroupIp) error
  11. EditGateWayGroupIp(ctx context.Context, req *model.GateWayGroupIp) error
  12. DeleteGateWayGroupIp(ctx context.Context, req *model.GateWayGroupIp) error
  13. }
  14. func NewGateWayGroupIpService(
  15. service *Service,
  16. gateWayGroupIpRepository repository.GateWayGroupIpRepository,
  17. ) GateWayGroupIpService {
  18. return &gateWayGroupIpService{
  19. Service: service,
  20. gateWayGroupIpRepository: gateWayGroupIpRepository,
  21. }
  22. }
  23. type gateWayGroupIpService struct {
  24. *Service
  25. gateWayGroupIpRepository repository.GateWayGroupIpRepository
  26. }
  27. func (s *gateWayGroupIpService) GetGateWayGroupIp(ctx context.Context, id int64) (*model.GateWayGroupIp, error) {
  28. return s.gateWayGroupIpRepository.GetGateWayGroupIp(ctx, id)
  29. }
  30. func (s *gateWayGroupIpService) GetGateWayGroupIpByGatewayGroupId(ctx context.Context, gatewayGroupId int) (*[]model.GateWayGroupIp, error) {
  31. res, err := s.gateWayGroupIpRepository.GetGateWayGroupIpByGatewayGroupId(ctx, gatewayGroupId)
  32. if err != nil {
  33. return nil, err
  34. }
  35. return &res, nil
  36. }
  37. func (s *gateWayGroupIpService) AddGateWayGroupIp(ctx context.Context, req *model.GateWayGroupIp) error {
  38. if err := s.gateWayGroupIpRepository.AddGateWayGroupIp(ctx, req); err != nil {
  39. return err
  40. }
  41. return nil
  42. }
  43. func (s *gateWayGroupIpService) EditGateWayGroupIp(ctx context.Context, req *model.GateWayGroupIp) error {
  44. if err := s.gateWayGroupIpRepository.EditGateWayGroupIp(ctx, req); err != nil {
  45. return err
  46. }
  47. return nil
  48. }
  49. func (s *gateWayGroupIpService) DeleteGateWayGroupIp(ctx context.Context, req *model.GateWayGroupIp) error {
  50. if err := s.gateWayGroupIpRepository.DeleteGateWayGroupIp(ctx, req); err != nil {
  51. return err
  52. }
  53. return nil
  54. }