feat(goals): 总览新增目标管理(增/删/改),同步通知 planner 并复活任务
- 总览页新增「目标管理」卡片,支持人工查看/新增/修改/删除目标 - 新增/修改:通知 planner(新增了目标/由 old 变为 new)并复活任务 - 删除:硬删除 goal 节点(级联删边/锚点),通知 planner,不复活任务 - 无 schema 变更:目标仍存 exploration_nodes(kind='goal'),仅加查询方法
This commit is contained in:
1 parent
025e1ce445
commit
d28ecd67fe
9 files changed
+506
-2
No files matched your search
@@ -173,6 +173,41 @@ func taskNodeDTO(n *db.Node) TaskNodeDTO {
|
||||
return d
|
||||
}
|
||||
|
||||
// GoalDTO is a goal node with its payload unpacked into text/vulnclass — the shape
|
||||
// the 总览「目标管理」UI works with (vs TaskNodeDTO which carries raw payload JSON).
|
||||
type GoalDTO struct {
|
||||
ID string `json:"id"`
|
||||
Text string `json:"text"`
|
||||
VulnClass string `json:"vulnclass,omitempty"`
|
||||
State string `json:"state"`
|
||||
Origin string `json:"origin,omitempty"`
|
||||
TS string `json:"ts"`
|
||||
}
|
||||
|
||||
func goalDTO(n *db.Node) GoalDTO {
|
||||
var p struct {
|
||||
Text string `json:"text"`
|
||||
VulnClass string `json:"vulnclass"`
|
||||
}
|
||||
_ = json.Unmarshal(n.Payload, &p)
|
||||
return GoalDTO{
|
||||
ID: i64s(n.ID),
|
||||
Text: p.Text,
|
||||
VulnClass: p.VulnClass,
|
||||
State: n.State,
|
||||
Origin: n.Origin,
|
||||
TS: rfc3339(n.CreatedAt),
|
||||
}
|
||||
}
|
||||
|
||||
func goalDTOs(in []*db.Node) []GoalDTO {
|
||||
out := make([]GoalDTO, 0, len(in))
|
||||
for _, n := range in {
|
||||
out = append(out, goalDTO(n))
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func taskNodeDTOs(in []*db.Node) []TaskNodeDTO {
|
||||
out := make([]TaskNodeDTO, 0, len(in))
|
||||
for _, n := range in {
|
||||
|
||||
Reference in new issue
Block a user