From 49194758b850f84900eff25b02f6cd8ea46bcd0e Mon Sep 17 00:00:00 2001 From: dengbiao Date: Wed, 11 Dec 2024 13:51:06 +0800 Subject: [PATCH] update --- src/dao/sys_cfg_dao.go | 1 + src/implement/sys_cfg_implement.go | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/dao/sys_cfg_dao.go b/src/dao/sys_cfg_dao.go index d9e5bfc..6efe736 100644 --- a/src/dao/sys_cfg_dao.go +++ b/src/dao/sys_cfg_dao.go @@ -3,6 +3,7 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" type SysCfgDao interface { + Close() error SysCfgGetAll() (*[]model.SysCfg, error) SysCfgGetOneNoDataNoErr(key string) (*model.SysCfg, error) SysCfgGetOne(key string) (*model.SysCfg, error) diff --git a/src/implement/sys_cfg_implement.go b/src/implement/sys_cfg_implement.go index 43feeed..67aa50e 100644 --- a/src/implement/sys_cfg_implement.go +++ b/src/implement/sys_cfg_implement.go @@ -26,6 +26,13 @@ type SysCfgDb struct { RedisAddr redis.Conn } +func (s SysCfgDb) Close() error { //TODO::使用时,强制defer调用此析构函数 + if s.RedisAddr != nil { + return s.RedisAddr.Close() + } + return nil +} + func (s SysCfgDb) SysCfgGetAll() (*[]model.SysCfg, error) { var cfgList []model.SysCfg if err := s.Db.Cols("key,val,memo").Find(&cfgList); err != nil {