From f85de1bf74f93be7f5377194cab848e81ca26c42 Mon Sep 17 00:00:00 2001 From: iyear Date: Tue, 6 Jul 2021 21:03:40 +0800 Subject: [PATCH] Custom table name --- config/config.go | 2 ++ model/client.go | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/config/config.go b/config/config.go index 93bb476..5c49c23 100644 --- a/config/config.go +++ b/config/config.go @@ -40,6 +40,7 @@ type MysqlConfig struct { User string Password string DB string + Table string } func InitConfig() { @@ -71,6 +72,7 @@ func InitConfig() { User: viper.GetString("mysql.user"), Password: viper.GetString("mysql.password"), DB: viper.GetString("mysql.database"), + Table: viper.GetString("mysql.table"), } viper.WatchConfig() viper.OnConfigChange(func(e fsnotify.Event) { diff --git a/model/client.go b/model/client.go index 2c39db5..6797c1c 100644 --- a/model/client.go +++ b/model/client.go @@ -2,6 +2,7 @@ package model import ( "github.com/guonaihong/gout" + "github.com/iyear/E5SubBot/config" "github.com/pkg/errors" "github.com/tidwall/gjson" "net/url" @@ -30,6 +31,9 @@ const ( scope string = "openid offline_access mail.read user.read" ) +func (c *Client) TableName() string { + return config.Mysql.Table +} func NewClient(clientId string, clientSecret string) *Client { return &Client{ ClientId: clientId,