tank/code/rest/preference_service.go
2019-04-28 01:29:13 +08:00

48 lines
894 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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()
//手动装填本实例的Bean. 这里必须要用中间变量方可。
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
}
//执行清理操作
func (this *PreferenceService) Cleanup() {
this.logger.Info("[PreferenceService]执行清理重置缓存中的preference。")
this.Reset()
}