71 lines
1.5 KiB
Go
71 lines
1.5 KiB
Go
package app
|
|
|
|
import (
|
|
"f5"
|
|
"main/constant"
|
|
"mt"
|
|
"main/middleware"
|
|
. "main/global"
|
|
)
|
|
|
|
type app struct {
|
|
initCb func()
|
|
unInitCb func()
|
|
}
|
|
|
|
func (this *app) GetPkgName() string {
|
|
return "mailserver"
|
|
}
|
|
|
|
func (this *app) GetHttpListenPort() int32 {
|
|
return mt.Table.MailCluster.GetHttpListenPort()
|
|
}
|
|
|
|
func (this *app) Run(initCb func(), unInitCb func()) {
|
|
this.initCb = initCb
|
|
this.unInitCb = unInitCb
|
|
f5.Run(this)
|
|
}
|
|
|
|
func (this *app) Init() {
|
|
f5.LoadMetaTable(mt.Table)
|
|
this.registerDataSources()
|
|
this.initCb()
|
|
f5.GetApp().GetGinEngine().Use(middleware.CaForward, middleware.CaAuth)
|
|
}
|
|
|
|
func (this *app) UnInit() {
|
|
this.unInitCb()
|
|
}
|
|
|
|
func (this *app) Update() {
|
|
}
|
|
|
|
func (this *app) registerDataSources() {
|
|
f5.GetGoStyleDb().RegisterDataSource(
|
|
constant.MAIL_DB,
|
|
mt.Table.MailDb.GetById(0).GetHost(),
|
|
mt.Table.MailDb.GetById(0).GetPort(),
|
|
mt.Table.MailDb.GetById(0).GetUser(),
|
|
mt.Table.MailDb.GetById(0).GetPasswd(),
|
|
mt.Table.MailDb.GetById(0).GetDatabase(),
|
|
1,
|
|
mt.Table.MailDb.GetById(0).GetMaxOpenConns(),
|
|
mt.Table.MailDb.GetById(0).GetMaxIdleConns())
|
|
|
|
f5.GetJsStyleDb().RegisterDataSource(
|
|
constant.MAIL_DB,
|
|
mt.Table.MailDb.GetById(0).GetHost(),
|
|
mt.Table.MailDb.GetById(0).GetPort(),
|
|
mt.Table.MailDb.GetById(0).GetUser(),
|
|
mt.Table.MailDb.GetById(0).GetPasswd(),
|
|
mt.Table.MailDb.GetById(0).GetDatabase(),
|
|
1,
|
|
mt.Table.MailDb.GetById(0).GetMaxOpenConns(),
|
|
mt.Table.MailDb.GetById(0).GetMaxIdleConns())
|
|
}
|
|
|
|
func (this *app) HasTask() bool {
|
|
return GetMailMgr().HasTask()
|
|
}
|