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

@@ -51,5 +51,8 @@ func master(c *fiber.Ctx) error {
mastermanager.ReloadMaster()
}
c.Set("Content-Length", fmt.Sprintf("%d", len(data)))
c.Set("Content-Type", "application/octet-stream")
c.Set("X-Encoding", "bzip2")
return c.Send(data)
}

File diff suppressed because it is too large Load Diff

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)
}

View File

@@ -0,0 +1,90 @@
package tcpServer
import (
"bdgrp_go/routes"
"crypto/tls"
"fmt"
"io"
"net/http"
"strings"
"github.com/gofiber/fiber/v2"
)
var skipReqHeaders = map[string]bool{
"transfer-encoding": true,
"connection": true,
"keep-alive": true,
"content-encoding": true,
"content-length": true,
"cf-connecting-ip": true,
"cf-ray": true,
"cf-visitor": true,
"cf-ipcountry": true,
"cf-pseudo-ipv4": true,
"x-forwarded-for": true,
"x-forwarded-proto": true,
"x-real-ip": true,
"cdn-loop": true,
}
var skipRespHeaders = map[string]bool{
"transfer-encoding": true,
"connection": true,
"keep-alive": true,
"content-encoding": true,
"content-length": true,
}
var client = &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
}
func init() {
path := routes.PathOf()
routes.Register(func(app *fiber.App) {
app.Post(path, handle)
fmt.Println("Loaded:", path)
})
}
func handle(c *fiber.Ctx) error {
userid := c.Params("userid")
url := fmt.Sprintf("https://l3-prod-all-bd.bilibiligame.net/api/tcpServer/%s", userid)
req, err := http.NewRequest("POST", url, strings.NewReader(string(c.Body())))
if err != nil {
return c.Status(500).SendString(err.Error())
}
c.Request().Header.VisitAll(func(k, v []byte) {
key := strings.ToLower(string(k))
if !skipReqHeaders[key] {
req.Header.Set(string(k), string(v))
}
})
req.Header.Set("host", "l3-prod-all-bd.bilibiligame.net")
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
return c.Status(500).SendString(err.Error())
}
defer resp.Body.Close()
for key, values := range resp.Header {
if !skipRespHeaders[strings.ToLower(key)] {
c.Set(key, values[0])
}
}
c.Response().Header.Del("Content-Length")
body, err := io.ReadAll(resp.Body)
if err != nil {
return c.Status(500).SendString(err.Error())
}
return c.Send(body)
}

View File

@@ -123,7 +123,6 @@ func postUser(c *fiber.Ctx) error {
"operatingSystem": newUser["operatingSystem"],
"tutorialStatus": newUser["tutorialStatus"],
"introduction": newUser["introduction"],
"unknownString": newUser["unknownString"],
"tutorialEndedAt": fmt.Sprintf("%v", newUser["tutorialEndedAt"]),
}

View File

@@ -113,7 +113,6 @@ func login(c *fiber.Ctx) error {
"operatingSystem": user["operatingSystem"],
"tutorialStatus": user["tutorialStatus"],
"introduction": user["introduction"],
"unknownString": user["unknownString"],
"tutorialEndedAt": fmt.Sprintf("%v", user["tutorialEndedAt"]),
}

View File

