feat: P1 合盘/星座/问答与测测完整设计包及模拟器取证工具
落地 synastry/star/ask API 与 H5 页面,补齐 cece-frontend-re complete-design 证据文档,并加入 Android 模拟器截图抓取脚本。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
sc "github.com/yuxingu/digital-psychology/apps/api/internal/scale"
|
||||
"github.com/yuxingu/digital-psychology/apps/api/internal/repository"
|
||||
)
|
||||
|
||||
@@ -51,31 +52,10 @@ func (s *Service) Submit(ctx context.Context, userID uuid.UUID, slug string, in
|
||||
if err != nil {
|
||||
return nil, errors.New("scale not found")
|
||||
}
|
||||
counts := map[string]int{}
|
||||
for _, v := range in.Answers {
|
||||
counts[v]++
|
||||
}
|
||||
best, bestN := "A", -1
|
||||
for k, n := range counts {
|
||||
if n > bestN {
|
||||
best, bestN = k, n
|
||||
}
|
||||
}
|
||||
label := map[string]string{
|
||||
"A": "理性澄清型",
|
||||
"B": "感受连接型",
|
||||
"C": "节奏尊重型",
|
||||
}[best]
|
||||
if label == "" {
|
||||
label = "平衡探索型"
|
||||
}
|
||||
result := map[string]interface{}{
|
||||
"title": "探索结果",
|
||||
"style_key": best,
|
||||
"label": label,
|
||||
"summary": "这是你当前沟通偏好的探索结果,可用于自我了解与关系理解,不是固定标签。",
|
||||
"share_line": "我的沟通方式:" + label,
|
||||
}
|
||||
|
||||
labels, _, _ := labelsForSlug(slug)
|
||||
key, label := sc.ScoreMajority(in.Answers, labels, "平衡探索型")
|
||||
result := sc.BuildResult(slug, key, label)
|
||||
ansJSON, _ := json.Marshal(in.Answers)
|
||||
resJSON, _ := json.Marshal(result)
|
||||
id, err := s.Repo.SaveResult(ctx, userID, scaleID, in.ProfileID, ansJSON, resJSON)
|
||||
@@ -84,3 +64,37 @@ func (s *Service) Submit(ctx context.Context, userID uuid.UUID, slug string, in
|
||||
}
|
||||
return &SubmitResult{ID: id, Result: result}, nil
|
||||
}
|
||||
|
||||
func labelsForSlug(slug string) (labels map[string]string, sharePrefix, summary string) {
|
||||
switch slug {
|
||||
case "emotion-pattern":
|
||||
return sc.EmotionLabels(),
|
||||
"我的情感模式:",
|
||||
"这是你当前情绪调节偏好的探索结果,可用于自我了解与日常调整,不是固定标签。"
|
||||
case "mbti-lite":
|
||||
return map[string]string{"E": "外向充能型", "I": "内向充能型", "T": "理性决策型", "F": "感受决策型", "J": "结构安排型", "P": "弹性探索型"},
|
||||
"我的人格偏好:", "轻量人格偏好探索,不是固定分类。"
|
||||
case "enneagram-lite":
|
||||
return map[string]string{"A": "尽责驱动型", "B": "联结驱动型", "C": "独立驱动型"},
|
||||
"我的动机模式:", "内在动机轻量探索,用于自我觉察。"
|
||||
case "bigfive-lite":
|
||||
return map[string]string{"O": "开放探索型", "C": "条理稳健型", "E": "主动外展型", "A": "温和协作型", "N": "细腻敏感型"},
|
||||
"我的性格五维:", "稳定特质速览,可随情境变化。"
|
||||
case "love-style":
|
||||
return map[string]string{"A": "稳定陪伴型", "B": "深度共鸣型", "C": "空间尊重型"},
|
||||
"我的亲密互动:", "亲密关系偏好探索,不是关系定论。"
|
||||
case "eq-lite":
|
||||
return map[string]string{"A": "觉察表达型", "B": "行动调节型", "C": "缓慢识别型"},
|
||||
"我的情绪觉察:", "情绪习惯探索,可用于日常调节。"
|
||||
case "stress-index":
|
||||
return map[string]string{"A": "节奏稳定型", "B": "波动调节型", "C": "高负荷需休息型"},
|
||||
"我的压力负荷:", "近期压力与恢复偏好,不是诊断。"
|
||||
case "career-interest":
|
||||
return map[string]string{"A": "创造表达型", "B": "助人支持型", "C": "分析解决型"},
|
||||
"我的职业兴趣:", "工作动力偏好探索,可作方向参考。"
|
||||
default:
|
||||
return sc.CommunicationLabels(),
|
||||
"我的沟通方式:",
|
||||
"这是你当前沟通偏好的探索结果,可用于自我了解与关系理解,不是固定标签。"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user