ManagementSystem/modules/structs/user.go

53 lines
1.1 KiB
Go

package structs
import (
"reflect"
"github.com/gocql/gocql"
"github.com/scylladb/gocqlx/v2"
)
type User struct {
Id string
Username string
AccountName string
AccountNameLc string
Email string
Password string
Description string
Latitude float64
Longitude float64
XpLevel int
XpPoints int
FollowersCount int
FollowingCount int
AccountStatus uint8
AvatarUrl string
PublicKeys []UserPublicKeys
CreatedAt int64
UpdatedAt int64
}
type UserPublicKeys struct {
gocqlx.UDT
Id string
PublicKey string
}
// needed to store into database
func (u UserPublicKeys) MarshalUDT(name string, info gocql.TypeInfo) ([]byte, error) {
f := gocqlx.DefaultMapper.FieldByName(reflect.ValueOf(u), name)
return gocql.Marshal(info, f.Interface())
}
// needed to take from database
func (u *UserPublicKeys) UnmarshalUDT(name string, info gocql.TypeInfo, data []byte) error {
f := gocqlx.DefaultMapper.FieldByName(reflect.ValueOf(u), name)
return gocql.Unmarshal(info, data, f.Addr().Interface())
}
// swagger:model UsersResponse
type UsersResponse struct {
Users []User
}