diff --git a/biz/controller/level.go b/biz/controller/level.go index 16e85b2..9fbab21 100644 --- a/biz/controller/level.go +++ b/biz/controller/level.go @@ -18,16 +18,17 @@ func (c *level) Detail(ctx context.Context, req *dto.LevelDetailReq) (*dto.Level return nil, err } res := &dto.LevelDetailRes{ - LevelId: detail.LevelId, - Title: detail.Title, - Scene: elementVO(detail.Scene), - SceneContent: detail.SceneContent, - SceneImage: detail.SceneImage, - SceneAudio: detail.SceneAudio, - Entry: nodeVO(detail.Entry), - TotalFinals: detail.TotalFinals, - Perfect: detail.Perfect, - Stars: detail.Stars, + LevelId: detail.LevelId, + Title: detail.Title, + Scene: elementVO(detail.Scene), + SceneContent: detail.SceneContent, + SceneContentPinyin: detail.SceneContentPinyin, + SceneImage: detail.SceneImage, + SceneAudio: detail.SceneAudio, + Entry: nodeVO(detail.Entry), + TotalFinals: detail.TotalFinals, + Perfect: detail.Perfect, + Stars: detail.Stars, } return res, nil } @@ -40,6 +41,7 @@ func elementVO(e *service.Element) *dto.ElementVO { Id: e.Id, EType: e.EType, Name: e.Name, + NamePinyin: e.NamePinyin, Image: e.Image, Audio: e.Audio, Description: e.Description, @@ -51,6 +53,7 @@ func nodeVO(n *service.Node) dto.NodeVO { NodeId: n.NodeId, Title: n.Title, Content: n.Content, + ContentPinyin: n.ContentPinyin, Image: n.Image, Audio: n.Audio, Character: elementVO(n.Character), @@ -62,9 +65,12 @@ func nodeVO(n *service.Node) dto.NodeVO { } for _, o := range n.Options { vo.Options = append(vo.Options, dto.OptionVO{ - OptionId: o.OptionId, - Text: o.Text, - Prop: elementVO(o.Prop), + OptionId: o.OptionId, + Text: o.Text, + TextPinyin: o.TextPinyin, + FeedbackPros: o.FeedbackPros, + FeedbackCons: o.FeedbackCons, + Prop: elementVO(o.Prop), }) } return vo diff --git a/biz/controller/strategy.go b/biz/controller/strategy.go index 0a1a498..7fbfb48 100644 --- a/biz/controller/strategy.go +++ b/biz/controller/strategy.go @@ -44,17 +44,19 @@ func (c *strategy) Detail(ctx context.Context, req *dto.StrategyDetailReq) (*dto 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)), + StrategyId: detail.StrategyId, + Name: detail.Name, + Pinyin: detail.Pinyin, + Meaning: detail.Meaning, + MeaningPinyin: detail.MeaningPinyin, + GroupName: detail.GroupName, + TeachContent: detail.TeachContent, + TeachContentPinyin: detail.TeachContentPinyin, + 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{ diff --git a/biz/model/dto/level.go b/biz/model/dto/level.go index 777c4a5..a260fa8 100644 --- a/biz/model/dto/level.go +++ b/biz/model/dto/level.go @@ -12,40 +12,46 @@ type ElementVO struct { Id int64 `json:"id"` EType int `json:"e_type"` Name string `json:"name"` + NamePinyin string `json:"name_pinyin"` Image string `json:"image"` Audio string `json:"audio"` Description string `json:"description"` } type OptionVO struct { - OptionId int64 `json:"option_id"` - Text string `json:"text"` - Prop *ElementVO `json:"prop"` + OptionId int64 `json:"option_id"` + Text string `json:"text"` + TextPinyin string `json:"text_pinyin"` + FeedbackPros string `json:"feedback_pros"` + FeedbackCons string `json:"feedback_cons"` + Prop *ElementVO `json:"prop"` } type NodeVO struct { - NodeId int64 `json:"node_id"` - Title string `json:"title"` - Content string `json:"content"` - Image string `json:"image"` - Audio string `json:"audio"` - Character *ElementVO `json:"character"` - InteractionType int `json:"interaction_type"` - Config string `json:"config"` - NodeType int `json:"node_type"` - ResultType int `json:"result_type"` - Options []OptionVO `json:"options"` + NodeId int64 `json:"node_id"` + Title string `json:"title"` + Content string `json:"content"` + ContentPinyin string `json:"content_pinyin"` + Image string `json:"image"` + Audio string `json:"audio"` + Character *ElementVO `json:"character"` + InteractionType int `json:"interaction_type"` + Config string `json:"config"` + NodeType int `json:"node_type"` + ResultType int `json:"result_type"` + Options []OptionVO `json:"options"` } type LevelDetailRes struct { - LevelId int64 `json:"level_id"` - Title string `json:"title"` - Scene *ElementVO `json:"scene"` - SceneContent string `json:"scene_content"` - SceneImage string `json:"scene_image"` - SceneAudio string `json:"scene_audio"` - Entry NodeVO `json:"entry"` - TotalFinals int `json:"total_finals"` - Perfect bool `json:"perfect"` - Stars int `json:"stars"` + LevelId int64 `json:"level_id"` + Title string `json:"title"` + Scene *ElementVO `json:"scene"` + SceneContent string `json:"scene_content"` + SceneContentPinyin string `json:"scene_content_pinyin"` + SceneImage string `json:"scene_image"` + SceneAudio string `json:"scene_audio"` + Entry NodeVO `json:"entry"` + TotalFinals int `json:"total_finals"` + Perfect bool `json:"perfect"` + Stars int `json:"stars"` } diff --git a/biz/model/dto/strategy.go b/biz/model/dto/strategy.go index b11bd57..053641a 100644 --- a/biz/model/dto/strategy.go +++ b/biz/model/dto/strategy.go @@ -46,15 +46,17 @@ type LevelBrief struct { } type StrategyDetailRes struct { - StrategyId int64 `json:"strategy_id"` - Name string `json:"name"` - Pinyin string `json:"pinyin"` - Meaning string `json:"meaning"` - GroupName string `json:"group_name"` - TeachContent string `json:"teach_content"` - TeachImage string `json:"teach_image"` - TeachAudio string `json:"teach_audio"` - SummaryQ string `json:"summary_q"` - SummaryOptions string `json:"summary_options"` - Levels []LevelBrief `json:"levels"` + StrategyId int64 `json:"strategy_id"` + Name string `json:"name"` + Pinyin string `json:"pinyin"` + Meaning string `json:"meaning"` + MeaningPinyin string `json:"meaning_pinyin"` + GroupName string `json:"group_name"` + TeachContent string `json:"teach_content"` + TeachContentPinyin string `json:"teach_content_pinyin"` + TeachImage string `json:"teach_image"` + TeachAudio string `json:"teach_audio"` + SummaryQ string `json:"summary_q"` + SummaryOptions string `json:"summary_options"` + Levels []LevelBrief `json:"levels"` } diff --git a/biz/service/level.go b/biz/service/level.go index fd48858..ab5d4bd 100644 --- a/biz/service/level.go +++ b/biz/service/level.go @@ -44,6 +44,7 @@ type Element struct { Id int64 EType int Name string + NamePinyin string Image string Audio string Description string @@ -51,9 +52,12 @@ type Element struct { // Option 分支选项 VO。 type Option struct { - OptionId int64 - Text string - Prop *Element + OptionId int64 + Text string + TextPinyin string + FeedbackPros string + FeedbackCons string + Prop *Element } // Node 关卡节点 VO(决策/终局)。 @@ -61,6 +65,7 @@ type Node struct { NodeId int64 Title string Content string + ContentPinyin string Image string Audio string Character *Element @@ -73,16 +78,17 @@ type Node struct { // LevelDetail 关卡详情:场景 + 入口节点决策树 + 用户进度。 type LevelDetail struct { - LevelId int64 - Title string - Scene *Element - SceneContent string - SceneImage string - SceneAudio string - Entry *Node - TotalFinals int - Perfect bool - Stars int + LevelId int64 + Title string + Scene *Element + SceneContent string + SceneContentPinyin string + SceneImage string + SceneAudio string + Entry *Node + TotalFinals int + Perfect bool + Stars int } // Detail 关卡详情:节点/选项/元素分表取回,内存组装决策树(入口节点)。 @@ -150,16 +156,17 @@ func (s *level) Detail(ctx context.Context, parentUid, childId, levelId int64) ( } return &LevelDetail{ - LevelId: levelRec["id"].Int64(), - Title: levelRec["title"].String(), - Scene: elements[levelRec["scene_id"].Int64()], - SceneContent: levelRec["scene_content"].String(), - SceneImage: levelRec["scene_image"].String(), - SceneAudio: levelRec["scene_audio"].String(), - Entry: buildNode(entryRec, optionRecs, elements), - TotalFinals: totalFinals, - Perfect: progressRec["perfect"].Int() == 1, - Stars: progressRec["stars"].Int(), + LevelId: levelRec["id"].Int64(), + Title: levelRec["title"].String(), + Scene: elements[levelRec["scene_id"].Int64()], + SceneContent: levelRec["scene_content"].String(), + SceneContentPinyin: levelRec["scene_content_pinyin"].String(), + SceneImage: levelRec["scene_image"].String(), + SceneAudio: levelRec["scene_audio"].String(), + Entry: buildNode(entryRec, optionRecs, elements), + TotalFinals: totalFinals, + Perfect: progressRec["perfect"].Int() == 1, + Stars: progressRec["stars"].Int(), }, nil } @@ -192,6 +199,7 @@ func elementsOf(ctx context.Context, levelRec gdb.Record, nodeRecs, optionRecs [ Id: r["id"].Int64(), EType: r["e_type"].Int(), Name: r["name"].String(), + NamePinyin: r["name_pinyin"].String(), Image: r["image"].String(), Audio: r["audio"].String(), Description: r["description"].String(), @@ -206,6 +214,7 @@ func buildNode(nodeRec gdb.Record, optionRecs []gdb.Record, elements map[int64]* NodeId: nodeRec["id"].Int64(), Title: nodeRec["title"].String(), Content: nodeRec["content"].String(), + ContentPinyin: nodeRec["content_pinyin"].String(), Image: nodeRec["image"].String(), Audio: nodeRec["audio"].String(), Character: elements[nodeRec["character_id"].Int64()], @@ -219,9 +228,12 @@ func buildNode(nodeRec gdb.Record, optionRecs []gdb.Record, elements map[int64]* continue } node.Options = append(node.Options, &Option{ - OptionId: o["id"].Int64(), - Text: o["text"].String(), - Prop: elements[o["prop_id"].Int64()], + OptionId: o["id"].Int64(), + Text: o["text"].String(), + TextPinyin: o["text_pinyin"].String(), + FeedbackPros: o["feedback_pros"].String(), + FeedbackCons: o["feedback_cons"].String(), + Prop: elements[o["prop_id"].Int64()], }) } return node diff --git a/biz/service/strategy.go b/biz/service/strategy.go index 2e53b49..d674b33 100644 --- a/biz/service/strategy.go +++ b/biz/service/strategy.go @@ -36,17 +36,19 @@ type StrategyItem struct { // StrategyDetail 计策详情:内容 + 关卡列表(含进度)。 type StrategyDetail struct { - StrategyId int64 - Name string - Pinyin string - Meaning string - GroupName string - TeachContent string - TeachImage string - TeachAudio string - SummaryQ string - SummaryOptions string - Levels []*LevelBrief + StrategyId int64 + Name string + Pinyin string + Meaning string + MeaningPinyin string + GroupName string + TeachContent string + TeachContentPinyin string + TeachImage string + TeachAudio string + SummaryQ string + SummaryOptions string + Levels []*LevelBrief } // LevelBrief 关卡概要:进度 + 解锁 + 内容版本(客户端据此判断可重新挑战)。 @@ -177,16 +179,18 @@ func (s *strategy) Detail(ctx context.Context, parentUid, childId, strategyId in } detail := &StrategyDetail{ - StrategyId: rec["id"].Int64(), - Name: rec["name"].String(), - Pinyin: rec["pinyin"].String(), - Meaning: rec["meaning"].String(), - GroupName: rec["group_name"].String(), - TeachContent: rec["teach_content"].String(), - TeachImage: rec["teach_image"].String(), - TeachAudio: rec["teach_audio"].String(), - SummaryQ: rec["summary_q"].String(), - SummaryOptions: rec["summary_options"].String(), + StrategyId: rec["id"].Int64(), + Name: rec["name"].String(), + Pinyin: rec["pinyin"].String(), + Meaning: rec["meaning"].String(), + MeaningPinyin: rec["meaning_pinyin"].String(), + GroupName: rec["group_name"].String(), + TeachContent: rec["teach_content"].String(), + TeachContentPinyin: rec["teach_content_pinyin"].String(), + TeachImage: rec["teach_image"].String(), + TeachAudio: rec["teach_audio"].String(), + SummaryQ: rec["summary_q"].String(), + SummaryOptions: rec["summary_options"].String(), } for _, lv := range levels { p := progress[lv["id"].Int64()]