1
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
|
||||
"36wisdom/biz/model/dto"
|
||||
"36wisdom/biz/service"
|
||||
)
|
||||
|
||||
type nodeOption struct{}
|
||||
|
||||
var NodeOption = &nodeOption{}
|
||||
|
||||
func (c *nodeOption) Get(ctx context.Context, req *dto.NodeOptionGetReq) (*dto.NodeOptionGetRes, error) {
|
||||
rec, err := service.NodeOption.GetInNode(ctx, req.OptionId, req.NodeId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res := &dto.NodeOptionGetRes{}
|
||||
if !rec.IsEmpty() {
|
||||
res.NodeOption = nodeOptionItem(rec)
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (c *nodeOption) ListByNode(ctx context.Context, req *dto.NodeOptionListReq) (*dto.NodeOptionListRes, error) {
|
||||
recs, err := service.NodeOption.ListEnabledByNode(ctx, req.NodeId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res := &dto.NodeOptionListRes{List: make([]dto.NodeOptionItem, 0, len(recs))}
|
||||
for _, r := range recs {
|
||||
res.List = append(res.List, nodeOptionItem(r))
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func nodeOptionItem(r gdb.Record) dto.NodeOptionItem {
|
||||
return dto.NodeOptionItem{
|
||||
Id: r["id"].Int64(),
|
||||
NodeId: r["node_id"].Int64(),
|
||||
Text: r["text"].String(),
|
||||
PropId: r["prop_id"].Int64(),
|
||||
Audio: r["audio"].String(),
|
||||
NextNodeId: r["next_node_id"].Int64(),
|
||||
Feedback: r["feedback"].String(),
|
||||
FeedbackAudio: r["feedback_audio"].String(),
|
||||
SortOrder: r["sort_order"].Int(),
|
||||
Status: r["status"].Int(),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user