tank/code/rest/preference_service.go
2019-05-06 02:18:08 +08:00

45 lines
759 B
Go

package rest
import "github.com/eyebluecn/tank/code/core"
//@Service
type PreferenceService struct {
BaseBean
preferenceDao *PreferenceDao
preference *Preference
}
func (this *PreferenceService) Init() {
this.BaseBean.Init()
b := core.CONTEXT.GetBean(this.preferenceDao)
if b, ok := b.(*PreferenceDao); ok {
this.preferenceDao = b
}
}
func (this *PreferenceService) Fetch() *Preference {
if this.preference == nil {
this.preference = this.preferenceDao.Fetch()
}
return this.preference
}
//清空单例配置。
func (this *PreferenceService) Reset() {
this.preference = nil
}
//System cleanup.
func (this *PreferenceService) Cleanup() {
this.logger.Info("[PreferenceService] clean up. Delete all preference")
this.Reset()
}