Compare commits
4 Commits
5743a36f51
...
e79282d8cc
| Author | SHA1 | Date | |
|---|---|---|---|
| e79282d8cc | |||
| a28c1dec9b | |||
| 86cde9bb97 | |||
| c4ccba256d |
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
resp/
|
||||||
|
.env
|
||||||
|
db.json
|
||||||
|
.idea
|
||||||
4681
mission.json
4681
mission.json
File diff suppressed because it is too large
Load Diff
48485
pastEvents/CN.json
48485
pastEvents/CN.json
File diff suppressed because it is too large
Load Diff
47043
pastEvents/GL.json
47043
pastEvents/GL.json
File diff suppressed because it is too large
Load Diff
50993
pastEvents/JP.json
50993
pastEvents/JP.json
File diff suppressed because it is too large
Load Diff
48623
pastEvents/TW.json
48623
pastEvents/TW.json
File diff suppressed because it is too large
Load Diff
@@ -51,8 +51,5 @@ func master(c *fiber.Ctx) error {
|
|||||||
mastermanager.ReloadMaster()
|
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)
|
return c.Send(data)
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,120 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
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)
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
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)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
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)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
package music
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -123,6 +123,7 @@ func postUser(c *fiber.Ctx) error {
|
|||||||
"operatingSystem": newUser["operatingSystem"],
|
"operatingSystem": newUser["operatingSystem"],
|
||||||
"tutorialStatus": newUser["tutorialStatus"],
|
"tutorialStatus": newUser["tutorialStatus"],
|
||||||
"introduction": newUser["introduction"],
|
"introduction": newUser["introduction"],
|
||||||
|
"unknownString": newUser["unknownString"],
|
||||||
"tutorialEndedAt": fmt.Sprintf("%v", newUser["tutorialEndedAt"]),
|
"tutorialEndedAt": fmt.Sprintf("%v", newUser["tutorialEndedAt"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ func login(c *fiber.Ctx) error {
|
|||||||
"operatingSystem": user["operatingSystem"],
|
"operatingSystem": user["operatingSystem"],
|
||||||
"tutorialStatus": user["tutorialStatus"],
|
"tutorialStatus": user["tutorialStatus"],
|
||||||
"introduction": user["introduction"],
|
"introduction": user["introduction"],
|
||||||
|
"unknownString": user["unknownString"],
|
||||||
"tutorialEndedAt": fmt.Sprintf("%v", user["tutorialEndedAt"]),
|
"tutorialEndedAt": fmt.Sprintf("%v", user["tutorialEndedAt"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
17
routes_gen.go
Normal file
17
routes_gen.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
// Code generated by gen/gen.go — DO NOT EDIT
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "bdgrp_go/routes/api/acdm"
|
||||||
|
_ "bdgrp_go/routes/api"
|
||||||
|
_ "bdgrp_go/routes/api/information"
|
||||||
|
_ "bdgrp_go/routes/api/multiroom/create"
|
||||||
|
_ "bdgrp_go/routes/api/suite"
|
||||||
|
_ "bdgrp_go/routes/api/system"
|
||||||
|
_ "bdgrp_go/routes/api/user/heart"
|
||||||
|
_ "bdgrp_go/routes/api/user"
|
||||||
|
_ "bdgrp_go/routes/api/user/param_userid"
|
||||||
|
_ "bdgrp_go/routes/api/validation"
|
||||||
|
_ "bdgrp_go/routes"
|
||||||
|
_ "bdgrp_go/routes/upstream"
|
||||||
|
)
|
||||||
222
utils/helper.go
222
utils/helper.go
@@ -1,222 +0,0 @@
|
|||||||
package utils
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
func ComputeMusicClearInfo(musicScore map[string]any) map[string]any {
|
|
||||||
difficulties := []string{"easy", "normal", "hard", "expert", "special"}
|
|
||||||
type stat struct{ cleared, fullCombo, allPerfect int }
|
|
||||||
stats := map[string]*stat{}
|
|
||||||
for _, d := range difficulties {
|
|
||||||
stats[d] = &stat{}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, v := range musicScore {
|
|
||||||
data := v.(map[string]any)
|
|
||||||
entries, ok := data["entries"].([]any)
|
|
||||||
if !ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
for _, e := range entries {
|
|
||||||
entry := e.(map[string]any)
|
|
||||||
diff, _ := entry["musicDifficulty"].(string)
|
|
||||||
clearStatus, _ := entry["clearStatus"].(string)
|
|
||||||
if s, ok := stats[diff]; ok {
|
|
||||||
s.cleared++
|
|
||||||
if clearStatus == "full_combo" {
|
|
||||||
s.fullCombo++
|
|
||||||
}
|
|
||||||
if clearStatus == "all_perfect" {
|
|
||||||
s.allPerfect++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result := map[string]any{}
|
|
||||||
for _, d := range difficulties {
|
|
||||||
result[d] = map[string]any{
|
|
||||||
"clearedMusicCount": stats[d].cleared,
|
|
||||||
"fullComboMusicCount": stats[d].fullCombo,
|
|
||||||
"allPerfectMusicCount": stats[d].allPerfect,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return map[string]any{"entries": result}
|
|
||||||
}
|
|
||||||
|
|
||||||
func ComputeMusicClearCountInfo(musicScore map[string]any) map[string]any {
|
|
||||||
result := map[string]any{}
|
|
||||||
for id, v := range musicScore {
|
|
||||||
data := v.(map[string]any)
|
|
||||||
entries, ok := data["entries"].([]any)
|
|
||||||
if ok && len(entries) > 0 {
|
|
||||||
result[id] = len(entries)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return map[string]any{"entries": result}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BuildUserSituations(userid string, master map[string]any, user map[string]any) []any {
|
|
||||||
situationMap := master["masterCharacterSituationMap"].(map[string]any)["entries"].(map[string]any)
|
|
||||||
|
|
||||||
var result []any
|
|
||||||
for _, v := range situationMap {
|
|
||||||
card := v.(map[string]any)
|
|
||||||
releasedAt := fmt.Sprintf("%v", card["releasedAt"])
|
|
||||||
if releasedAt == "4128645600000" || releasedAt == "4131237600000" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// maxLevel
|
|
||||||
maxLevel := 0
|
|
||||||
if paramMap, ok := card["parameterMap"].(map[string]any); ok {
|
|
||||||
for k := range paramMap {
|
|
||||||
var level int
|
|
||||||
fmt.Sscanf(k, "%d", &level)
|
|
||||||
if level > maxLevel {
|
|
||||||
maxLevel = level
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rarity := 0
|
|
||||||
if r, ok := card["rarity"].(float64); ok {
|
|
||||||
rarity = int(r)
|
|
||||||
}
|
|
||||||
hasTraining := rarity >= 3
|
|
||||||
|
|
||||||
var ep0, ep1 map[string]any
|
|
||||||
if eps, ok := card["episodes"].(map[string]any); ok {
|
|
||||||
if entries, ok := eps["entries"].([]any); ok {
|
|
||||||
if len(entries) > 0 {
|
|
||||||
ep0, _ = entries[0].(map[string]any)
|
|
||||||
}
|
|
||||||
if len(entries) > 1 {
|
|
||||||
ep1, _ = entries[1].(map[string]any)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
illust := "normal"
|
|
||||||
if hasTraining {
|
|
||||||
illust = "after_training"
|
|
||||||
}
|
|
||||||
if user != nil {
|
|
||||||
if si, ok := user["situationIllust"].(map[string]any); ok {
|
|
||||||
if v, ok := si[fmt.Sprintf("%v", card["situationId"])]; ok {
|
|
||||||
illust = fmt.Sprintf("%v", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
trainingStatus := "not_doing"
|
|
||||||
if hasTraining {
|
|
||||||
trainingStatus = "done"
|
|
||||||
}
|
|
||||||
|
|
||||||
sit := map[string]any{
|
|
||||||
"userId": userid,
|
|
||||||
"situationId": card["situationId"],
|
|
||||||
"level": maxLevel,
|
|
||||||
"exp": 0,
|
|
||||||
"createdAt": card["releasedAt"],
|
|
||||||
"addExp": 0,
|
|
||||||
"trainingStatus": trainingStatus,
|
|
||||||
"duplicateCount": 0,
|
|
||||||
"illust": illust,
|
|
||||||
"skillExp": 0,
|
|
||||||
"skillLevel": 5,
|
|
||||||
"limitBreakRank": 4,
|
|
||||||
}
|
|
||||||
|
|
||||||
if hasTraining {
|
|
||||||
t, _ := card["training"].(map[string]any)
|
|
||||||
perf, tech, vis := 0.0, 0.0, 0.0
|
|
||||||
if t != nil {
|
|
||||||
perf, _ = t["trainingPerformance"].(float64)
|
|
||||||
tech, _ = t["trainingTechnique"].(float64)
|
|
||||||
vis, _ = t["trainingVisual"].(float64)
|
|
||||||
}
|
|
||||||
ep0Perf, ep0Tech, ep0Vis := 0.0, 0.0, 0.0
|
|
||||||
ep1Perf, ep1Tech, ep1Vis := 0.0, 0.0, 0.0
|
|
||||||
if ep0 != nil {
|
|
||||||
ep0Perf, _ = ep0["appendPerformance"].(float64)
|
|
||||||
ep0Tech, _ = ep0["appendTechnique"].(float64)
|
|
||||||
ep0Vis, _ = ep0["appendVisual"].(float64)
|
|
||||||
}
|
|
||||||
if ep1 != nil {
|
|
||||||
ep1Perf, _ = ep1["appendPerformance"].(float64)
|
|
||||||
ep1Tech, _ = ep1["appendTechnique"].(float64)
|
|
||||||
ep1Vis, _ = ep1["appendVisual"].(float64)
|
|
||||||
}
|
|
||||||
|
|
||||||
sit["userAppendParameter"] = map[string]any{
|
|
||||||
"userId": userid,
|
|
||||||
"situationId": card["situationId"],
|
|
||||||
"performance": perf,
|
|
||||||
"technique": tech,
|
|
||||||
"visual": vis,
|
|
||||||
"characterPotentialPerformance": 30,
|
|
||||||
"characterPotentialTechnique": 30,
|
|
||||||
"characterPotentialVisual": 30,
|
|
||||||
"characterBonusPerformance": 30 + ep0Perf + ep1Perf,
|
|
||||||
"characterBonusTechnique": 30 + ep0Tech + ep1Tech,
|
|
||||||
"characterBonusVisual": 30 + ep0Vis + ep1Vis,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result = append(result, sit)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
func BuildUserProfileDegree(userid string, user map[string]any) map[string]any {
|
|
||||||
degree := user["degree"].([]any)
|
|
||||||
result := map[string]any{
|
|
||||||
"first": map[string]any{
|
|
||||||
"userId": userid,
|
|
||||||
"profileDegreeType": "first",
|
|
||||||
"degreeId": degree[0],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
if len(degree) > 1 && degree[1] != nil {
|
|
||||||
result["second"] = map[string]any{
|
|
||||||
"userId": userid,
|
|
||||||
"profileDegreeType": "second",
|
|
||||||
"degreeId": degree[1],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
func BuildCharacterRankMap() map[string]any {
|
|
||||||
entries := map[string]any{}
|
|
||||||
for i := 1; i <= 40; i++ {
|
|
||||||
entries[fmt.Sprintf("%d", i)] = map[string]any{
|
|
||||||
"rank": 100, "exp": 0, "addExp": 0,
|
|
||||||
"nextExp": 0, "totalExp": 0, "releasedPotentialLevel": 50,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return map[string]any{"entries": entries}
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetScoreRank(score float64, difficultyMaster map[string]any) string {
|
|
||||||
if difficultyMaster == nil {
|
|
||||||
return "c"
|
|
||||||
}
|
|
||||||
get := func(key string) float64 {
|
|
||||||
v, _ := difficultyMaster[key].(float64)
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case score >= get("scoreSS"):
|
|
||||||
return "ss"
|
|
||||||
case score >= get("scoreS"):
|
|
||||||
return "s"
|
|
||||||
case score >= get("scoreA"):
|
|
||||||
return "a"
|
|
||||||
case score >= get("scoreB"):
|
|
||||||
return "b"
|
|
||||||
default:
|
|
||||||
return "c"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user