memo_organizer.go 988 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package store
  2. import (
  3. "context"
  4. "errors"
  5. )
  6. type MemoOrganizer struct {
  7. MemoID int32
  8. UserID int32
  9. Pinned bool
  10. }
  11. type FindMemoOrganizer struct {
  12. MemoID int32
  13. UserID int32
  14. }
  15. type DeleteMemoOrganizer struct {
  16. MemoID *int32
  17. UserID *int32
  18. }
  19. func (s *Store) UpsertMemoOrganizer(ctx context.Context, upsert *MemoOrganizer) (*MemoOrganizer, error) {
  20. return s.driver.UpsertMemoOrganizer(ctx, upsert)
  21. }
  22. func (s *Store) GetMemoOrganizer(ctx context.Context, find *FindMemoOrganizer) (*MemoOrganizer, error) {
  23. list, err := s.ListMemoOrganizer(ctx, find)
  24. if err != nil {
  25. return nil, err
  26. }
  27. if len(list) == 0 {
  28. return nil, errors.New("not found")
  29. }
  30. return list[0], nil
  31. }
  32. func (s *Store) ListMemoOrganizer(ctx context.Context, find *FindMemoOrganizer) ([]*MemoOrganizer, error) {
  33. return s.driver.ListMemoOrganizer(ctx, find)
  34. }
  35. func (s *Store) DeleteMemoOrganizer(ctx context.Context, delete *DeleteMemoOrganizer) error {
  36. return s.driver.DeleteMemoOrganizer(ctx, delete)
  37. }