add more routes

This commit is contained in:
2026-09-06 21:57:03 +08:00
parent 4688c10585
commit 5743a36f51
35 changed files with 202373 additions and 2 deletions

View File

@@ -0,0 +1,120 @@
package param_userid
import (
"bdgrp_go/db"
"bdgrp_go/master"
"bdgrp_go/pbutil"
"bdgrp_go/routes"
"bdgrp_go/utils"
"fmt"
"math/rand"
"time"
"github.com/gofiber/fiber/v2"
)
func init() {
path := routes.PathOf()
routes.Register(func(app *fiber.App) {
app.Get(path, get)
app.Put(path, put)
fmt.Println("Loaded:", path)
})
}
func get(c *fiber.Ctx) error {
userid := c.Params("userid")
user := db.FindUser(userid)
m := master.GetMaster()
areaMap := m["masterAreaMap"].(map[string]any)["entries"].(map[string]any)
actionSetMap := m["masterActionSetMap"].(map[string]any)["entries"].(map[string]any)
seasonMap := m["masterSeasonBasicMap"].(map[string]any)["entries"].(map[string]any)
// userAreaMap
resultEntries := map[string]any{}
for areaId, v := range areaMap {
area := v.(map[string]any)
if area["areaType"] != "common" {
continue
}
// filter actionSets by areaId
var available []any
for _, a := range actionSetMap {
action := a.(map[string]any)
if fmt.Sprintf("%v", action["areaId"]) == areaId {
available = append(available, action["actionSetId"])
}
}
// shuffle + slice
rand.Shuffle(len(available), func(i, j int) {
available[i], available[j] = available[j], available[i]
})
count := min(rand.Intn(3)+1, len(available))
actionSets := make([]any, 0)
for _, id := range available[:count] {
actionSets = append(actionSets, map[string]any{
"actionSetId": id,
"status": "already_read",
})
}
// areaItems
areaItems := []any{}
if user["areaItems"] != nil {
items := user["areaItems"].(map[string]any)
if v, ok := items[areaId]; ok {
areaItems = v.([]any)
}
}
resultEntries[areaId] = map[string]any{
"areaId": areaId,
"actionSets": actionSets,
"areaItemIds": areaItems,
}
}
// current season
now := time.Now().UnixMilli()
var seasonId any
for _, v := range seasonMap {
s := v.(map[string]any)
startAt := int64(s["startAt"].(float64))
endAt := int64(s["endAt"].(float64))
if startAt <= now && now < endAt {
seasonId = s["seasonId"]
break
}
}
data := map[string]any{
"userAreaMap": map[string]any{
"entries": resultEntries,
},
"backstage": nil,
"userSeason": map[string]any{
"seasonId": seasonId,
},
"userLotterySelectedBackstageTalkSetMap": nil,
}
encoded, err := pbutil.Encode("UserAreaCharacterResponse", data)
if err != nil {
return c.Status(500).SendString(err.Error())
}
encrypted, err := utils.Encrypt(encoded)
if err != nil {
return c.Status(500).SendString(err.Error())
}
return c.Send(encrypted)
}
func put(c *fiber.Ctx) error {
return c.SendStatus(200)
}

View File

@@ -0,0 +1,66 @@
package param_userid
import (
"bdgrp_go/pbutil"
"bdgrp_go/routes"
"bdgrp_go/utils"
"fmt"
"github.com/gofiber/fiber/v2"
)
func init() {
path := routes.PathOf()
routes.Register(func(app *fiber.App) {
app.Put(path, handle)
fmt.Println("Loaded:", path)
})
}
func handle(c *fiber.Ctx) error {
userid := c.Params("userid")
data := map[string]any{
"updateResources": map[string]any{
"updatedBandDeckRankList": map[string]any{},
"userDailyLive": map[string]any{
"lastClearedAt": 1770992661000,
"liveStartedAt": 1770992661000,
"getDailyLiveRewardId": 6,
},
"userDailyLiveTotalRewardHistory": map[string]any{
"userId": userid,
"dailyLiveId": 8,
"status": "STARTED",
"dailyLiveCount": 1,
},
},
"response": map[string]any{
"userDailyLive": map[string]any{
"lastClearedAt": 1770992661000,
"liveStartedAt": 1770992661000,
"getDailyLiveRewardId": 6,
"dailyPresents": []any{
map[string]any{
"resourceId": 43,
"resourceType": "practice_ticket",
"quantity": 1,
"lbBonus": 1,
},
},
},
},
}
encoded, err := pbutil.Encode("SuiteUserDailyLiveClearResponse", data)
if err != nil {
return c.Status(500).SendString(err.Error())
}
encrypted, err := utils.Encrypt(encoded)
if err != nil {
return c.Status(500).SendString(err.Error())
}
return c.Send(encrypted)
}

