feat(links): new link model
This commit is contained in:
parent
586c7dd9c6
commit
ac6d38ee4d
1 changed files with 31 additions and 5 deletions
|
|
@ -1,16 +1,42 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/google/uuid"
|
||||||
|
|
||||||
type Link struct {
|
type Link struct {
|
||||||
|
id string
|
||||||
fromNoteID string
|
fromNoteID string
|
||||||
toNoteID string
|
targetSlug string
|
||||||
raw string
|
raw string
|
||||||
|
display string
|
||||||
|
line int
|
||||||
|
col int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLink(fromNoteID, toNoteID, raw string) *Link {
|
func NewLink(id, fromNoteID, targetSlug, raw, display string, line, col int) *Link {
|
||||||
return &Link{
|
return &Link{
|
||||||
|
id: id,
|
||||||
fromNoteID: fromNoteID,
|
fromNoteID: fromNoteID,
|
||||||
toNoteID: toNoteID,
|
targetSlug: targetSlug,
|
||||||
raw: raw,
|
raw: raw,
|
||||||
|
display: display,
|
||||||
|
line: line,
|
||||||
|
col: col,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateLink(fromNoteID, targetSlug, raw, display string, line, col int) *Link {
|
||||||
|
id, err := uuid.NewV7()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return &Link{
|
||||||
|
id: id.String(),
|
||||||
|
fromNoteID: fromNoteID,
|
||||||
|
targetSlug: targetSlug,
|
||||||
|
raw: raw,
|
||||||
|
display: display,
|
||||||
|
line: line,
|
||||||
|
col: col,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -18,8 +44,8 @@ func (l *Link) FromNoteID() string {
|
||||||
return l.fromNoteID
|
return l.fromNoteID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Link) ToNoteID() string {
|
func (l *Link) TargetSlug() string {
|
||||||
return l.toNoteID
|
return l.targetSlug
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Link) Raw() string {
|
func (l *Link) Raw() string {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue