exhibition-register/pkg/db/exhibition_register.go

19 lines
612 B
Go
Raw Normal View History

2024-01-29 09:02:58 +00:00
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
}