View File

@@ -0,0 +1,99 @@
package deck
import (
"bdgrp_go/db"
"bdgrp_go/pbutil"
"bdgrp_go/routes"
"bdgrp_go/utils"
"fmt"
"github.com/gofiber/fiber/v2"
)
func init() {
path := routes.PathOf()
routes.Register(func(app *fiber.App) {
app.Put(path, deck)
fmt.Println("Loaded:", path)
})
}
func deck(c *fiber.Ctx) error {
decrypted, err := utils.Decrypt(c.Body())
if err != nil {
fmt.Println(err)
}
decoded, err := pbutil.Decode("EditUserDeckRequest", decrypted)
if err != nil {
fmt.Println(err)
}
userid := c.Params("userid")
user := db.FindUser(userid)
decks := user["decks"].([]any)
isNew := false
var deck map[string]any
for _, d := range decks {
d := d.(map[string]any)
if fmt.Sprintf("%v", d["deckId"]) == c.Params("deckid") {
deck = d
break
}
}
if deck == nil {
deck = map[string]any{
"deckId": c.Params("deckid"),
}
isNew = true
}
if v, ok := decoded["member1"].(string); ok && v != "" {
deck["member1"] = v
}
if v, ok := decoded["member2"].(string); ok && v != "" {
deck["member2"] = v
}
if v, ok := decoded["member3"].(string); ok && v != "" {
deck["member3"] = v
}
if v, ok := decoded["member4"].(string); ok && v != "" {
deck["member4"] = v
}
if v, ok := decoded["leader"].(string); ok && v != "" {
deck["leader"] = v
}
deck["deckName"] = decoded["deckName"].(string)
deck["deckType"] = decoded["deckType"].(string)
if isNew {
user["decks"] = append(user["decks"].([]any), deck)
}
db.Save()
data := map[string]any{
"updateResources": map[string]any{
"userDeckList": map[string]any{
"entries": user["decks"].([]any),
},
},
}
encoded, err := pbutil.Encode("EditUserDeckResponse", data)
if err != nil {
fmt.Println(err)
}
encrypted, err := utils.Encrypt(encoded)
if err != nil {
fmt.Println(err)
}
return c.Send(encrypted)
}

View File

@@ -0,0 +1,48 @@
package friend
import (
"bdgrp_go/pbutil"
"bdgrp_go/routes"
"bdgrp_go/utils"
"fmt"
"github.com/gofiber/fiber/v2"
)
func init() {
path := routes.PathOf()
routes.Register(func(app *fiber.App) {
app.Get(path, handle)
fmt.Println("Loaded:", path)
})
}
func handle(c *fiber.Ctx) error {
friendDetail := map[string]any{
"applicationMap": map[string]any{},
"approvalMap": map[string]any{},
"friendMap": map[string]any{},
"friendLimit": 60,
"approvalLimit": 50,
"applicationLimit": 50,
}
data := map[string]any{
"updateResources": map[string]any{
"userFriendRelationDetail": friendDetail,
},
"userFriendDetail": friendDetail,
}
encoded, err := pbutil.Encode("SuiteUserFriendTopResponse", data)
if err != nil {
return c.Status(500).SendString(err.Error())
}
encrypted, err := utils.Encrypt(encoded)
if err != nil {
return c.Status(500).SendString(err.Error())
}
return c.Send(encrypted)
}

View File

@@ -0,0 +1,16 @@
package friend
import (
"bdgrp_go/routes"
"fmt"
"github.com/gofiber/fiber/v2"
)
func init() {
path := routes.PathOf()
routes.Register(func(app *fiber.App) {
app.Get(path, handle)
fmt.Println("Loaded:", path)
})
}

View File

