Compare commits

..

No commits in common. "5cd3eeb765872c116e3fe3b98ee5e33f18e6d7df" and "4be2d235380e36246dad6f7891a055ed54d2b936" have entirely different histories.

1 changed files with 37 additions and 45 deletions

View File

@ -5,18 +5,19 @@ 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
} }
@ -25,87 +26,78 @@ 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
} }
// Retrieve the first website added to the webring func NewWebring(db *sql.DB) *Webring {
func (webring *Webring) retrieveFirstSite() (*SiteEntry, error) { webring := Webring{Db: db}
return nil, nil
return &webring
} }
// Retrieve the latest website added to the webring func (webring *Webring) retrieveFirstSite() (SiteEntry, error) {
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 {
return nil // commit to database
} }
// 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 {
return nil // update existing SiteEntry
} }
// Delete SiteEntry from database
func (webring *Webring) DeleteSiteEntry(entry *SiteEntry) error { func (webring *Webring) DeleteSiteEntry(entry *SiteEntry) error {
return nil // delete SiteEntry
} }
// 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
} }