add more routes
This commit is contained in:
4681
mission.json
Normal file
4681
mission.json
Normal file
File diff suppressed because it is too large
Load Diff
48485
pastEvents/CN.json
Normal file
48485
pastEvents/CN.json
Normal file
File diff suppressed because it is too large
Load Diff
47043
pastEvents/GL.json
Normal file
47043
pastEvents/GL.json
Normal file
File diff suppressed because it is too large
Load Diff
50993
pastEvents/JP.json
Normal file
50993
pastEvents/JP.json
Normal file
File diff suppressed because it is too large
Load Diff
48623
pastEvents/TW.json
Normal file
48623
pastEvents/TW.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -51,5 +51,8 @@ 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)
|
||||||
}
|
}
|
||||||
|
|||||||
1078
routes/api/suite/user/param_userid.go
Normal file
1078
routes/api/suite/user/param_userid.go
Normal file
File diff suppressed because it is too large
Load Diff
120
routes/api/suite/user/param_userid/area.go
Normal file
120
routes/api/suite/user/param_userid/area.go
Normal 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)
|
||||||
|
}
|
||||||
66
routes/api/suite/user/param_userid/dailylivereward.go
Normal file
66
routes/api/suite/user/param_userid/dailylivereward.go
Normal 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)
|
||||||
|
}
|
||||||
99
routes/api/suite/user/param_userid/deck/param_deckid.go
Normal file
99
routes/api/suite/user/param_userid/deck/param_deckid.go
Normal 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)
|
||||||
|
|
||||||
|
}
|
||||||
48
routes/api/suite/user/param_userid/friend/application.go
Normal file
48
routes/api/suite/user/param_userid/friend/application.go
Normal 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)
|
||||||
|
}
|
||||||
16
routes/api/suite/user/param_userid/friend/approval.go
Normal file
16
routes/api/suite/user/param_userid/friend/approval.go
Normal 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)
|
||||||
|
})
|
||||||
|
}
|
||||||
16
routes/api/suite/user/param_userid/friend/friend.go
Normal file
16
routes/api/suite/user/param_userid/friend/friend.go
Normal 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)
|
||||||
|
})
|
||||||
|
}
|
||||||
45
routes/api/suite/user/param_userid/friend/relation.go
Normal file
45
routes/api/suite/user/param_userid/friend/relation.go
Normal 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)
|
||||||
|
}
|
||||||
20
routes/api/suite/user/param_userid/index.go
Normal file
20
routes/api/suite/user/param_userid/index.go
Normal 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)
|
||||||
|
}
|
||||||
30
routes/api/suite/user/param_userid/loginbonus/acceptall.go
Normal file
30
routes/api/suite/user/param_userid/loginbonus/acceptall.go
Normal 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)
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package music
|
||||||
79
routes/api/suite/user/param_userid/profile/degree.go
Normal file
79
routes/api/suite/user/param_userid/profile/degree.go
Normal 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)
|
||||||
|
}
|
||||||
90
routes/api/tcpServer/param_userid.go
Normal file
90
routes/api/tcpServer/param_userid.go
Normal 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)
|
||||||
|
}
|
||||||
@@ -123,7 +123,6 @@ 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,7 +113,6 @@ 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"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
59
routes/api/user/param_userid/area/registeropentimearea.go
Normal file
59
routes/api/user/param_userid/area/registeropentimearea.go
Normal 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)
|
||||||
|
}
|
||||||
69
routes/api/user/param_userid/bandstory/param_bandid.go
Normal file
69
routes/api/user/param_userid/bandstory/param_bandid.go
Normal 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)
|
||||||
|
}
|
||||||
55
routes/api/user/param_userid/device/update.go
Normal file
55
routes/api/user/param_userid/device/update.go
Normal 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)
|
||||||
|
}
|
||||||
40
routes/api/user/param_userid/liveboost.go
Normal file
40
routes/api/user/param_userid/liveboost.go
Normal 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)
|
||||||
|
}
|
||||||
39
routes/api/user/param_userid/livefever.go
Normal file
39
routes/api/user/param_userid/livefever.go
Normal 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)
|
||||||
|
}
|
||||||
38
routes/api/user/param_userid/maindeck.go
Normal file
38
routes/api/user/param_userid/maindeck.go
Normal 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)
|
||||||
|
}
|
||||||
93
routes/api/user/param_userid/memorialstory.go
Normal file
93
routes/api/user/param_userid/memorialstory.go
Normal 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)
|
||||||
|
}
|
||||||
20
routes/api/user/param_userid/multiroomfriendrecruitment.go
Normal file
20
routes/api/user/param_userid/multiroomfriendrecruitment.go
Normal 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)
|
||||||
|
}
|
||||||
20
routes/api/user/param_userid/music/param_musicid.go
Normal file
20
routes/api/user/param_userid/music/param_musicid.go
Normal 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)
|
||||||
|
}
|
||||||
82
routes/api/user/param_userid/music/param_musicid/continue.go
Normal file
82
routes/api/user/param_userid/music/param_musicid/continue.go
Normal 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)
|
||||||
|
}
|
||||||
20
routes/api/user/param_userid/music/param_musicid/retry.go
Normal file
20
routes/api/user/param_userid/music/param_musicid/retry.go
Normal 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)
|
||||||
|
}
|
||||||
40
routes/api/user/param_userid/present.go
Normal file
40
routes/api/user/param_userid/present.go
Normal 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)
|
||||||
|
}
|
||||||
40
routes/api/user/param_userid/presenthistory.go
Normal file
40
routes/api/user/param_userid/presenthistory.go
Normal 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)
|
||||||
|
}
|
||||||
222
utils/helper.go
Normal file
222
utils/helper.go
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
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