udpforwarding.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package repository
  2. import (
  3. "context"
  4. "github.com/go-nunu/nunu-layout-advanced/internal/model"
  5. )
  6. type UdpForWardingRepository interface {
  7. GetUdpForWarding(ctx context.Context, id int64) (*model.UdpForWarding, error)
  8. AddUdpForwarding(ctx context.Context, req *model.UdpForWarding) error
  9. EditUdpForwarding(ctx context.Context, req *model.UdpForWarding) error
  10. DeleteUdpForwarding(ctx context.Context, id int64) error
  11. }
  12. func NewUdpForWardingRepository(
  13. repository *Repository,
  14. ) UdpForWardingRepository {
  15. return &udpForWardingRepository{
  16. Repository: repository,
  17. }
  18. }
  19. type udpForWardingRepository struct {
  20. *Repository
  21. }
  22. func (r *udpForWardingRepository) GetUdpForWarding(ctx context.Context, id int64) (*model.UdpForWarding, error) {
  23. var udpForWarding model.UdpForWarding
  24. return &udpForWarding, nil
  25. }
  26. func (r *udpForWardingRepository) AddUdpForwarding(ctx context.Context, req *model.UdpForWarding) error {
  27. if err := r.db.Create(&req).Error; err != nil {
  28. return err
  29. }
  30. return nil
  31. }
  32. func (r *udpForWardingRepository) EditUdpForwarding(ctx context.Context, req *model.UdpForWarding) error {
  33. if err := r.db.Updates(&req).Error; err != nil {
  34. return err
  35. }
  36. return nil
  37. }
  38. func (r *udpForWardingRepository) DeleteUdpForwarding(ctx context.Context, id int64) error {
  39. if err := r.db.Delete(&model.UdpForWarding{}, id).Error; err != nil {
  40. return err
  41. }
  42. return nil
  43. }