File size: 1,420 Bytes
d834a80
44c4b7e
 
 
 
 
 
 
 
5c3fcbb
44c4b7e
5c3fcbb
 
 
 
 
44c4b7e
 
 
 
 
 
ca18868
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5c3fcbb
 
 
ca18868
 
5c3fcbb
f7fe55b
ca18868
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package models

import (
	"time"

	"github.com/google/uuid"
	"gorm.io/gorm"
)

type User struct {
	ID          uuid.UUID      `gorm:"primaryKey;type:uuid;default:gen_random_uuid()" json:"id"`
	Username    string         `gorm:"size:100;uniqueIndex;not null" json:"username"`
	Password    string         `gorm:"not null" json:"-"`
	Role        string         `gorm:"default:'user';not null" json:"role"`
	AccountName string         `gorm:"size:100;default:'Default Device'" json:"account_name"`
	JID         string         `gorm:"column:jid;size:255" json:"jid"`
	IsActive    bool           `gorm:"default:false" json:"is_active"`
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"updated_at"`
	DeletedAt   gorm.DeletedAt `gorm:"index" json:"deleted_at"`
}

func (User) TableName() string {
	return "users"
}

type RefreshToken struct {
	ID        uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()" json:"id"`
	UserID    uuid.UUID `gorm:"type:uuid;not null" json:"user_id"`
	Token     string    `gorm:"uniqueIndex;not null" json:"token"`
	ExpiresAt time.Time `json:"expires_at"`
	CreatedAt time.Time `json:"created_at"`
}

func (RefreshToken) TableName() string {
	return "refresh_tokens"
}

type Setting struct {
	Key   string `gorm:"primaryKey;size:255" json:"key"`
	Value string `gorm:"type:text" json:"value"`
}

func (Setting) TableName() string {
	return "settings"
}