POST:/users works
This commit is contained in:
23
server/api/models/client.go
Normal file
23
server/api/models/client.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type ClientType string
|
||||
|
||||
const (
|
||||
ClientTypeAndroid ClientType = "ANDROID"
|
||||
ClientTypeIOS ClientType = "IOS"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
ClientID int64
|
||||
UserID int64
|
||||
Type ClientType
|
||||
FCMToken *string
|
||||
TimestampCreated time.Time
|
||||
AgentModel string
|
||||
AgentVersion string
|
||||
}
|
||||
|
||||
type ClientJSON struct {
|
||||
}
|
||||
51
server/api/models/user.go
Normal file
51
server/api/models/user.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type User struct {
|
||||
UserID int64
|
||||
Username *string
|
||||
ReadKey string
|
||||
SendKey string
|
||||
AdminKey string
|
||||
TimestampCreated time.Time
|
||||
TimestampLastRead *time.Time
|
||||
TimestampLastSent *time.Time
|
||||
MessagesSent int
|
||||
QuotaToday int
|
||||
QuotaDay *string
|
||||
IsPro bool
|
||||
ProToken *string
|
||||
}
|
||||
|
||||
func (u User) JSON() UserJSON {
|
||||
return UserJSON{
|
||||
UserID: u.UserID,
|
||||
Username: u.Username,
|
||||
ReadKey: u.ReadKey,
|
||||
SendKey: u.SendKey,
|
||||
AdminKey: u.AdminKey,
|
||||
TimestampCreated: u.TimestampCreated.Format(time.RFC3339Nano),
|
||||
TimestampLastRead: timeOptFmt(u.TimestampLastRead, time.RFC3339Nano),
|
||||
TimestampLastSent: timeOptFmt(u.TimestampLastSent, time.RFC3339Nano),
|
||||
MessagesSent: u.MessagesSent,
|
||||
QuotaToday: u.QuotaToday,
|
||||
QuotaDay: u.QuotaDay,
|
||||
IsPro: u.IsPro,
|
||||
}
|
||||
}
|
||||
|
||||
type UserJSON struct {
|
||||
UserID int64 `json:"user_id"`
|
||||
Username *string `json:"username"`
|
||||
ReadKey string `json:"read_key"`
|
||||
SendKey string `json:"send_key"`
|
||||
AdminKey string `json:"admin_key"`
|
||||
TimestampCreated string `json:"timestamp_created"`
|
||||
TimestampLastRead *string `json:"timestamp_last_read"`
|
||||
TimestampLastSent *string `json:"timestamp_last_sent"`
|
||||
MessagesSent int `json:"messages_sent"`
|
||||
QuotaToday int `json:"quota_today"`
|
||||
QuotaDay *string `json:"quota_day"`
|
||||
IsPro bool `json:"is_pro"`
|
||||
}
|
||||
14
server/api/models/utils.go
Normal file
14
server/api/models/utils.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||
"time"
|
||||
)
|
||||
|
||||
func timeOptFmt(t *time.Time, fmt string) *string {
|
||||
if t == nil {
|
||||
return nil
|
||||
} else {
|
||||
return langext.Ptr(t.Format(fmt))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user