2022-05-19 18:32:04 +08:00
|
|
|
package store
|
|
|
|
|
|
|
|
import (
|
2022-08-07 10:17:12 +08:00
|
|
|
"context"
|
2023-10-09 21:18:47 +08:00
|
|
|
"errors"
|
2022-05-19 18:32:04 +08:00
|
|
|
)
|
|
|
|
|
2023-07-06 21:56:42 +08:00
|
|
|
type MemoOrganizer struct {
|
2023-08-04 21:55:07 +08:00
|
|
|
MemoID int32
|
|
|
|
UserID int32
|
2022-05-19 18:32:04 +08:00
|
|
|
Pinned bool
|
|
|
|
}
|
|
|
|
|
2023-07-06 21:56:42 +08:00
|
|
|
type FindMemoOrganizer struct {
|
2023-08-04 21:55:07 +08:00
|
|
|
MemoID int32
|
|
|
|
UserID int32
|
2022-05-19 18:32:04 +08:00
|
|
|
}
|
|
|
|
|
2023-07-06 21:56:42 +08:00
|
|
|
type DeleteMemoOrganizer struct {
|
2023-08-04 21:55:07 +08:00
|
|
|
MemoID *int32
|
|
|
|
UserID *int32
|
2022-05-19 18:32:04 +08:00
|
|
|
}
|
|
|
|
|
2023-07-06 22:53:38 +08:00
|
|
|
func (s *Store) UpsertMemoOrganizer(ctx context.Context, upsert *MemoOrganizer) (*MemoOrganizer, error) {
|
2023-09-27 08:54:50 +08:00
|
|
|
return s.driver.UpsertMemoOrganizer(ctx, upsert)
|
2022-05-19 18:32:04 +08:00
|
|
|
}
|
|
|
|
|
2023-07-06 22:53:38 +08:00
|
|
|
func (s *Store) GetMemoOrganizer(ctx context.Context, find *FindMemoOrganizer) (*MemoOrganizer, error) {
|
2023-10-09 21:18:47 +08:00
|
|
|
list, err := s.ListMemoOrganizer(ctx, find)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(list) == 0 {
|
|
|
|
return nil, errors.New("not found")
|
|
|
|
}
|
|
|
|
|
|
|
|
return list[0], nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Store) ListMemoOrganizer(ctx context.Context, find *FindMemoOrganizer) ([]*MemoOrganizer, error) {
|
|
|
|
return s.driver.ListMemoOrganizer(ctx, find)
|
2022-05-19 18:32:04 +08:00
|
|
|
}
|
|
|
|
|
2023-07-06 22:53:38 +08:00
|
|
|
func (s *Store) DeleteMemoOrganizer(ctx context.Context, delete *DeleteMemoOrganizer) error {
|
2023-09-27 08:54:50 +08:00
|
|
|
return s.driver.DeleteMemoOrganizer(ctx, delete)
|
2022-11-06 12:21:58 +08:00
|
|
|
}
|