first commit

This commit is contained in:
2023-09-30 21:47:59 +08:00
commit d642ed1a9c
62 changed files with 8635 additions and 0 deletions

View File

View File

@@ -0,0 +1,30 @@
package repositories
import (
"gitter.top/drivers/sdbc"
"pastebin/config"
modelv1 "pastebin/model/v1"
"time"
)
var (
driver *sdbc.Driver
pastebinOperator sdbc.Operator
)
func GetPastebin() sdbc.Operator {
if driver == nil {
cfg := config.Get()
driver = sdbc.NewSDBC(&sdbc.Config{
Dbname: cfg.DBConfig.Dbname,
MaxIdleConn: 20,
MaxOpenConn: 200,
MaxLifetime: time.Hour,
Debug: cfg.DBConfig.Debug,
})
}
if pastebinOperator == nil {
pastebinOperator = driver.BindModel(&modelv1.ModelPastebin{})
}
return pastebinOperator
}