mysql.go 429 B

1234567891011121314151617181920212223242526272829
  1. package dialector
  2. import (
  3. "eta/eta_mini_ht_api/common/component/config"
  4. "gorm.io/driver/mysql"
  5. "gorm.io/gorm"
  6. )
  7. const (
  8. DriverName = "mysql"
  9. )
  10. type Mysql struct {
  11. mysqlConf *config.DBConfig
  12. }
  13. func (m *Mysql) GetDBName() string {
  14. return DriverName
  15. }
  16. func (m *Mysql) GetDial(dns string) gorm.Dialector {
  17. return mysql.Open(dns)
  18. }
  19. func getMysql() DBDial {
  20. return &Mysql{}
  21. }
  22. func init() {
  23. Register("mysql", getMysql)
  24. }