add more routes

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

View File

@@ -0,0 +1,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)
}