tugas baru

This commit is contained in:
Nama Kamu
2026-09-28 12:15:29 +07:00
parent 8bafff0c98
commit 6e7e35d9a5
15 changed files with 834 additions and 33 deletions
+21 -7
View File
@@ -4,11 +4,25 @@ import (
"time"
)
// Snippet merepresentasikan satu baris data dari database PostgreSQL
// User merepresentasikan tabel users di database
type User struct {
ID string `json:"id"` // UUID, server-generated
Username string `json:"username"` // unique, case-sensitive, 3-32 chars
PasswordHash string `json:"-"` // never returned in any response
}
// Session merepresentasikan tabel sessions di database
type Session struct {
Token string `json:"token"` // server-generated, unique bearer token
UserID string `json:"user_id"` // foreign key ke users.id
CreatedAt time.Time `json:"created_at"` // informational only
}
// Snippet merepresentasikan tabel snippets di database
// UserID disimpan di DB tapi tidak di-serialize ke JSON response
type Snippet struct {
ID int64 `json:"id"`
Title string `json:"title"`
Content string `json:"content"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
}
ID string `json:"id"`
Title string `json:"title"`
Content string `json:"content"`
UserID string `json:"-"` // internal only, not in JSON response
}