mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
refactor: update resource id naming
This commit is contained in:
@@ -32,8 +32,10 @@ func (v Visibility) String() string {
|
||||
}
|
||||
|
||||
type Memo struct {
|
||||
ID int32
|
||||
ResourceName string
|
||||
// ID is the system generated unique identifier for the memo.
|
||||
ID int32
|
||||
// UID is the user defined unique identifier for the memo.
|
||||
UID string
|
||||
|
||||
// Standard fields
|
||||
RowStatus RowStatus
|
||||
@@ -51,8 +53,8 @@ type Memo struct {
|
||||
}
|
||||
|
||||
type FindMemo struct {
|
||||
ID *int32
|
||||
ResourceName *string
|
||||
ID *int32
|
||||
UID *string
|
||||
|
||||
// Standard fields
|
||||
RowStatus *RowStatus
|
||||
@@ -76,13 +78,13 @@ type FindMemo struct {
|
||||
}
|
||||
|
||||
type UpdateMemo struct {
|
||||
ID int32
|
||||
ResourceName *string
|
||||
CreatedTs *int64
|
||||
UpdatedTs *int64
|
||||
RowStatus *RowStatus
|
||||
Content *string
|
||||
Visibility *Visibility
|
||||
ID int32
|
||||
UID *string
|
||||
CreatedTs *int64
|
||||
UpdatedTs *int64
|
||||
RowStatus *RowStatus
|
||||
Content *string
|
||||
Visibility *Visibility
|
||||
}
|
||||
|
||||
type DeleteMemo struct {
|
||||
@@ -90,8 +92,8 @@ type DeleteMemo struct {
|
||||
}
|
||||
|
||||
func (s *Store) CreateMemo(ctx context.Context, create *Memo) (*Memo, error) {
|
||||
if !util.ResourceNameMatcher.MatchString(create.ResourceName) {
|
||||
return nil, errors.New("resource name is invalid")
|
||||
if !util.UIDMatcher.MatchString(create.UID) {
|
||||
return nil, errors.New("invalid uid")
|
||||
}
|
||||
return s.driver.CreateMemo(ctx, create)
|
||||
}
|
||||
@@ -114,8 +116,8 @@ func (s *Store) GetMemo(ctx context.Context, find *FindMemo) (*Memo, error) {
|
||||
}
|
||||
|
||||
func (s *Store) UpdateMemo(ctx context.Context, update *UpdateMemo) error {
|
||||
if update.ResourceName != nil && !util.ResourceNameMatcher.MatchString(*update.ResourceName) {
|
||||
return errors.New("resource name is invalid")
|
||||
if update.UID != nil && !util.UIDMatcher.MatchString(*update.UID) {
|
||||
return errors.New("invalid uid")
|
||||
}
|
||||
return s.driver.UpdateMemo(ctx, update)
|
||||
}
|
||||
|
Reference in New Issue
Block a user