Custom table name

This commit is contained in:
iyear 2021-07-06 21:03:40 +08:00
parent 0ce6822978
commit f85de1bf74
2 changed files with 6 additions and 0 deletions

View File

@ -40,6 +40,7 @@ type MysqlConfig struct {
User string User string
Password string Password string
DB string DB string
Table string
} }
func InitConfig() { func InitConfig() {
@ -71,6 +72,7 @@ func InitConfig() {
User: viper.GetString("mysql.user"), User: viper.GetString("mysql.user"),
Password: viper.GetString("mysql.password"), Password: viper.GetString("mysql.password"),
DB: viper.GetString("mysql.database"), DB: viper.GetString("mysql.database"),
Table: viper.GetString("mysql.table"),
} }
viper.WatchConfig() viper.WatchConfig()
viper.OnConfigChange(func(e fsnotify.Event) { viper.OnConfigChange(func(e fsnotify.Event) {

View File

@ -2,6 +2,7 @@ package model
import ( import (
"github.com/guonaihong/gout" "github.com/guonaihong/gout"
"github.com/iyear/E5SubBot/config"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
"net/url" "net/url"
@ -30,6 +31,9 @@ const (
scope string = "openid offline_access mail.read user.read" 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 { func NewClient(clientId string, clientSecret string) *Client {
return &Client{ return &Client{
ClientId: clientId, ClientId: clientId,