|
1234567891011121314151617181920212223242526272829303132333435363738 |
- package pay
-
- import (
- "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/db"
- "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/md"
- "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/utils/cache"
- )
-
- var cfg = md.DBCfg{
- Host: "",
- Name: "",
- User: "",
- Psw: "",
- ShowLog: false,
- MaxLifetime: 0,
- MaxOpenConns: 0,
- MaxIdleConns: 0,
- Path: "",
- }
-
- func Init(host, name, user, psw, redisAddr string) error {
- cfg.Host = host
- cfg.Name = name
- cfg.User = user
- cfg.Psw = psw
- cfg.ShowLog = true
- cfg.MaxLifetime = 30
- cfg.MaxOpenConns = 100
- cfg.MaxIdleConns = 100
- cfg.Path = "./tmp/%s.logs"
- if err := db.InitDB(&cfg); err != nil {
- return err
- }
- if redisAddr != "" {
- cache.NewRedis(redisAddr)
- }
- return nil
- }
|