@@ -0,0 +1,16 @@
package friend
import (
"bdgrp_go/routes"
"fmt"
"github.com/gofiber/fiber/v2"
)
func init() {
path := routes.PathOf()
routes.Register(func(app *fiber.App) {
app.Get(path, handle)
fmt.Println("Loaded:", path)
})
}

View File

@@ -0,0 +1,45 @@
package friend
import (
"bdgrp_go/pbutil"
"bdgrp_go/routes"
"bdgrp_go/utils"
"fmt"
"github.com/gofiber/fiber/v2"
)
func init() {
path := routes.PathOf()
routes.Register(func(app *fiber.App) {
app.Get(path, relation)
fmt.Println("Loaded:", path)
})
}
func relation(c *fiber.Ctx) error {
data := map[string]any{
"updateResources": map[string]any{
"userFriendRelationDetail": map[string]any{
"applicationMap": nil,
"approvalMap": nil,
"friendMap": nil,
"friendLimit": 50,
"approvalLimit": 50,
"applicationLimit": 50,
},
},
}
encoded, err := pbutil.Encode("SuiteUserFriendRelationResponse", data)
if err != nil {
return c.Status(500).SendString(err.Error())
}
encrypted, err := utils.Encrypt(encoded)
if err != nil {
return c.Status(500).SendString(err.Error())
}
return c.Send(encrypted)
}

View File

@@ -0,0 +1,20 @@
package param_userid
import (
"bdgrp_go/routes"
"fmt"
"github.com/gofiber/fiber/v2"
)
func init() {
path := routes.PathOf()
routes.Register(func(app *fiber.App) {
app.Put(path, index)
fmt.Println("Loaded:", path)
})
}
func index(c *fiber.Ctx) error {
return c.SendStatus(200)
}

View File

@@ -0,0 +1,30 @@
package loginbonus
import (
"bdgrp_go/pbutil"
"bdgrp_go/routes"
"bdgrp_go/utils"
"fmt"
"github.com/gofiber/fiber/v2"
)
func init() {
path := routes.PathOf()
routes.Register(func(app *fiber.App) {
app.Put(path, acceptAll)
fmt.Println("Loaded:", path)
})
}
func acceptAll(c *fiber.Ctx) error {
data := map[string]any{
"updateResources": map[string]any{},
}
encoded, _ := pbutil.Encode("SuiteUserLoginBonusAcceptAllResponse", data)
encrypted, _ := utils.Encrypt(encoded)
return c.Send(encrypted)
}

View File

@@ -0,0 +1 @@
package music

View File

@@ -0,0 +1,79 @@
package profile
import (
"bdgrp_go/db"
"bdgrp_go/pbutil"
"bdgrp_go/routes"
"bdgrp_go/utils"
"fmt"
"github.com/gofiber/fiber/v2"
)
func init() {
path := routes.PathOf()
routes.Register(func(app *fiber.App) {
app.Put(path, handle)
fmt.Println("Loaded:", path)
})
}
func handle(c *fiber.Ctx) error {
userid := c.Params("userid")
decrypted, err := utils.Decrypt(c.Body())
if err != nil {
return c.Status(500).SendString(err.Error())
}
decoded, err := pbutil.Decode("UserDecoDegreeRequest", decrypted)
if err != nil {
return c.Status(500).SendString(err.Error())
}
user := db.FindUser(userid)
degree := user["degree"].([]any)
entries := map[string]any{}
degree[0] = decoded["degreeIdFirst"]
entries["first"] = map[string]any{
"userId": userid,
"profileDegreeType": "first",
"degreeId": degree[0],
}
if v, ok := decoded["degreeIdSecond"]; ok && v != nil && v != "" {
degree[1] = v
entries["second"] = map[string]any{
"userId": userid,
"profileDegreeType": "second",
"degreeId": degree[1],
}
} else {
degree[1] = nil
}
user["degree"] = degree
db.Save()
data := map[string]any{
"updateResources": map[string]any{
"userProfileDegreeMap": map[string]any{
"entries": entries,
},
},
}
encoded, err := pbutil.Encode("SuiteUserDecoDegreeResponse", data)
if err != nil {
return c.Status(500).SendString(err.Error())
}
encrypted, err := utils.Encrypt(encoded)
if err != nil {
return c.Status(500).SendString(err.Error())
}
return c.Send(encrypted)
}