19 lines
612 B
Go
19 lines
612 B
Go
package db
|
|
|
|
import (
|
|
exhibitionConfig "exhibition-register/config"
|
|
"github.com/google/wire"
|
|
"gorm.io/gorm"
|
|
"strings"
|
|
)
|
|
|
|
var Provider = wire.NewSet(NewDB)
|
|
|
|
func NewDB() *gorm.DB {
|
|
connDci := strings.Join([]string{exhibitionConfig.Data.ExhibitionRegister.User, ":", exhibitionConfig.Data.ExhibitionRegister.Password,
|
|
"@tcp(", exhibitionConfig.Data.ExhibitionRegister.Host, ":", exhibitionConfig.Data.ExhibitionRegister.Port, ")/",
|
|
exhibitionConfig.Data.ExhibitionRegister.DbName, "?charset=utf8mb4&parseTime=true&loc=Local"}, "")
|
|
ExhibitionRegister := loadMysqlConn(connDci)
|
|
return ExhibitionRegister
|
|
}
|