changed structs to go-cnj-helper dbstructs

alpha
alex 2023-02-17 21:17:41 +01:00
parent 23aa0f4b40
commit 85166dd087
4 changed files with 9 additions and 41 deletions

4
go.mod
View File

@ -3,12 +3,12 @@ module clickandjoin.app/storageserver
go 1.19
require (
git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.37
git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.38
github.com/gocql/gocql v1.3.1
github.com/gofiber/fiber/v2 v2.40.1
github.com/google/uuid v1.3.0
github.com/h2non/bimg v1.1.9
github.com/scylladb/gocqlx/v2 v2.7.0
github.com/scylladb/gocqlx/v2 v2.8.0
gopkg.in/yaml.v2 v2.4.0
)

4
go.sum
View File

@ -2,6 +2,8 @@ git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.36 h1:tqx39cmvtID3lb
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=
git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.38 h1:q18cXubjA12hKaeB7NvSK47qGTUtzsnqAWUUcCExJQY=
git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.38/go.mod h1:Jzc4/4ntrOLMOZYnUjkr1uBCVtRvPbEbQD+8kwBOdf4=
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
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=
@ -54,6 +56,8 @@ github.com/scylladb/go-reflectx v1.0.1 h1:b917wZM7189pZdlND9PbIJ6NQxfDPfBvUaQ7cj
github.com/scylladb/go-reflectx v1.0.1/go.mod h1:rWnOfDIRWBGN0miMLIcoPt/Dhi2doCMZqwMCJ3KupFc=
github.com/scylladb/gocqlx/v2 v2.7.0 h1:/w1VeJHCEAsg9eTculTvIS9eIe/VmEu0clhlH1CF7lc=
github.com/scylladb/gocqlx/v2 v2.7.0/go.mod h1:jKhM0/LkEAhEOSwd10TCMQdlC5x8aEzK7cXjQcPyMJ0=
github.com/scylladb/gocqlx/v2 v2.8.0 h1:f/oIgoEPjKDKd+RIoeHqexsIQVIbalVmT+axwvUqQUg=
github.com/scylladb/gocqlx/v2 v2.8.0/go.mod h1:4/+cga34PVqjhgSoo5Nr2fX1MQIqZB5eCE5DK4xeDig=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=

View File

@ -5,47 +5,10 @@ const (
LenXAuthorizationToken = 36
)
// Representation of the user model
// TABLE users
type User struct {
Id string
Username string
AccountName string
AccountNameLc string
Email string
Password string
Description string
Latitude float64
Longitude float64
ParticipatingEvents []string
VisitedEvents []string
Notifications []string
XpLevel int
XpPoints int
FollowersCount int
FollowingCount int
AccountStatus uint8
AvatarUrl string
CreatedAt int64
UpdatedAt int64
}
type UserPrivacy struct {
Test uint8
}
// TABLE sessions
type UserSession struct {
Id string
UserId string
FcmToken string
UserAgent string
AppVersion string
Ip string
LastUsed int64
CreatedAt int64
}
// swagger:model UpdatedUserAvatarResponse
type UpdatedUserAvatarResponse struct {
AvatarUrl string

View File

@ -6,6 +6,7 @@ import (
"clickandjoin.app/storageserver/modules/structs"
"clickandjoin.app/storageserver/modules/utils"
gocnjhelper "git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper"
"git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper/dbstructs"
"github.com/gofiber/fiber/v2"
"github.com/google/uuid"
)
@ -97,7 +98,7 @@ func UpdateAvatar(c *fiber.Ctx) error {
return c.SendStatus(fiber.StatusUnauthorized)
}
foundSession := structs.UserSession{Id: xAuthorization}
foundSession := dbstructs.UserSession{Id: xAuthorization}
q := scylladb.Session.Query(gocnjhelper.DbMSessions.Get("user_id")).BindStruct(foundSession)
@ -140,7 +141,7 @@ func UpdateAvatar(c *fiber.Ctx) error {
}
avatarUrl := utils.GetUserAvatarUrl(foundSession.UserId, fileName)
user := structs.User{Id: foundSession.UserId, AvatarUrl: avatarUrl}
user := dbstructs.User{Id: foundSession.UserId, AvatarUrl: avatarUrl}
q = scylladb.Session.Query(gocnjhelper.DbMUsers.Update("avatar_url")).BindStruct(user)