Files
honoka-chan/internal/handler/api/live/status.go
T
YumeMichi 150ce674ad Implement more endpoints & overhaul [2/n]
Drop LevelDB and move all the things to SQLite.

Implemented endpoints:
/api <unit, accessoryMaterialAll>
/api <unit, accessoryTab>
/live/continue
/live/partyList
/unit/favoriteAccessory (WIP)
/unit/sale

Signed-off-by: Sean Du <do4suki@gmail.com>
2026-04-28 11:44:56 +08:00

65 lines
1.7 KiB
Go

package live
import (
liveapischema "honoka-chan/internal/schema/api/live"
"honoka-chan/internal/session"
"time"
"github.com/gin-gonic/gin"
)
func liveStatus(ctx *gin.Context) (res any, err error) {
ss := session.Get(ctx)
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
}
for _, id := range liveDifficultyID {
normalLive := liveapischema.NormalLiveStatusList{
LiveDifficultyID: id,
Status: 1,
HiScore: 0,
HiComboCount: 0,
ClearCnt: 0,
AchievedGoalIDList: []int{},
}
normalLives = append(normalLives, normalLive)
}
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
}
for _, id := range liveDifficultyID {
specialLive := liveapischema.SpecialLiveStatusList{
LiveDifficultyID: id,
Status: 1,
HiScore: 0,
HiComboCount: 0,
ClearCnt: 0,
AchievedGoalIDList: []int{},
}
specialLives = append(specialLives, specialLive)
}
res = liveapischema.StatusResp{
Result: liveapischema.StatusData{
NormalLiveStatusList: normalLives,
SpecialLiveStatusList: specialLives,
TrainingLiveStatusList: []liveapischema.TrainingLiveStatusList{},
MarathonLiveStatusList: []any{},
FreeLiveStatusList: []any{},
CanResumeLive: false,
},
Status: 200,
CommandNum: false,
TimeStamp: time.Now().Unix(),
}
return res, err
}