12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package repository
- import (
- "context"
- "github.com/go-nunu/nunu-layout-advanced/internal/model"
- )
- type UdpForWardingRepository interface {
- GetUdpForWarding(ctx context.Context, id int64) (*model.UdpForWarding, error)
- AddUdpForwarding(ctx context.Context, req *model.UdpForWarding) error
- EditUdpForwarding(ctx context.Context, req *model.UdpForWarding) error
- DeleteUdpForwarding(ctx context.Context, id int64) error
- }
- func NewUdpForWardingRepository(
- repository *Repository,
- ) UdpForWardingRepository {
- return &udpForWardingRepository{
- Repository: repository,
- }
- }
- type udpForWardingRepository struct {
- *Repository
- }
- func (r *udpForWardingRepository) GetUdpForWarding(ctx context.Context, id int64) (*model.UdpForWarding, error) {
- var udpForWarding model.UdpForWarding
- return &udpForWarding, nil
- }
- func (r *udpForWardingRepository) AddUdpForwarding(ctx context.Context, req *model.UdpForWarding) error {
- if err := r.db.Create(&req).Error; err != nil {
- return err
- }
- return nil
- }
- func (r *udpForWardingRepository) EditUdpForwarding(ctx context.Context, req *model.UdpForWarding) error {
- if err := r.db.Updates(&req).Error; err != nil {
- return err
- }
- return nil
- }
- func (r *udpForWardingRepository) DeleteUdpForwarding(ctx context.Context, id int64) error {
- if err := r.db.Delete(&model.UdpForWarding{}, id).Error; err != nil {
- return err
- }
- return nil
- }
|