Reduce handler request boilerplate
- Add session.Attach to reuse per-request sessions across middleware and ghome handlers - Make Session finalize/abort paths idempotent to avoid duplicate commit or rollback work - Move request_data parsing helper to internal/utils - Expand ParseRequestData usage across api, download, unit, live, multiunit, and subscenario handlers - Extract download package metadata into internal/handler/download/types.go - Return explicit errors from selected session lookup helpers and update callers - Make api action handlers return errors directly instead of calling ss.CheckErr in nested layers Signed-off-by: Sean Du <do4suki@gmail.com>
This commit is contained in:
@@ -13,16 +13,16 @@ func unitDeckInfo(ctx *gin.Context) (res any, err error) {
|
||||
|
||||
userDeck := []unitapischema.UserDeckData{}
|
||||
err = ss.UserEng.Table("user_deck").Where("user_id = ?", ss.UserID).Asc("deck_id").Find(&userDeck)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
unitDeckInfo := []unitapischema.DeckInfoData{}
|
||||
for _, deck := range userDeck {
|
||||
deckUnit := []unitapischema.UnitDeckData{}
|
||||
err = ss.UserEng.Table("user_deck_unit").Where("user_deck_id = ?", deck.ID).Asc("position").Find(&deckUnit)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
oUID := []unitapischema.UnitOwningUserIds{}
|
||||
|
||||
Reference in New Issue
Block a user