package contracts import ( "github.com/samber/do" "github.com/samber/lo" ) type ResEvent string type ResListener interface { Insert(new map[string]any, u User, id int64) error Update(new map[string]any, u User, old map[string]any) error Delete(old map[string]any, u User) error GetResource() Resource GetCode() string } type BaseListener struct { Container *do.Injector res Resource // 监听资源 code string // code events []string // 监听动作 } func (this BaseListener) GetCode() string { return this.code } func (this BaseListener) GetResource() Resource { return this.res } func (this BaseListener) HasEvent(event string) bool { return lo.Contains(this.events, event) } func (BaseListener) Insert(new map[string]any, u User, id int64) error { return nil } func (BaseListener) Update(new map[string]any, u User, old map[string]any) error { return nil } func (BaseListener) Delete(old map[string]any, u User) error { return nil } func NewBaseListener(code string, res Resource, container *do.Injector) *BaseListener { return &BaseListener{code: code, res: res, Container: container} }