feat(backend): implement task creation and admin web

This commit is contained in:
QiuSW
2026-07-26 14:03:32 +08:00
parent 2b265c92fc
commit c5d3b215ff
58 changed files with 8773 additions and 83 deletions
+38
View File
@@ -0,0 +1,38 @@
package usecase
import (
"crypto/rand"
"encoding/binary"
"fmt"
"sync/atomic"
"time"
)
type SystemClock struct{}
func (SystemClock) Now() time.Time {
return time.Now().UTC()
}
type UUIDGenerator struct{}
func (UUIDGenerator) NewID() (string, error) {
var value [16]byte
if _, err := rand.Read(value[:]); err != nil {
now := uint64(time.Now().UnixNano())
binary.BigEndian.PutUint64(value[:8], now)
binary.BigEndian.PutUint64(value[8:], fallbackUUID.Add(1))
}
value[6] = (value[6] & 0x0f) | 0x40
value[8] = (value[8] & 0x3f) | 0x80
return fmt.Sprintf(
"%08x-%04x-%04x-%04x-%012x",
value[0:4],
value[4:6],
value[6:8],
value[8:10],
value[10:16],
), nil
}
var fallbackUUID atomic.Uint64