85 lines
1.9 KiB
Go
85 lines
1.9 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
|
|
}
|
|
|
|
type UserSignUpProcess struct {
|
|
XToken string
|
|
Email string
|
|
UserAgent string
|
|
Ip string
|
|
EmailVerifyCode string
|
|
EmailVerified bool
|
|
LastEmailResend int64
|
|
CreatedAt int64
|
|
ExpiresAt int64
|
|
}
|
|
|
|
// swagger:model UserSignUpProcessesResponse
|
|
type UserSignUpProcessesResponse struct {
|
|
UserSignUpProcesses []UserSignUpProcess
|
|
}
|
|
|
|
type UserRelationship struct {
|
|
UserFirstId string
|
|
UserSecondId string
|
|
UserFirstFollowingState uint8
|
|
UserSecondFollowingState uint8
|
|
BlockedState uint8
|
|
CreatedAt int64
|
|
UpdatedAt int64
|
|
}
|
|
|
|
// swagger:model UserRelationshipsResponse
|
|
type UserRelationshipsResponse struct {
|
|
Relationships []UserRelationship
|
|
}
|