@@ -0,0 +1,59 @@
package area
import (
"bdgrp_go/master"
"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 {
userid := c.Params("userid")
m := master.GetMaster()
areaMap := m["masterAreaMap"].(map[string]any)
entries := areaMap["entries"].(map[string]any)
// .filter(area.areaType === "common").map(...)
resultEntries := map[string]any{}
for areaId, v := range entries {
area := v.(map[string]any)
if area["areaType"] != "common" {
continue
}
resultEntries[areaId] = map[string]any{
"userId": userid,
"areaId": areaId,
}
}
data := map[string]any{
"registerTimeOpenAreaIdList": nil,
"userAreaStatusMap": map[string]any{
"entries": resultEntries,
},
}
encoded, err := pbutil.Encode("RegisterTimeOpenAreaResponse", 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,69 @@
package bandstory
import (
"bdgrp_go/master"
"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)
})
}
var bandStoryKeys = map[string]string{
"1": "masterPoppinPartyStoryMap",
"2": "masterAfterglowStoryMap",
"3": "masterHelloHappyWorldStoryMap",
"4": "masterPastelPalettesStoryMap",
"5": "masterRoseliaStoryMap",
"18": "masterRaiseASuilenStoryMap",
"21": "masterMorfonicaStoryMap",
"45": "masterMyGoStoryMap",
}
func handle(c *fiber.Ctx) error {
userid := c.Params("userid")
bandid := c.Params("bandid")
m := master.GetMaster()
key, _ := bandStoryKeys[bandid]
storyMap := m[key].(map[string]any)
entries := storyMap["entries"].(map[string]any)
var result []any
for _, v := range entries {
story := v.(map[string]any)
result = append(result, map[string]any{
"userId": userid,
"bandStoryId": story["bandStoryId"],
"bandId": story["bandId"],
"status": "already_read",
"seq": story["seq"],
})
}
data := map[string]any{
"entries": result,
}
encoded, err := pbutil.Encode("UserBandStoryList", 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,55 @@
package device
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, updateDevice)
fmt.Println("Loaded:", path)
})
}
func updateDevice(c *fiber.Ctx) error {
decrypted, err := utils.Decrypt(c.Body())
if err != nil {
fmt.Println(err)
}
decoded, err := pbutil.Decode("DeviceInfoUpdateRequest", decrypted)
userid := c.Params("userid")
user := db.FindUser(userid)
user["deviceModel"] = decoded["deviceModel"]
user["operatingSystem"] = decoded["operatingSystem"]
db.Save()
data := map[string]any{
"deviceModel": user["deviceModel"],
"operatingSystem": user["operatingSystem"],
"clientVersion": user["clientVersion"],
}
encoded, err := pbutil.Encode("UserRegistration", 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,40 @@
package param_userid
import (
"bdgrp_go/pbutil"
"bdgrp_go/routes"
"bdgrp_go/utils"
"fmt"
"time"
"github.com/gofiber/fiber/v2"
)
func init() {
path := routes.PathOf()
routes.Register(func(app *fiber.App) {
app.Get(path, liveBoost)
fmt.Println("Loaded:", path)
})
}
func liveBoost(c *fiber.Ctx) error {
data := map[string]any{
"userId": c.Params("userId"),
"count": 67,
"serverDate": time.Now().UnixMilli(),
"liveBoostBonusType": "default",
}
encoded, err := pbutil.Encode("UserLiveBoost", 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,39 @@
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.Get(path, liveFever)
fmt.Println("Loaded:", path)
})
}
func liveFever(c *fiber.Ctx) error {
data := map[string]any {
"userId": c.Params("userId"),
"count": 67,
"inActivity": true,
"limit": 3,
}
encoded, err := pbutil.Encode("UserLiveFeverCount", 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,38 @@
package param_userid
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, mainDeck)
fmt.Println("Loaded:", path)
})
}
func mainDeck(c *fiber.Ctx) error {
decrypted, err := utils.Decrypt(c.Body())
if err != nil {
fmt.Println(err)
}
decoded, err := pbutil.Decode("UserPutRequest", decrypted)
userid := c.Params("userid")
user := db.FindUser(userid)
user["mainDeck"] = decoded["mainDeck"]
db.Save()
return c.Send(nil)
}

View File

@@ -0,0 +1,93 @@
package param_userid
import (
"bdgrp_go/master"
"bdgrp_go/pbutil"
"bdgrp_go/routes"
"bdgrp_go/utils"
"encoding/json"
"fmt"
"maps"
"os"
"path/filepath"
"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 {
userid := c.Params("userid")
m := master.GetMaster()
// 讀 pastEvents/{SERVER}.json
pastPath := filepath.Join("pastEvents", os.Getenv("SERVER")+".json")
pastData, err := os.ReadFile(pastPath)
if err != nil {
return c.Status(500).SendString("no past events")
}
var past map[string]any
json.Unmarshal(pastData, &past)
// masterEventStoryMemorialConfigMap.entries
configMap := m["masterEventStoryMemorialConfigMap"].(map[string]any)
entries := configMap["entries"].(map[string]any)
// pastEventStoryMap.entries
pastStoryMap := past["pastEventStoryMap"].(map[string]any)
pastEntries := pastStoryMap["entries"].(map[string]any)
// Object.fromEntries(Object.entries(...).map(...))
resultEntries := map[string]any{}
for eventId := range entries {
// Array.from({ length: ... }, (_, i) => ...)
var storyList []any
if pastEvent, ok := pastEntries[eventId].(map[string]any); ok {
if innerEntries, ok := pastEvent["entries"].([]any); ok {
for i := range innerEntries {
storyList = append(storyList, map[string]any{
"userId": userid,
"eventId": eventId,
"seq": i,
"status": "already_read",
})
}
}
}
resultEntries[eventId] = map[string]any{
"eventId": eventId,
"userEventStoryList": map[string]any{
"entries": storyList,
},
"isExistUnReadStory": false,
"isLocked": false,
}
}
// 合併 past(等同 ...past)
data := map[string]any{
"userEventStoryMemorialMap": map[string]any{
"entries": resultEntries,
},
}
maps.Copy(data, past)
encoded, err := pbutil.Encode("UserEventStoryMemorialResponse", 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.Get(path, recruitment)
fmt.Println("Loaded:", path)
})
}
func recruitment(c *fiber.Ctx) error {
return c.SendStatus(200)
}

