48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package pointsmall
|
|
|
|
import (
|
|
"context"
|
|
|
|
"hfb_sys/backend/internal/model"
|
|
)
|
|
|
|
type Service struct {
|
|
repo *Repository
|
|
}
|
|
|
|
func NewService(repo *Repository) *Service {
|
|
return &Service{repo: repo}
|
|
}
|
|
|
|
func (s *Service) Summary(ctx context.Context, userID uint64) (*SummaryDTO, error) {
|
|
return s.repo.Summary(ctx, userID)
|
|
}
|
|
|
|
func (s *Service) Ledger(ctx context.Context, userID uint64, limit int) ([]model.RenterGrowthLedger, error) {
|
|
return s.repo.Ledger(ctx, userID, limit)
|
|
}
|
|
|
|
func (s *Service) ListProducts(ctx context.Context, includeOffline bool) ([]ProductDTO, error) {
|
|
return s.repo.ListProducts(ctx, includeOffline)
|
|
}
|
|
|
|
func (s *Service) CreateProduct(ctx context.Context, req ProductRequest) (*ProductDTO, error) {
|
|
return s.repo.CreateProduct(ctx, req)
|
|
}
|
|
|
|
func (s *Service) UpdateProduct(ctx context.Context, id uint64, req ProductRequest) (*ProductDTO, error) {
|
|
return s.repo.UpdateProduct(ctx, id, req)
|
|
}
|
|
|
|
func (s *Service) Redeem(ctx context.Context, userID, productID uint64, req RedeemRequest) (*RedemptionDTO, error) {
|
|
return s.repo.Redeem(ctx, userID, productID, req)
|
|
}
|
|
|
|
func (s *Service) ListRedemptions(ctx context.Context, userID uint64, admin bool) ([]RedemptionDTO, error) {
|
|
return s.repo.ListRedemptions(ctx, userID, admin)
|
|
}
|
|
|
|
func (s *Service) CompleteRedemption(ctx context.Context, adminID, id uint64, remark string) (*RedemptionDTO, error) {
|
|
return s.repo.CompleteRedemption(ctx, adminID, id, remark)
|
|
}
|