mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user