Add webring struct, make all previous methods webring methods
This commit is contained in:
parent
e59fe33b55
commit
4be2d23538
|
@ -1,35 +0,0 @@
|
|||
package webring
|
||||
|
||||
import "github.com/google/uuid"
|
||||
|
||||
type WebmasterId string
|
||||
|
||||
type SiteWebmaster struct {
|
||||
id WebmasterId
|
||||
name string
|
||||
email string
|
||||
}
|
||||
|
||||
func NewSiteWebmaster(name, email string) SiteWebmaster {
|
||||
return SiteWebmaster{
|
||||
id: WebmasterId(uuid.NewString()),
|
||||
name: name,
|
||||
email: email,
|
||||
}
|
||||
}
|
||||
|
||||
func RetrieveSiteWebmaster(id WebmasterId) SiteWebmaster {
|
||||
return SiteWebmaster{}
|
||||
}
|
||||
|
||||
func (webmaster SiteWebmaster) Create() {
|
||||
|
||||
}
|
||||
|
||||
func (webmaster SiteWebmaster) Update() {
|
||||
|
||||
}
|
||||
|
||||
func (webmaster SiteWebmaster) Delete() {
|
||||
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
package webring
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"modernc.org/sqlite"
|
||||
)
|
||||
|
||||
type SiteId string
|
||||
|
@ -31,20 +33,71 @@ func NewSiteEntry(siteName, webmasterEmail, siteUrl string) SiteEntry {
|
|||
}
|
||||
}
|
||||
|
||||
func RetrieveSiteEntry(id SiteId) SiteEntry {
|
||||
return SiteEntry{}
|
||||
type WebmasterId string
|
||||
|
||||
type SiteWebmaster struct {
|
||||
id WebmasterId
|
||||
name string
|
||||
email string
|
||||
}
|
||||
|
||||
func (site SiteEntry) Create() {
|
||||
func NewSiteWebmaster(name, email string) SiteWebmaster {
|
||||
return SiteWebmaster{ id: WebmasterId(uuid.NewString()),
|
||||
name: name,
|
||||
email: email,
|
||||
}
|
||||
}
|
||||
|
||||
type Webring struct {
|
||||
Db *sql.DB
|
||||
first SiteId
|
||||
last SiteId
|
||||
length int
|
||||
}
|
||||
|
||||
func NewWebring(db *sql.DB) *Webring {
|
||||
webring := Webring{Db: db}
|
||||
|
||||
return &webring
|
||||
}
|
||||
|
||||
func (webring *Webring) retrieveFirstSite() (SiteEntry, error) {
|
||||
|
||||
}
|
||||
|
||||
func (webring *Webring) retrieveLastSite() (SiteEntry, error) {
|
||||
|
||||
}
|
||||
|
||||
func (webring *Webring) CreateSiteEntry(entry *SiteEntry) error {
|
||||
// commit to database
|
||||
}
|
||||
|
||||
func (site SiteEntry) Update() {
|
||||
func (webring *Webring) RetrieveSiteEntry(id SiteId) (*SiteEntry, error) {
|
||||
|
||||
}
|
||||
|
||||
func (webring *Webring) UpdateSiteEntry(entry *SiteEntry) error {
|
||||
// update existing SiteEntry
|
||||
}
|
||||
|
||||
func (site SiteEntry) Delete() {
|
||||
func (webring *Webring) DeleteSiteEntry(entry *SiteEntry) error {
|
||||
// delete SiteEntry
|
||||
}
|
||||
|
||||
func (webring *Webring) CreateSiteWebmaster(webmaster *SiteWebmaster) error {
|
||||
|
||||
}
|
||||
|
||||
func (webring *Webring) RetrieveSiteWebmaster(id WebmasterId) (*SiteWebmaster, error) {
|
||||
|
||||
}
|
||||
|
||||
func (webring *Webring) UpdateSiteWebmaster(webmaster *SiteWebmaster) error {
|
||||
|
||||
}
|
||||
|
||||
func (webring *Webring) DeleteSiteWebmaster(webmaster *SiteWebmaster) error {
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue