first commit
This commit is contained in:
		
							
								
								
									
										37
									
								
								internal/test/service.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								internal/test/service.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
package test
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	generated "Sipro-Marketplaces/internal/test/db/generated"
 | 
			
		||||
	"context"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Service interface {
 | 
			
		||||
	Create(ctx context.Context, data string) (int32, error)
 | 
			
		||||
	Get(ctx context.Context, id int32) (generated.Test, error)
 | 
			
		||||
	Update(ctx context.Context, id int32, data string) error
 | 
			
		||||
	Delete(ctx context.Context, id int32) error
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type service struct {
 | 
			
		||||
	repo Repository
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewService(repo Repository) Service {
 | 
			
		||||
	return &service{repo: repo}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *service) Create(ctx context.Context, data string) (int32, error) {
 | 
			
		||||
	return s.repo.Create(ctx, data)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *service) Get(ctx context.Context, id int32) (generated.Test, error) {
 | 
			
		||||
	return s.repo.Get(ctx, id)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *service) Update(ctx context.Context, id int32, data string) error {
 | 
			
		||||
	return s.repo.Update(ctx, id, data)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *service) Delete(ctx context.Context, id int32) error {
 | 
			
		||||
	return s.repo.Delete(ctx, id)
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user