mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-26 01:23:13 +01:00
refactor(guild): introduce service layer for guild member operations
Extract business logic from handleMsgMhfOperateGuildMember into GuildService.OperateMember, establishing the handler→service→repo layering pattern. The handler is now ~20 lines of protocol glue (type-assert, map action, call service, send ACK, notify). GuildService owns authorization checks, repo coordination, mail composition, and best-effort mail delivery. It accepts plain Go types (no mhfpacket or Session imports), making it fully testable with mock repos. Cross-channel notification stays in the handler since it requires Session. Adds 7 table-driven service-level tests covering accept/reject/kick, authorization, repo errors, mail errors, and unknown actions.
This commit is contained in:
@@ -71,6 +71,7 @@ type Server struct {
|
||||
miscRepo MiscRepo
|
||||
scenarioRepo ScenarioRepo
|
||||
mercenaryRepo MercenaryRepo
|
||||
guildService *GuildService
|
||||
erupeConfig *cfg.Config
|
||||
acceptConns chan net.Conn
|
||||
deleteConns chan net.Conn
|
||||
@@ -153,6 +154,8 @@ func NewServer(config *Config) *Server {
|
||||
s.scenarioRepo = NewScenarioRepository(config.DB)
|
||||
s.mercenaryRepo = NewMercenaryRepository(config.DB)
|
||||
|
||||
s.guildService = NewGuildService(s.guildRepo, s.mailRepo, s.charRepo, s.logger)
|
||||
|
||||
// Mezeporta
|
||||
s.stages.Store("sl1Ns200p0a0u0", NewStage("sl1Ns200p0a0u0"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user