refactor(channelserver): extract RengokuRepository and MailRepository

Move all direct DB access from handlers_rengoku.go (11 calls) and
handlers_mail.go (10 calls) into dedicated repository types, continuing
the established extraction pattern.

RengokuRepository provides UpsertScore and GetRanking, replacing a
3-call check/insert/update sequence and an 8-case switch of nearly
identical queries respectively.

MailRepository provides SendMail, SendMailTx, GetListForCharacter,
GetByID, MarkRead, MarkDeleted, SetLocked, and MarkItemReceived.
The old Mail.Send(), Mail.MarkRead(), GetMailListForCharacter, and
GetMailByID free functions are removed. Guild handlers that sent mail
via Mail.Send(s, ...) now call mailRepo directly.
This commit is contained in:
Houmgaor
2026-02-20 23:31:27 +01:00
parent b17b2f3b38
commit de3bf9173a
9 changed files with 256 additions and 239 deletions

View File

@@ -52,6 +52,8 @@ type Server struct {
houseRepo *HouseRepository
festaRepo *FestaRepository
towerRepo *TowerRepository
rengokuRepo *RengokuRepository
mailRepo *MailRepository
erupeConfig *_config.Config
acceptConns chan net.Conn
deleteConns chan net.Conn
@@ -129,6 +131,8 @@ func NewServer(config *Config) *Server {
s.houseRepo = NewHouseRepository(config.DB)
s.festaRepo = NewFestaRepository(config.DB)
s.towerRepo = NewTowerRepository(config.DB)
s.rengokuRepo = NewRengokuRepository(config.DB)
s.mailRepo = NewMailRepository(config.DB)
// Mezeporta
s.stages["sl1Ns200p0a0u0"] = NewStage("sl1Ns200p0a0u0")