import (
"database/sql"
"github.com/gogf/gf/contrib/drivers/mysql/v2"
"github.com/gogf/gf/v2/database/gdb"
)
type MyBizDriver struct {
mysql.Driver
}
// Open creates and returns an underlying sql.DB object for mysql.
// Note that it converts time.Time argument to local timezone in default.
func (d *MyBizDriver) Open(config *gdb.ConfigNode) (db *sql.DB, err error) {
config.User = d.decode(config.User)
config.Pass = d.decode(config.Pass)
return d.Driver.Open(config)
}
func (d *MyBizDriver) decode(s string) string {
// 执行字段解密处理逻辑
// ...
return s
}