instrument usecases & repository methods
This commit is contained in:
parent
39b89fc404
commit
16d38bb3cf
7 changed files with 100 additions and 13 deletions
28
internal/usecase/instrument.go
Normal file
28
internal/usecase/instrument.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package usecase
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"gitea.computernetthings.ru/yash/crypto_alert_bot/internal/entities"
|
||||
)
|
||||
|
||||
func (uc *Usecase) InstrumentList(ctx context.Context, offset, limit int) ([]entities.Instrument, error) {
|
||||
instruments, err := uc.storage.InstrumentList(ctx, offset, limit)
|
||||
if err != nil {
|
||||
uc.log.Error("failed to list instruments", "offset", offset, "limit", limit, "err", err)
|
||||
return nil, fmt.Errorf("failed to list instruments: %w", err)
|
||||
}
|
||||
|
||||
return instruments, nil
|
||||
}
|
||||
|
||||
func (uc *Usecase) CreateInstrument(ctx context.Context, instrument *entities.Instrument) (entities.InstrumentID, error) {
|
||||
id, err := uc.storage.CreateInstrument(ctx, instrument)
|
||||
if err != nil {
|
||||
uc.log.Error("failed to create instrument", "instrument", instrument, "err", err)
|
||||
return "", fmt.Errorf("failed to create instrument: %w", err)
|
||||
}
|
||||
|
||||
return id, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue