/
models.go
64 lines (55 loc) · 1.52 KB
/
models.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package models
import (
"github.com/jinzhu/gorm"
"time"
"fmt"
)
type Account struct {
gorm.Model
ExtId int
Name string
GaAccessToken string
GaViewId string
GaQuotaUser string
GaRefreshToken string
Active bool `sql:"DEFAULT:true"`
Tickets []Ticket `gorm:"ForeignKey:AccountExtId"`
}
type Ticket struct {
gorm.Model
AccountExtId int `gorm:"not null"`
ExtId int `gorm:"not null"`
PublishedAt time.Time
Url string `gorm:"type:text;not null"`
Active bool `sql:"DEFAULT:true"`
GaPageViews int
}
type TicketUpdate struct {
Id int
AccId int
PageViews int
}
type AccJoinTicket struct {
AccId int
GaAccessToken string
GaViewId string
GaQuotaUser string
GaRefreshToken string
ExtId int
Url string
PublishedAt time.Time
GaPageViews int
}
func (ajt AccJoinTicket) String() string {
return "AccJoinTicket: {" +
fmt.Sprintf("TicketId: %v, ", ajt.ExtId) +
fmt.Sprintf("Url: %v, ", ajt.Url) +
fmt.Sprintf("GaPageViews: %v, ", ajt.GaPageViews) +
fmt.Sprintf("PublishedAt: %v, ", ajt.PublishedAt) +
fmt.Sprintf("AccId: %v, ", ajt.AccId) +
fmt.Sprintf("GaAccessToken: %v, ", ajt.GaAccessToken) +
fmt.Sprintf("GaRefreshToken: %v, ", ajt.GaRefreshToken) +
fmt.Sprintf("GaViewId: %v, ", ajt.GaViewId) +
fmt.Sprintf("GaQuotaUser: %v ", ajt.GaQuotaUser) +
"}\n"
}