refactor(tower): extract tower logic into TowerService

The tower repo had business logic beyond simple CRUD: AddGem used a
fetch-transform-save pattern, progress capping was inline in the
handler, and RP donation orchestrated multiple repo calls with
conditional page advancement. Move these into a new TowerService
following the established service layer pattern.
This commit is contained in:
Houmgaor
2026-02-24 16:07:37 +01:00
parent 76d139538b
commit 7a56810e78
8 changed files with 322 additions and 56 deletions

View File

@@ -3,8 +3,6 @@ package channelserver
import (
"fmt"
"erupe-ce/common/stringsupport"
"github.com/jmoiron/sqlx"
)
@@ -78,16 +76,6 @@ func (r *TowerRepository) UpdateGems(charID uint32, gems string) error {
return err
}
// AddGem adds quantity to a specific gem index.
func (r *TowerRepository) AddGem(charID uint32, gemIndex int, quantity int) error {
gems, err := r.GetGems(charID)
if err != nil {
return err
}
newGems := stringsupport.CSVSetIndex(gems, gemIndex, stringsupport.CSVGetIndex(gems, gemIndex)+quantity)
return r.UpdateGems(charID, newGems)
}
// TenrouiraiProgressData holds the guild's tenrouirai (sky corridor) progress.
type TenrouiraiProgressData struct {
Page uint8