Compare commits
2 Commits
4be2d23538
...
5cd3eeb765
Author | SHA1 | Date |
---|---|---|
yequari | 5cd3eeb765 | |
yequari | 2f3a4aee36 |
|
@ -5,19 +5,18 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"modernc.org/sqlite"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type SiteId string
|
type SiteId string
|
||||||
|
|
||||||
type SiteEntry struct {
|
type SiteEntry struct {
|
||||||
id SiteId
|
Id SiteId
|
||||||
name string
|
Name string
|
||||||
webmaster *SiteWebmaster
|
Webmaster *SiteWebmaster
|
||||||
url string
|
Url string
|
||||||
dateAdded time.Time
|
DateAdded time.Time
|
||||||
next SiteId
|
Next SiteId
|
||||||
prev SiteId
|
Prev SiteId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,78 +25,87 @@ func NewSiteEntry(siteName, webmasterEmail, siteUrl string) SiteEntry {
|
||||||
// previous site is the last one inserted
|
// previous site is the last one inserted
|
||||||
// retrieve webmaster from database or create if it doesn't exist
|
// retrieve webmaster from database or create if it doesn't exist
|
||||||
return SiteEntry{
|
return SiteEntry{
|
||||||
id: SiteId(uuid.NewString()),
|
Id: SiteId(uuid.NewString()),
|
||||||
name: siteName,
|
Name: siteName,
|
||||||
url: siteUrl,
|
Url: siteUrl,
|
||||||
dateAdded: time.Now(),
|
DateAdded: time.Now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebmasterId string
|
type WebmasterId string
|
||||||
|
|
||||||
type SiteWebmaster struct {
|
type SiteWebmaster struct {
|
||||||
id WebmasterId
|
Id WebmasterId
|
||||||
name string
|
Name string
|
||||||
email string
|
Email string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSiteWebmaster(name, email string) SiteWebmaster {
|
func NewSiteWebmaster(name, email string) SiteWebmaster {
|
||||||
return SiteWebmaster{ id: WebmasterId(uuid.NewString()),
|
return SiteWebmaster{ Id: WebmasterId(uuid.NewString()),
|
||||||
name: name,
|
Name: name,
|
||||||
email: email,
|
Email: email,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Webring struct {
|
type Webring struct {
|
||||||
Db *sql.DB
|
Db *sql.DB
|
||||||
|
Length int
|
||||||
first SiteId
|
first SiteId
|
||||||
last SiteId
|
last SiteId
|
||||||
length int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWebring(db *sql.DB) *Webring {
|
// Retrieve the first website added to the webring
|
||||||
webring := Webring{Db: db}
|
func (webring *Webring) retrieveFirstSite() (*SiteEntry, error) {
|
||||||
|
return nil, nil
|
||||||
return &webring
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (webring *Webring) retrieveFirstSite() (SiteEntry, error) {
|
// Retrieve the latest website added to the webring
|
||||||
|
func (webring *Webring) retrieveLastSite() (*SiteEntry, error) {
|
||||||
}
|
return nil, nil
|
||||||
|
|
||||||
func (webring *Webring) retrieveLastSite() (SiteEntry, error) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Commit a SiteEntry to the database
|
||||||
func (webring *Webring) CreateSiteEntry(entry *SiteEntry) error {
|
func (webring *Webring) CreateSiteEntry(entry *SiteEntry) error {
|
||||||
// commit to database
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Retrieve a SiteEntry from the database by id
|
||||||
func (webring *Webring) RetrieveSiteEntry(id SiteId) (*SiteEntry, error) {
|
func (webring *Webring) RetrieveSiteEntry(id SiteId) (*SiteEntry, error) {
|
||||||
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Retrieve a SiteEntry from the database by url
|
||||||
|
func (webring *Webring) RetriveSiteEntryByUrl(url string) (*SiteEntry, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update existing SiteEntry with the values of passed entry
|
||||||
func (webring *Webring) UpdateSiteEntry(entry *SiteEntry) error {
|
func (webring *Webring) UpdateSiteEntry(entry *SiteEntry) error {
|
||||||
// update existing SiteEntry
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete SiteEntry from database
|
||||||
func (webring *Webring) DeleteSiteEntry(entry *SiteEntry) error {
|
func (webring *Webring) DeleteSiteEntry(entry *SiteEntry) error {
|
||||||
// delete SiteEntry
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Commit a SiteWebmaster to the database
|
||||||
func (webring *Webring) CreateSiteWebmaster(webmaster *SiteWebmaster) error {
|
func (webring *Webring) CreateSiteWebmaster(webmaster *SiteWebmaster) error {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Retrieve a SiteWebmaster from the database by id
|
||||||
func (webring *Webring) RetrieveSiteWebmaster(id WebmasterId) (*SiteWebmaster, error) {
|
func (webring *Webring) RetrieveSiteWebmaster(id WebmasterId) (*SiteWebmaster, error) {
|
||||||
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update a SiteWebmaster in the database with the values of the passed webmaster
|
||||||
func (webring *Webring) UpdateSiteWebmaster(webmaster *SiteWebmaster) error {
|
func (webring *Webring) UpdateSiteWebmaster(webmaster *SiteWebmaster) error {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete a SiteWebmaster from the database
|
||||||
func (webring *Webring) DeleteSiteWebmaster(webmaster *SiteWebmaster) error {
|
func (webring *Webring) DeleteSiteWebmaster(webmaster *SiteWebmaster) error {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue