add load data_player
This commit is contained in:
Binary file not shown.
@@ -47,10 +47,10 @@ func FileAuthGET() (map[string]interface{}, error) {
|
|||||||
valueList[i] = strings.TrimSpace(valueList[i])
|
valueList[i] = strings.TrimSpace(valueList[i])
|
||||||
}
|
}
|
||||||
MapDATA[key] = valueList
|
MapDATA[key] = valueList
|
||||||
break
|
|
||||||
case false:
|
case false:
|
||||||
MapDATA[key] = value
|
MapDATA[key] = value
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,20 @@ type resp_json struct {
|
|||||||
Status string `json:"Status"`
|
Status string `json:"Status"`
|
||||||
Message string `json:"Message,omitempty"`
|
Message string `json:"Message,omitempty"`
|
||||||
Logs []logEntry `json:"Logs,omitempty"`
|
Logs []logEntry `json:"Logs,omitempty"`
|
||||||
|
Foto string `json:"Foto,omitempty"`
|
||||||
|
PlayerName string `json:"PlayerName,omitempty"`
|
||||||
|
Conhecimento *int64 `json:"Conhecimento,omitempty"`
|
||||||
|
Level *int64 `json:"Level,omitempty"`
|
||||||
|
Idade *int64 `json:"Idade,omitempty"`
|
||||||
|
Altura *float64 `json:"Altura,omitempty"`
|
||||||
|
Vida string `json:"Vida,omitempty"`
|
||||||
|
Destresa *int64 `json:"Destresa,omitempty"`
|
||||||
|
Inteligencia *int64 `json:"Inteligencia,omitempty"`
|
||||||
|
Força *int64 `json:"Força,omitempty"`
|
||||||
|
Constituição *int64 `json:"Constituição,omitempty"`
|
||||||
|
Cárisma *int64 `json:"Cárisma,omitempty"`
|
||||||
|
Inventario *int64 `json:"Inventario,omitempty"`
|
||||||
|
Descrição string `json:"Descrição,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -1,35 +1,28 @@
|
|||||||
module rpgzrox
|
module Helena_de_troia
|
||||||
|
|
||||||
go 1.24.3
|
go 1.24.4
|
||||||
|
|
||||||
require github.com/gocql/gocql v1.7.0
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/go-redis/redis/v8 v8.11.5
|
github.com/go-redis/redis/v8 v8.11.5
|
||||||
|
github.com/go-sql-driver/mysql v1.9.3
|
||||||
|
github.com/gocql/gocql v1.7.0
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
golang.org/x/time v0.11.0
|
github.com/labstack/echo/v4 v4.13.4
|
||||||
)
|
golang.org/x/crypto v0.39.0
|
||||||
|
golang.org/x/time v0.12.0
|
||||||
require (
|
|
||||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
filippo.io/edwards25519 v1.1.0 // indirect
|
filippo.io/edwards25519 v1.1.0 // indirect
|
||||||
github.com/go-sql-driver/mysql v1.9.2
|
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||||
)
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/golang/snappy v0.0.3 // indirect
|
github.com/golang/snappy v0.0.3 // indirect
|
||||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
|
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
|
||||||
github.com/labstack/echo/v4 v4.13.4
|
|
||||||
github.com/labstack/gommon v0.4.2 // indirect
|
github.com/labstack/gommon v0.4.2 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||||
golang.org/x/crypto v0.39.0
|
|
||||||
golang.org/x/net v0.40.0 // indirect
|
golang.org/x/net v0.40.0 // indirect
|
||||||
golang.org/x/sys v0.33.0 // indirect
|
golang.org/x/sys v0.33.0 // indirect
|
||||||
golang.org/x/text v0.26.0 // indirect
|
golang.org/x/text v0.26.0 // indirect
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWo
|
|||||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||||
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||||
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
||||||
github.com/go-sql-driver/mysql v1.9.2 h1:4cNKDYQ1I84SXslGddlsrMhc8k4LeDVj6Ad6WRjiHuU=
|
github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1aweo=
|
||||||
github.com/go-sql-driver/mysql v1.9.2/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
|
github.com/go-sql-driver/mysql v1.9.3/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
|
||||||
github.com/gocql/gocql v1.7.0 h1:O+7U7/1gSN7QTEAaMEsJc1Oq2QHXvCWoF3DFK9HDHus=
|
github.com/gocql/gocql v1.7.0 h1:O+7U7/1gSN7QTEAaMEsJc1Oq2QHXvCWoF3DFK9HDHus=
|
||||||
github.com/gocql/gocql v1.7.0/go.mod h1:vnlvXyFZeLBF0Wy+RS8hrOdbn0UWsWtdg07XJnFxZ+4=
|
github.com/gocql/gocql v1.7.0/go.mod h1:vnlvXyFZeLBF0Wy+RS8hrOdbn0UWsWtdg07XJnFxZ+4=
|
||||||
github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA=
|
github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA=
|
||||||
@@ -63,8 +63,8 @@ golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
|||||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||||
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
|
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
|
||||||
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
|
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
|
||||||
golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0=
|
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
|
||||||
golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
|
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
|
||||||
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
|
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
|
||||||
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
/* libs minha */
|
/* libs minha */
|
||||||
"rpgzrox/config_data"
|
"Helena_de_troia/config_data"
|
||||||
|
|
||||||
/* libs externas */
|
/* libs externas */
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
@@ -83,8 +82,10 @@ func main() {
|
|||||||
|
|
||||||
e.GET("/", online)
|
e.GET("/", online)
|
||||||
e.GET("roll", roll_get)
|
e.GET("roll", roll_get)
|
||||||
|
e.GET("register", badreq)
|
||||||
e.POST("register", registrar)
|
e.POST("register", registrar)
|
||||||
e.POST("login", login, timeoutMiddleware, rateLimit)
|
e.POST("login", login, timeoutMiddleware, rateLimit)
|
||||||
|
e.GET("login", badreq)
|
||||||
e.GET("player", player_data)
|
e.GET("player", player_data)
|
||||||
|
|
||||||
/* log */
|
/* log */
|
||||||
|
|||||||
@@ -22,6 +22,13 @@ func online(c echo.Context) error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func badreq(c echo.Context) error {
|
||||||
|
return c.JSON(http.StatusBadRequest, resp_json{
|
||||||
|
Status: "Error",
|
||||||
|
Message: "essa rota não foi preparada para requisições do tipo get.",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func registrar(c echo.Context) error {
|
func registrar(c echo.Context) error {
|
||||||
player := c.FormValue("player")
|
player := c.FormValue("player")
|
||||||
password := c.FormValue("password")
|
password := c.FormValue("password")
|
||||||
@@ -231,15 +238,40 @@ func roll_get(c echo.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func player_data(c echo.Context) error {
|
func player_data(c echo.Context) error {
|
||||||
test, err := ValidSession(c)
|
userSession, err := ValidSession(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.JSON(http.StatusUnauthorized, resp_json{
|
return c.JSON(http.StatusUnauthorized, resp_json{
|
||||||
Status: "Error",
|
Status: "Error",
|
||||||
Message: err.Error(),
|
Message: err.Error(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
var foto, playername, vida, descrição string
|
||||||
|
var conhecimento, level, idade, vd, vdm, destresa, inteligencia, força, constituição, cárisma, inventario int64
|
||||||
|
var altura float64
|
||||||
|
err = db.QueryRow("SELECT foto, nome, conhecimento, level, idade, altura, vida, vida_maxima, destresa, inteligencia, força, constituição, cárisma, inventario, descrição FROM players WHERE id=? LIMIT 1;", userSession["user_id"]).Scan(&foto, &playername, &conhecimento, &level, &idade, &altura, &vd, &vdm, &destresa, &inteligencia, &força, &constituição, &cárisma, &inventario, &descrição)
|
||||||
|
if err == nil {
|
||||||
|
vida = fmt.Sprintf("%v/%v", vd, vdm)
|
||||||
return c.JSON(http.StatusOK, resp_json{
|
return c.JSON(http.StatusOK, resp_json{
|
||||||
Status: "Success",
|
Status: "Success",
|
||||||
Message: test["user_id"],
|
Foto: foto,
|
||||||
|
PlayerName: playername,
|
||||||
|
Conhecimento: &conhecimento,
|
||||||
|
Level: &level,
|
||||||
|
Idade: &idade,
|
||||||
|
Altura: &altura,
|
||||||
|
Vida: vida,
|
||||||
|
Destresa: &destresa,
|
||||||
|
Inteligencia: &inteligencia,
|
||||||
|
Força: &força,
|
||||||
|
Constituição: &constituição,
|
||||||
|
Cárisma: &cárisma,
|
||||||
|
Inventario: &inventario,
|
||||||
|
Descrição: descrição,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
return c.JSON(http.StatusBadRequest, resp_json{
|
||||||
|
Status: "Error",
|
||||||
|
Message: "Algo deu errado ao carregar dados da sua ficha",
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user