refactor(channelserver): extract Event, Achievement, Shop, and Cafe repositories

Move 22 raw SQL queries from 4 handler files into dedicated repository
structs, continuing the repository extraction pattern. Achievement
insert uses ON CONFLICT DO NOTHING to eliminate check-then-insert race,
and IncrementScore validates the column index to prevent SQL injection.
This commit is contained in:
Houmgaor
2026-02-21 13:13:55 +01:00
parent 87040c55bb
commit ad73f2fb55
9 changed files with 230 additions and 69 deletions

View File

@@ -58,6 +58,10 @@ type Server struct {
stampRepo *StampRepository
distRepo *DistributionRepository
sessionRepo *SessionRepository
eventRepo *EventRepository
achievementRepo *AchievementRepository
shopRepo *ShopRepository
cafeRepo *CafeRepository
erupeConfig *_config.Config
acceptConns chan net.Conn
deleteConns chan net.Conn
@@ -140,6 +144,10 @@ func NewServer(config *Config) *Server {
s.stampRepo = NewStampRepository(config.DB)
s.distRepo = NewDistributionRepository(config.DB)
s.sessionRepo = NewSessionRepository(config.DB)
s.eventRepo = NewEventRepository(config.DB)
s.achievementRepo = NewAchievementRepository(config.DB)
s.shopRepo = NewShopRepository(config.DB)
s.cafeRepo = NewCafeRepository(config.DB)
// Mezeporta
s.stages["sl1Ns200p0a0u0"] = NewStage("sl1Ns200p0a0u0")