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,51 @@
package service
import (
"context"
"wucher/internal/domain/forces_present"
"wucher/internal/shared/pkg/sortkey"
)
type ForcesPresentService struct {
repo forces_present.Repository
}
func NewForcesPresentService(repo forces_present.Repository) *ForcesPresentService {
return &ForcesPresentService{repo: repo}
}
func (s *ForcesPresentService) Create(ctx context.Context, row *forces_present.ForcesPresent) error {
return s.repo.Create(ctx, row)
}
func (s *ForcesPresentService) Update(ctx context.Context, row *forces_present.ForcesPresent) error {
return s.repo.Update(ctx, row)
}
func (s *ForcesPresentService) Delete(ctx context.Context, id []byte, deletedBy []byte) error {
return s.repo.Delete(ctx, id, deletedBy)
}
func (s *ForcesPresentService) GetByID(ctx context.Context, id []byte) (*forces_present.ForcesPresent, error) {
return s.repo.GetByID(ctx, id)
}
func (s *ForcesPresentService) List(ctx context.Context, filter, sort string, limit, offset int) ([]forces_present.ForcesPresent, int64, error) {
return s.repo.List(ctx, filter, normalizeForcesPresentSort(sort), limit, offset)
}
func normalizeForcesPresentSort(sort string) string {
return normalizeSortByRules(sort,
sortExpr(
joinSortClauses(sortkey.ActivePositiveSortClauses("", "is_active", "sortkey", "name", false)),
joinSortClauses(sortkey.ActivePositiveSortClauses("", "is_active", "sortkey", "name", true)),
"sortkey",
),
sortField("name"),
sortField("note"),
sortField("is_active"),
sortField("created_at"),
sortField("updated_at"),
)
}