Add user database migration, core reusable components, and layout structure
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
)
|
||||
|
||||
// ── Work Order ────────────────────────────────────────────────────────────────
|
||||
|
||||
type WorkOrder struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
@@ -41,6 +47,8 @@ type WorkOrderListItem struct {
|
||||
PhotoCount int `db:"photo_count" json:"photo_count"`
|
||||
}
|
||||
|
||||
// ── Steps / Resources / Attachments / Accounting ─────────────────────────────
|
||||
|
||||
type Step struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
WOID int `db:"wo_id" json:"wo_id"`
|
||||
@@ -90,6 +98,8 @@ type AccountingCode struct {
|
||||
Description string `db:"description" json:"description"`
|
||||
}
|
||||
|
||||
// ── Resource Registry ─────────────────────────────────────────────────────────
|
||||
|
||||
type RegistryPerson struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
Name string `db:"name" json:"name"`
|
||||
@@ -106,10 +116,10 @@ type RegistryVehicle struct {
|
||||
}
|
||||
|
||||
type RegistryEquipment struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
Name string `db:"name" json:"name"`
|
||||
ID int `db:"id" json:"id"`
|
||||
Name string `db:"name" json:"name"`
|
||||
AssetTag string `db:"asset_tag" json:"asset_tag"`
|
||||
Category string `db:"category" json:"category"`
|
||||
Category string `db:"category" json:"category"`
|
||||
}
|
||||
|
||||
type RegistryMaterial struct {
|
||||
@@ -119,11 +129,38 @@ type RegistryMaterial struct {
|
||||
PartNumber string `db:"part_number" json:"part_number"`
|
||||
}
|
||||
|
||||
// ── Users & Auth ──────────────────────────────────────────────────────────────
|
||||
|
||||
type User struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
Username string `db:"username" json:"username"`
|
||||
Email string `db:"email" json:"email"`
|
||||
DisplayName string `db:"display_name" json:"display_name"`
|
||||
PasswordHash string `db:"password_hash" json:"-"`
|
||||
Role string `db:"role" json:"role"`
|
||||
AvatarURL string `db:"avatar_url" json:"avatar_url,omitempty"`
|
||||
Active bool `db:"active" json:"active"`
|
||||
LastLogin *time.Time `db:"last_login" json:"last_login"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
}
|
||||
|
||||
// LocalClaims is the JWT payload for locally-issued tokens.
|
||||
type LocalClaims struct {
|
||||
jwt.RegisteredClaims
|
||||
UserID int `json:"uid"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
DisplayName string `json:"name"`
|
||||
Role string `json:"role"`
|
||||
}
|
||||
|
||||
// UserClaims is stored in request context after token validation.
|
||||
type UserClaims struct {
|
||||
Sub string
|
||||
Email string
|
||||
Name string
|
||||
Roles []string
|
||||
UserID int `json:"user_id"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
DisplayName string `json:"display_name"`
|
||||
Role string `json:"role"`
|
||||
}
|
||||
|
||||
type CtxKey string
|
||||
|
||||
Reference in New Issue
Block a user