changed db models to go-cnj-helper models

alpha
alex 2023-02-17 20:43:55 +01:00
parent abc35e9c26
commit 23aa0f4b40
4 changed files with 5 additions and 41 deletions

2
go.mod
View File

@ -3,7 +3,7 @@ module clickandjoin.app/storageserver
go 1.19 go 1.19
require ( require (
git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.36 git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.37
github.com/gocql/gocql v1.3.1 github.com/gocql/gocql v1.3.1
github.com/gofiber/fiber/v2 v2.40.1 github.com/gofiber/fiber/v2 v2.40.1
github.com/google/uuid v1.3.0 github.com/google/uuid v1.3.0

2
go.sum
View File

@ -1,5 +1,7 @@
git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.36 h1:tqx39cmvtID3lbjvUbN6Vv2Xt16fXQSwnxiw4esMqnQ= git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.36 h1:tqx39cmvtID3lbjvUbN6Vv2Xt16fXQSwnxiw4esMqnQ=
git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.36/go.mod h1:RnqJsFYGR0cdxbeQjB1dDlr/MeKgnMkc7XoZtFDhMbo= git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.36/go.mod h1:RnqJsFYGR0cdxbeQjB1dDlr/MeKgnMkc7XoZtFDhMbo=
git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.37 h1:vw9ah/Wg+8UyTRGu+L3p23S7DxpqbuWH6a098b2qR9g=
git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.37/go.mod h1:RnqJsFYGR0cdxbeQjB1dDlr/MeKgnMkc7XoZtFDhMbo=
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYEDvkta6I8/rnYM5gSdSV2tJ6XbZuEtY= github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYEDvkta6I8/rnYM5gSdSV2tJ6XbZuEtY=

View File

@ -1,38 +0,0 @@
package scylladb
import (
"github.com/scylladb/gocqlx/v2/table"
)
var (
Users = table.New(table.Metadata{
Name: "users",
Columns: []string{
"id",
"username",
"account_name",
"account_name_lc",
"email",
"password",
"description",
"latitude",
"longitude",
"xp_level",
"xp_points",
"followers_count",
"following_count",
"account_status",
"avatar_url",
"created_at",
"updated_at"},
PartKey: []string{"id"},
})
Sessions = table.New(table.Metadata{
Name: "sessions",
Columns: []string{
"id",
"user_id"},
PartKey: []string{"id"},
})
)

View File

@ -99,7 +99,7 @@ func UpdateAvatar(c *fiber.Ctx) error {
foundSession := structs.UserSession{Id: xAuthorization} foundSession := structs.UserSession{Id: xAuthorization}
q := scylladb.Session.Query(scylladb.Sessions.Get("user_id")).BindStruct(foundSession) q := scylladb.Session.Query(gocnjhelper.DbMSessions.Get("user_id")).BindStruct(foundSession)
if err := q.GetRelease(&foundSession); err != nil { if err := q.GetRelease(&foundSession); err != nil {
gocnjhelper.LogErrorf("Failed to get user session, err: %s", err) gocnjhelper.LogErrorf("Failed to get user session, err: %s", err)
@ -142,7 +142,7 @@ func UpdateAvatar(c *fiber.Ctx) error {
avatarUrl := utils.GetUserAvatarUrl(foundSession.UserId, fileName) avatarUrl := utils.GetUserAvatarUrl(foundSession.UserId, fileName)
user := structs.User{Id: foundSession.UserId, AvatarUrl: avatarUrl} user := structs.User{Id: foundSession.UserId, AvatarUrl: avatarUrl}
q = scylladb.Session.Query(scylladb.Users.Update("avatar_url")).BindStruct(user) q = scylladb.Session.Query(gocnjhelper.DbMUsers.Update("avatar_url")).BindStruct(user)
if err := q.ExecRelease(); err != nil { if err := q.ExecRelease(); err != nil {
gocnjhelper.LogErrorf("Failed to update user avatar url, err: %s", err) gocnjhelper.LogErrorf("Failed to update user avatar url, err: %s", err)