45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
|
|
"wucher/internal/domain/operation"
|
|
)
|
|
|
|
type HEMSOperationalDataService struct {
|
|
repo operation.HEMSOperationalDataRepository
|
|
}
|
|
|
|
func NewHEMSOperationalDataService(repo operation.HEMSOperationalDataRepository) *HEMSOperationalDataService {
|
|
return &HEMSOperationalDataService{repo: repo}
|
|
}
|
|
|
|
func (s *HEMSOperationalDataService) Create(ctx context.Context, row *operation.HEMSOperationalData) error {
|
|
return s.repo.Create(ctx, row)
|
|
}
|
|
|
|
func (s *HEMSOperationalDataService) Update(ctx context.Context, row *operation.HEMSOperationalData) error {
|
|
return s.repo.Update(ctx, row)
|
|
}
|
|
|
|
func (s *HEMSOperationalDataService) Delete(ctx context.Context, id []byte, deletedBy []byte) error {
|
|
return s.repo.Delete(ctx, id, deletedBy)
|
|
}
|
|
|
|
func (s *HEMSOperationalDataService) GetByID(ctx context.Context, id []byte) (*operation.HEMSOperationalData, error) {
|
|
return s.repo.GetByID(ctx, id)
|
|
}
|
|
|
|
func (s *HEMSOperationalDataService) List(ctx context.Context, filter, sort string, limit, offset int) ([]operation.HEMSOperationalData, int64, error) {
|
|
return s.repo.List(ctx, filter, normalizeHEMSOperationalDataSort(sort), limit, offset)
|
|
}
|
|
|
|
func normalizeHEMSOperationalDataSort(sort string) string {
|
|
return normalizeSortByRules(sort,
|
|
sortField("time"),
|
|
sortField("location"),
|
|
sortField("created_at"),
|
|
sortField("updated_at"),
|
|
)
|
|
}
|