Overhaul [1/n]

Signed-off-by: Sean Du <do4suki@gmail.com>
This commit is contained in:
2026-01-29 02:42:28 +08:00
parent 989acd6ff1
commit c77241a883
2267 changed files with 7158 additions and 5583 deletions
+19
View File
@@ -0,0 +1,19 @@
package live
import (
"fmt"
"github.com/gin-gonic/gin"
)
func LiveApi(ctx *gin.Context, action string) (res any, err error) {
switch action {
case "liveStatus":
res, err = liveStatus(ctx)
case "schedule":
res, err = liveSchedule(ctx)
default:
err = fmt.Errorf("unimplemented action: live: %s", action)
}
return res, err
}
+57
View File
@@ -0,0 +1,57 @@
package live
import (
"honoka-chan/internal/schema/api/live"
"honoka-chan/internal/session"
"time"
"github.com/gin-gonic/gin"
)
func liveSchedule(ctx *gin.Context) (res any, err error) {
ss := session.Get(ctx)
var liveDifficultyID []int
specialLives := []live.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 := live.SpecialLiveStatusList{
LiveDifficultyID: id,
Status: 1,
HiScore: 0,
HiComboCount: 0,
ClearCnt: 0,
AchievedGoalIDList: []int{},
}
specialLives = append(specialLives, specialLive)
}
livesList := []live.LiveList{}
for _, v := range specialLives {
livesList = append(livesList, live.LiveList{
LiveDifficultyID: v.LiveDifficultyID,
StartDate: "2023-01-01 00:00:00",
EndDate: "2037-01-01 00:00:00",
IsRandom: false,
})
}
res = live.ScheduleResp{
Result: live.ScheduleData{
EventList: []any{},
LiveList: livesList,
LimitedBonusList: []any{},
LimitedBonusCommonList: []live.LimitedBonusCommonList{}, // 特效道具
RandomLiveList: []live.RandomLiveList{}, // 随机歌曲
FreeLiveList: []any{},
TrainingLiveList: []live.TrainingLiveList{}, // 挑战歌曲
},
Status: 200,
CommandNum: false,
TimeStamp: time.Now().Unix(),
}
return res, err
}
+64
View File
@@ -0,0 +1,64 @@
package live
import (
"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 := []live.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 := live.NormalLiveStatusList{
LiveDifficultyID: id,
Status: 1,
HiScore: 0,
HiComboCount: 0,
ClearCnt: 0,
AchievedGoalIDList: []int{},
}
normalLives = append(normalLives, normalLive)
}
specialLives := []live.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 := live.SpecialLiveStatusList{
LiveDifficultyID: id,
Status: 1,
HiScore: 0,
HiComboCount: 0,
ClearCnt: 0,
AchievedGoalIDList: []int{},
}
specialLives = append(specialLives, specialLive)
}
res = live.StatusResp{
Result: live.StatusData{
NormalLiveStatusList: normalLives,
SpecialLiveStatusList: specialLives,
TrainingLiveStatusList: []live.TrainingLiveStatusList{},
MarathonLiveStatusList: []any{},
FreeLiveStatusList: []any{},
CanResumeLive: false,
},
Status: 200,
CommandNum: false,
TimeStamp: time.Now().Unix(),
}
return res, err
}