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:
2026-06-04 03:05:32 +08:00
parent 60677fe0dd
commit e61c07a9a3
53 changed files with 220 additions and 135 deletions
+2 -2
View File
@@ -14,8 +14,8 @@ func liveSchedule(ctx *gin.Context) (res any, err error) {
var liveID []int
err = ss.MainEng.Table("special_live_m").
Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveID)
if ss.CheckErr(err) {
return
if err != nil {
return nil, err
}
liveList := []liveapischema.LiveList{}
+4 -4
View File
@@ -14,8 +14,8 @@ func liveStatus(ctx *gin.Context) (res any, err error) {
var liveDifficultyID []int
normalLives := []liveapischema.NormalLiveStatusList{}
err = ss.MainEng.Table("normal_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyID)
if ss.CheckErr(err) {
return
if err != nil {
return nil, err
}
for _, id := range liveDifficultyID {
normalLive := liveapischema.NormalLiveStatusList{
@@ -31,8 +31,8 @@ func liveStatus(ctx *gin.Context) (res any, err error) {
specialLives := []liveapischema.SpecialLiveStatusList{}
err = ss.MainEng.Table("special_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyID)
if ss.CheckErr(err) {
return
if err != nil {
return nil, err
}
for _, id := range liveDifficultyID {
specialLive := liveapischema.SpecialLiveStatusList{