forked from Team254/cheesy-arena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sponsor_slide.go
49 lines (41 loc) · 1.38 KB
/
sponsor_slide.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2014 Team 254. All Rights Reserved.
// Author: [email protected] (Nick Eyre)
//
// Model and datastore CRUD methods for the sponsor slideshow.
package main
type SponsorSlide struct {
Id int
Subtitle string
Line1 string
Line2 string
Image string
DisplayTimeSec int
}
func (database *Database) CreateSponsorSlide(sponsorSlide *SponsorSlide) error {
return database.sponsorSlideMap.Insert(sponsorSlide)
}
func (database *Database) GetSponsorSlideById(id int) (*SponsorSlide, error) {
sponsorSlide := new(SponsorSlide)
err := database.sponsorSlideMap.Get(sponsorSlide, id)
if err != nil && err.Error() == "sql: no rows in result set" {
sponsorSlide = nil
err = nil
}
return sponsorSlide, err
}
func (database *Database) SaveSponsorSlide(sponsorSlide *SponsorSlide) error {
_, err := database.sponsorSlideMap.Update(sponsorSlide)
return err
}
func (database *Database) DeleteSponsorSlide(sponsorSlide *SponsorSlide) error {
_, err := database.sponsorSlideMap.Delete(sponsorSlide)
return err
}
func (database *Database) TruncateSponsorSlides() error {
return database.sponsorSlideMap.TruncateTables()
}
func (database *Database) GetAllSponsorSlides() ([]SponsorSlide, error) {
var sponsorSlides []SponsorSlide
err := database.teamMap.Select(&sponsorSlides, "SELECT * FROM sponsor_slides ORDER BY id")
return sponsorSlides, err
}