update
1. add youtube command 2. add google webhook 3. add twitch oauth route 4. add api checkSession middleware
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@ import (
|
||||
type Account struct {
|
||||
ID string `db:"id" cc:"id"`
|
||||
Account string `db:"account" cc:"account"`
|
||||
Password string `db:"password" cc:"password"`
|
||||
Password string `db:"password" cc:"-"`
|
||||
Ctime time.Time `db:"ctime" cc:"ctime"`
|
||||
Mtime time.Time `db:"mtime" cc:"ctime"`
|
||||
}
|
||||
|
||||
+33
-2
@@ -1,6 +1,9 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TwitchGroup -
|
||||
type TwitchGroup struct {
|
||||
@@ -32,6 +35,24 @@ func GetJoinChatChannel() (channels []*TwitchChannel, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetTwitchChannelWithName -
|
||||
func GetTwitchChannelWithName(name string) (ch *TwitchChannel, err error) {
|
||||
if len(name) == 0 {
|
||||
return nil, errors.New("name empty")
|
||||
}
|
||||
err = x.Get(&ch, `select * from "public"."twitch_channel" where "name" = $1`, name)
|
||||
return
|
||||
}
|
||||
|
||||
// GetTwitchChannelWithID -
|
||||
func GetTwitchChannelWithID(id string) (ch *TwitchChannel, err error) {
|
||||
if len(id) == 0 {
|
||||
return nil, errors.New("id empty")
|
||||
}
|
||||
err = x.Get(&ch, `select * from "public"."twitch_channel" where "id" = $1`, id)
|
||||
return
|
||||
}
|
||||
|
||||
// GetWithName -
|
||||
func (p *TwitchChannel) GetWithName() (err error) {
|
||||
stmt, err := x.PrepareNamed(`select * from "public"."twitch_channel" where "name" = :name`)
|
||||
@@ -45,7 +66,7 @@ func (p *TwitchChannel) GetWithName() (err error) {
|
||||
|
||||
// Add -
|
||||
func (p *TwitchChannel) Add() (err error) {
|
||||
stmt, err := x.PrepareNamed(`insert into "public"."twitch_channel" ("name", "laststream", "join", "opayid") values (:name, :laststream, :join, :opayid) returning *`)
|
||||
stmt, err := x.PrepareNamed(`insert into "public"."twitch_channel" ("id", "name", "laststream", "join", "opayid") values (:id, :name, :laststream, :join, :opayid) returning *`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -64,6 +85,16 @@ func (p *TwitchChannel) UpdateStream(streamID string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateName -
|
||||
func (p *TwitchChannel) UpdateName(name string) (err error) {
|
||||
_, err = x.Exec(`update "public"."twitch_channel" set "name" = $1 where "id" = $2`, name, p.ID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
p.Name = name
|
||||
return
|
||||
}
|
||||
|
||||
// GetGroups -
|
||||
func (p *TwitchChannel) GetGroups() (err error) {
|
||||
query := `select g.*, rt.tmpl as tmpl from "public"."twitch_channel" tw
|
||||
|
||||
@@ -25,6 +25,16 @@ func GetYoutubeChannelWithID(id string) (yt *YoutubeChannel, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// Add -
|
||||
func (p *YoutubeChannel) Add() (err error) {
|
||||
stmt, err := x.PrepareNamed(`insert into "public"."youtube_channel" ("id", "name") values (:id, :name) returning *`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = stmt.Get(p, p)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateLastVideo -
|
||||
func (p *YoutubeChannel) UpdateLastVideo(vid string) (err error) {
|
||||
p.LastVideo = vid
|
||||
|
||||
Reference in New Issue
Block a user