83 lines
2.1 KiB
Go
83 lines
2.1 KiB
Go
package sociaty
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/base"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
"time"
|
|
)
|
|
|
|
var _ comm.ISociaty = (*Sociaty)(nil)
|
|
|
|
type Sociaty struct {
|
|
modules.ModuleBase
|
|
api *apiComp
|
|
service base.IRPCXService
|
|
modelSociaty *ModelSociaty
|
|
modelSociatyTask *ModelSociatyTask
|
|
modelSociatyLog *ModelSociatyLog
|
|
configure *configureComp
|
|
}
|
|
|
|
func NewModule() core.IModule {
|
|
return &Sociaty{}
|
|
}
|
|
|
|
func (this *Sociaty) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
|
err = this.ModuleBase.Init(service, module, options)
|
|
return
|
|
}
|
|
|
|
func (this *Sociaty) GetType() core.M_Modules {
|
|
return comm.ModuleSociaty
|
|
}
|
|
|
|
func (this *Sociaty) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
|
this.modelSociaty = this.RegisterComp(new(ModelSociaty)).(*ModelSociaty)
|
|
this.modelSociatyTask = this.RegisterComp(new(ModelSociatyTask)).(*ModelSociatyTask)
|
|
this.modelSociatyLog = this.RegisterComp(new(ModelSociatyLog)).(*ModelSociatyLog)
|
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
|
}
|
|
|
|
func (this *Sociaty) Start() (err error) {
|
|
err = this.ModuleBase.Start()
|
|
return
|
|
}
|
|
|
|
// 会长弹劾处理
|
|
func (this *Sociaty) ProcessAccuse(uid, sociatyId string) {
|
|
ggd := this.configure.GetGlobalConf()
|
|
t := ggd.GuildImpeachmentCountDown
|
|
if t == 0 {
|
|
return
|
|
}
|
|
sociaty := this.modelSociaty.getSociaty(sociatyId)
|
|
if sociaty != nil {
|
|
if sociaty.AccuseTime > 0 {
|
|
now := time.Now().Unix()
|
|
if now-sociaty.AccuseTime >= int64(3600*t) {
|
|
//TODO 选新会长
|
|
|
|
} else {
|
|
//结束弹劾
|
|
update := map[string]interface{}{
|
|
"accuseTime": 0,
|
|
}
|
|
if err := this.modelSociaty.updateSociaty(sociatyId, update); err != nil {
|
|
this.Errorf("弹劾时间更新失败 %v", err)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 公会成员
|
|
func (this *Sociaty) Members(uid string) (list []*pb.SociatyMemberInfo) {
|
|
sociaty := this.modelSociaty.getUserSociaty(uid)
|
|
return this.modelSociaty.members(sociaty)
|
|
}
|