user instruments

This commit is contained in:
yash 2026-04-28 11:42:07 +03:00
parent dd03cae0f3
commit abb2411af7
9 changed files with 494 additions and 48 deletions

View file

@ -13,8 +13,16 @@ type Storage interface {
UserByID(ctx context.Context, id entities.UserID) (*entities.User, error)
UserByTelegramID(ctx context.Context, tgID entities.TelegramID) (*entities.User, error)
InstrumentList(ctx context.Context, offset, limit int) ([]entities.Instrument, error)
// InstrumentList returns instruments visible to userID: global ones plus any
// the user has explicitly added.
InstrumentList(ctx context.Context, userID entities.UserID, offset, limit int) ([]entities.Instrument, error)
// CreateInstrument upserts the instrument (and its currencies) and returns the ID,
// whether the row was just created or already existed.
CreateInstrument(ctx context.Context, instrument *entities.Instrument) (entities.InstrumentID, error)
// AddUserInstrument links an instrument to a user (idempotent).
AddUserInstrument(ctx context.Context, userID entities.UserID, instrumentID entities.InstrumentID) error
// RemoveUserInstrument removes a user's link to a non-global instrument.
RemoveUserInstrument(ctx context.Context, userID entities.UserID, instrumentID entities.InstrumentID) error
SaveAlert(ctx context.Context, alert *entities.Alert) (entities.AlertID, error)
AllActiveAlerts(ctx context.Context) ([]entities.Alert, error)