init push

This commit is contained in:
2026-07-16 22:16:45 +07:00
commit 8b068bdb10
1021 changed files with 332816 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
package service
import (
"context"
"wucher/internal/domain/icao"
"wucher/internal/shared/pkg/sortkey"
)
type ICAOService struct {
repo icao.Repository
}
func NewICAOService(repo icao.Repository) *ICAOService {
return &ICAOService{repo: repo}
}
func (s *ICAOService) Create(ctx context.Context, row *icao.ICAO) error {
return s.repo.Create(ctx, row)
}
func (s *ICAOService) Update(ctx context.Context, row *icao.ICAO) error {
return s.repo.Update(ctx, row)
}
func (s *ICAOService) Delete(ctx context.Context, id []byte, deletedBy []byte) error {
return s.repo.Delete(ctx, id, deletedBy)
}
func (s *ICAOService) GetByID(ctx context.Context, id []byte) (*icao.ICAO, error) {
return s.repo.GetByID(ctx, id)
}
func (s *ICAOService) List(ctx context.Context, filter, sort string, limit, offset int) ([]icao.ICAO, int64, error) {
return s.repo.List(ctx, filter, normalizeICAOSort(sort), limit, offset)
}
func normalizeICAOSort(sort string) string {
return normalizeSortByRules(sort,
sortExpr(
joinSortClauses(sortkey.ActivePositiveSortClauses("", "is_active", "sortkey", "icao_code", false)),
joinSortClauses(sortkey.ActivePositiveSortClauses("", "is_active", "sortkey", "icao_code", true)),
"sortkey",
),
sortField("name"),
sortField("icao_code"),
sortField("address"),
sortField("landline_number"),
sortField("mobile_number"),
sortField("email"),
sortField("note"),
sortField("is_active"),
sortField("created_at"),
sortField("updated_at"),
)
}