twitch streaming check ok
This commit is contained in:
@@ -2,18 +2,19 @@ package model
|
||||
|
||||
import "time"
|
||||
|
||||
type FBGroups struct {
|
||||
// FBGroup -
|
||||
type FBGroup struct {
|
||||
*LineGroup
|
||||
Tmpl string `db:"tmpl"`
|
||||
}
|
||||
|
||||
// FacebookPage - struct
|
||||
type FacebookPage struct {
|
||||
ID string `db:"id" cc:"id"`
|
||||
LastPost string `db:"lastpost" cc:"lastpost"`
|
||||
Ctime time.Time `db:"ctime" cc:"ctime"`
|
||||
Mtime time.Time `db:"mtime" cc:"ctime"`
|
||||
Groups []*FBGroups `db:"-"`
|
||||
ID string `db:"id" cc:"id"`
|
||||
LastPost string `db:"lastpost" cc:"lastpost"`
|
||||
Ctime time.Time `db:"ctime" cc:"ctime"`
|
||||
Mtime time.Time `db:"mtime" cc:"ctime"`
|
||||
Groups []*FBGroup `db:"-"`
|
||||
}
|
||||
|
||||
// GetAllFacebookPage -
|
||||
@@ -25,6 +26,7 @@ func GetAllFacebookPage() (pages []*FacebookPage, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// UpdatePost -
|
||||
func (p *FacebookPage) UpdatePost(postID string) (err error) {
|
||||
query := `update "public"."facebook_page" set "lastpost" = $1 where id = $2`
|
||||
_, err = x.Exec(query, postID, p.ID)
|
||||
@@ -35,6 +37,7 @@ func (p *FacebookPage) UpdatePost(postID string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetGroups -
|
||||
func (p *FacebookPage) GetGroups() (err error) {
|
||||
query := `select g.*, rt.tmpl as tmpl from "public"."facebook_page" p
|
||||
left join "public"."line_fb_rt" rt
|
||||
|
||||
+42
-11
@@ -2,19 +2,50 @@ package model
|
||||
|
||||
import "time"
|
||||
|
||||
// TwitchChannel - struct
|
||||
type TwitchChannel struct {
|
||||
ID string `db:"id" cc:"id"`
|
||||
Name string `db:"name" cc:"name"`
|
||||
LastStream string `db:"laststream" cc:"laststream"`
|
||||
Join bool `db:"join" cc:"join"`
|
||||
OpayID string `db:"opayid" cc:"opayid"`
|
||||
Ctime time.Time `db:"ctime" cc:"ctime"`
|
||||
Mtime time.Time `db:"mtime" cc:"ctime"`
|
||||
// TwitchGroup -
|
||||
type TwitchGroup struct {
|
||||
*LineGroup
|
||||
Tmpl string `db:"tmpl"`
|
||||
}
|
||||
|
||||
// GetAllChannel -
|
||||
func GetAllChannel() (channels []*TwitchChannel, err error) {
|
||||
// TwitchChannel - struct
|
||||
type TwitchChannel struct {
|
||||
ID string `db:"id" cc:"id"`
|
||||
Name string `db:"name" cc:"name"`
|
||||
LastStream string `db:"laststream" cc:"laststream"`
|
||||
Join bool `db:"join" cc:"join"`
|
||||
OpayID string `db:"opayid" cc:"opayid"`
|
||||
Ctime time.Time `db:"ctime" cc:"ctime"`
|
||||
Mtime time.Time `db:"mtime" cc:"ctime"`
|
||||
Groups []*TwitchGroup `db:"-"`
|
||||
}
|
||||
|
||||
// GetAllTwitchChannel -
|
||||
func GetAllTwitchChannel() (channels []*TwitchChannel, err error) {
|
||||
err = x.Select(&channels, `select * from "public"."twitch_channel"`)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateStream -
|
||||
func (p *TwitchChannel) UpdateStream(streamID string) (err error) {
|
||||
query := `update "public"."twitch_channel" set "laststream" = $1 where "id" = $2`
|
||||
_, err = x.Exec(query, streamID, p.ID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
p.LastStream = streamID
|
||||
return
|
||||
}
|
||||
|
||||
// GetGroups -
|
||||
func (p *TwitchChannel) GetGroups() (err error) {
|
||||
query := `select g.*, rt.tmpl as tmpl from "public"."twitch_channel" tw
|
||||
left join "public"."line_twitch_rt" rt
|
||||
on rt.twitch = tw.id
|
||||
left join "public"."line_group" g
|
||||
on g.id = rt.line
|
||||
where
|
||||
tw.id = $1`
|
||||
err = x.Select(&p.Groups, query, p.ID)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user