feat: add GORM integration with repository pattern

- Add GORM models in models/ directory with proper column tags
- Create repository interfaces and implementations in core/repository/
- Add database package with MySQL and SQLite support
- Add UUID ID utility for GORM models
- Implement complete repository layer replacing SQL-based data access
- Add database migrations and index creation
- Support both MySQL and SQLite drivers with auto-migration

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-06-30 22:07:51 +12:00
parent e865c4c1a2
commit bd3f101fb4
19 changed files with 1467 additions and 0 deletions

48
core/util/id/id.go Normal file
View File

@@ -0,0 +1,48 @@
package id
import (
"encoding/binary"
"github.com/google/uuid"
)
// New creates a new binary ID (16 bytes) using UUID v4
func New() []byte {
u := uuid.New()
return u[:]
}
// ToUUID converts a binary ID back to UUID
func ToUUID(b []byte) (uuid.UUID, error) {
return uuid.FromBytes(b)
}
// String returns the string representation of a binary ID
func String(b []byte) string {
u, err := uuid.FromBytes(b)
if err != nil {
return ""
}
return u.String()
}
// FromString parses a string UUID into binary format
func FromString(s string) ([]byte, error) {
u, err := uuid.Parse(s)
if err != nil {
return nil, err
}
return u[:], nil
}
// Uint64ToBytes converts a uint64 to 8-byte slice
func Uint64ToBytes(v uint64) []byte {
b := make([]byte, 8)
binary.BigEndian.PutUint64(b, v)
return b
}
// BytesToUint64 converts 8-byte slice to uint64
func BytesToUint64(b []byte) uint64 {
return binary.BigEndian.Uint64(b)
}