- 用户域:注册/登录(JWT)/修改密码/个人资料 - 照片/衣橱/身形/化身:上传存储 + 3D 化身模板匹配 - 穿搭生成:天气(高德+和风+缓存) → 规则预筛 → LLM 规划(1次调用) → 规则评分(5维100分制) → 全低分触发 LLM 兜底创作 → 异步任务状态机 - 效果图:选主方案后异步生成 3 视角(mock/wanx 供应商 + 内容 hash 缓存 + 每日限额) - 商业化:合作门店列表(seed 4 家) - 冒烟:全链路端到端验证通过(mock LLM/天气),23 个 API 端点 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
50 lines
957 B
Go
50 lines
957 B
Go
package imagegen
|
||
|
||
import (
|
||
"sync"
|
||
"time"
|
||
)
|
||
|
||
// cache 效果图 URL 缓存(key: 方案内容 hash:角度,24h TTL)
|
||
type cache struct {
|
||
mu sync.Mutex
|
||
items map[string]cacheEntry
|
||
}
|
||
|
||
type cacheEntry struct {
|
||
url string
|
||
expiresAt time.Time
|
||
}
|
||
|
||
var effectCache = &cache{items: make(map[string]cacheEntry)}
|
||
|
||
// CacheGet 读取缓存 URL
|
||
func CacheGet(key string) (string, bool) {
|
||
return cacheGet(key)
|
||
}
|
||
|
||
// CacheSet 写入缓存 URL
|
||
func CacheSet(key, url string) {
|
||
cacheSet(key, url)
|
||
}
|
||
|
||
func cacheGet(key string) (string, bool) {
|
||
effectCache.mu.Lock()
|
||
defer effectCache.mu.Unlock()
|
||
e, ok := effectCache.items[key]
|
||
if !ok {
|
||
return "", false
|
||
}
|
||
if time.Now().After(e.expiresAt) {
|
||
delete(effectCache.items, key)
|
||
return "", false
|
||
}
|
||
return e.url, true
|
||
}
|
||
|
||
func cacheSet(key, url string) {
|
||
effectCache.mu.Lock()
|
||
defer effectCache.mu.Unlock()
|
||
effectCache.items[key] = cacheEntry{url: url, expiresAt: time.Now().Add(24 * time.Hour)}
|
||
}
|