View File

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

View File

@@ -0,0 +1,82 @@
package param_musicid
import (
"bdgrp_go/db"
"bdgrp_go/pbutil"
"bdgrp_go/routes"
"bdgrp_go/utils"
"crypto/sha1"
"fmt"
"github.com/gofiber/fiber/v2"
)
func init() {
path := routes.PathOf()
routes.Register(func(app *fiber.App) {
app.Put(path, musicContinue)
fmt.Println("Loaded:", path)
})
}
func musicContinue(c *fiber.Ctx) error {
userid := c.Params("userid")
decrypted, err := utils.Decrypt(c.Body())
if err != nil {
fmt.Println(err)
}
decoded, err := pbutil.Decode("UserMusicContinueRequest", decrypted)
if err != nil {
fmt.Println(err)
}
user := db.FindUser(userid)
str := userid + decoded["continueCount"].(string) + decoded["continueTime"].(string)
data := map[string]any{
"userGamedata": map[string]any{
"userId": userid,
"rank": user["rank"],
"exp": user["exp"],
"coin": user["coin"],
"mainDeck": user["mainDeck"],
"paidStar": user["paidStar"],
"freeStar": user["freeStar"],
"seal": user["seal"],
"degree": user["degree"],
"publishTotalDeckPowerFlg": user["publishTotalDeckPowerFlg"],
"publishBandRankFlg": user["publishBandRankFlg"],
"publishMusicClearedFlg": user["publishMusicClearedFlg"],
"publishMusicFullComboFlg": user["publishMusicFullComboFlg"],
"publishHighScoreRatingFlg": user["publishHighScoreRatingFlg"],
"pooledExp": user["pooledExp"],
"totalExp": user["totalExp"],
"nextExp": user["nextExp"],
"publishUpdatedAtFlg": user["publishUpdatedAtFlg"],
"userPaidStarRecallResponse": nil,
"startDashLoginBonusReceiveFlg": user["startDashLoginBonusReceiveFlg"],
"publishMusicAllPerfectFlg": user["publishMusicAllPerfectFlg"],
"publishDeckRankFlg": user["publishDeckRankFlg"],
"publishStageAchievementConditionsFlg": user["publishStageAchievementConditionsFlg"],
"publishStageFriendRankingFlg": user["publishStageFriendRankingFlg"],
"publishCharacterRankFlg": user["publishCharacterRankFlg"],
"loginDays": user["loginDays"],
},
"continueHash": fmt.Sprintf("%x", sha1.Sum([]byte(str))),
}
encoded, err := pbutil.Encode("UserMusicContinueResponse", 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,20 @@
package param_musicid
import (
"bdgrp_go/routes"
"fmt"
"github.com/gofiber/fiber/v2"
)
func init() {
path := routes.PathOf()
routes.Register(func(app *fiber.App) {
app.Post(path, retry)
fmt.Println("Loaded:", path)
})
}
func retry(c *fiber.Ctx) error {
return c.SendStatus(200)
}

View File

@@ -0,0 +1,40 @@
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.Get(path, present)
fmt.Println("Loaded:", path)
})
}
func present(c *fiber.Ctx) error {
data := map[string]any{
"pagination": map[string]any{
"start": 9223372036854775807,
"limit": c.Query("limit"),
"record": 0,
},
}
encoded, err := pbutil.Encode("UserPresentLimit", 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,40 @@
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.Get(path, presentHistory)
fmt.Println("Loaded:", path)
})
}
func presentHistory(c *fiber.Ctx) error {
data := map[string]any{
"pagination": map[string]any{
"start": 9223372036854775807,
"limit": c.Query("limit"),
"record": 0,
},
}
encoded, err := pbutil.Encode("UserPresentHistoryList", data)
if err != nil {
fmt.Println(err)
}
encrypted, err := utils.Encrypt(encoded)
if err != nil {
fmt.Println(err)
}
return c.Send(encrypted)
}