计策列表/详情、关卡详情(决策树内存组装),内容查询走缓存, 按孩子年龄段过滤关卡,解锁按前置计全部关卡完美判定。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
74 lines
2.0 KiB
Go
74 lines
2.0 KiB
Go
package controller
|
|
|
|
import (
|
|
"context"
|
|
|
|
"36wisdom/biz/model/dto"
|
|
"36wisdom/biz/service"
|
|
"36wisdom/common/auth"
|
|
)
|
|
|
|
type strategy struct{}
|
|
|
|
var Strategy = &strategy{}
|
|
|
|
func (c *strategy) List(ctx context.Context, req *dto.StrategyListReq) (*dto.StrategyListRes, error) {
|
|
items, err := service.Strategy.List(ctx, auth.GetUid(ctx), req.ChildId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
res := &dto.StrategyListRes{List: make([]dto.StrategyItem, 0, len(items))}
|
|
for _, it := range items {
|
|
res.List = append(res.List, dto.StrategyItem{
|
|
StrategyId: it.StrategyId,
|
|
Name: it.Name,
|
|
Pinyin: it.Pinyin,
|
|
GroupNo: it.GroupNo,
|
|
GroupName: it.GroupName,
|
|
Meaning: it.Meaning,
|
|
Icon: it.Icon,
|
|
SortOrder: it.SortOrder,
|
|
Stars: it.Stars,
|
|
PerfectCount: it.PerfectCount,
|
|
TotalLevels: it.TotalLevels,
|
|
Unlocked: it.Unlocked,
|
|
UnlockReason: it.UnlockReason,
|
|
})
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
func (c *strategy) Detail(ctx context.Context, req *dto.StrategyDetailReq) (*dto.StrategyDetailRes, error) {
|
|
detail, err := service.Strategy.Detail(ctx, auth.GetUid(ctx), req.ChildId, req.StrategyId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
res := &dto.StrategyDetailRes{
|
|
StrategyId: detail.StrategyId,
|
|
Name: detail.Name,
|
|
Pinyin: detail.Pinyin,
|
|
Meaning: detail.Meaning,
|
|
GroupName: detail.GroupName,
|
|
TeachContent: detail.TeachContent,
|
|
TeachImage: detail.TeachImage,
|
|
TeachAudio: detail.TeachAudio,
|
|
SummaryQ: detail.SummaryQ,
|
|
SummaryOptions: detail.SummaryOptions,
|
|
Levels: make([]dto.LevelBrief, 0, len(detail.Levels)),
|
|
}
|
|
for _, lv := range detail.Levels {
|
|
res.Levels = append(res.Levels, dto.LevelBrief{
|
|
LevelId: lv.LevelId,
|
|
Title: lv.Title,
|
|
AgeGroup: lv.AgeGroup,
|
|
SceneName: lv.SceneName,
|
|
Stars: lv.Stars,
|
|
Perfect: lv.Perfect,
|
|
Unlocked: lv.Unlocked,
|
|
ContentVersion: lv.ContentVersion,
|
|
ProgressVersion: lv.ProgressVersion,
|
|
})
|
|
}
|
|
return res, nil
|
|
}
|