From 8e20a049a445d6394b71140262fa97aba899d5e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?walker-sheng=E2=80=9D?= Date: Tue, 2 Jul 2024 18:34:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=97=E4=BD=99=E4=BB=A3=E7=A0=81=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- repo/repo.go | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/repo/repo.go b/repo/repo.go index d3a0e20..1c9a0a3 100644 --- a/repo/repo.go +++ b/repo/repo.go @@ -174,38 +174,28 @@ func NewLinkNodeAndLinkAndBuildLinkship(ta model.Turnout, tap model.PipePort, tb nodeb = repo1.getOrBuildLinkNode(tb) pla = nil plb = model.NewPipeLink(nodeb, tbp) - exist, link = repo1.isLinkExist(pla, plb) - if exist { - return - } - link = model.NewLink(pla, plb) - link.SetLinkedElement(model.PipePortB, plb) - nodeb.SetLinkedElement(tbp, model.NewPipeLink(link, model.PipePortB)) } else if tb == nil { nodea = repo1.getOrBuildLinkNode(ta) nodeb = nil pla = model.NewPipeLink(nodea, tap) plb = nil - exist, link = repo1.isLinkExist(pla, plb) - if exist { - return - } - link = model.NewLink(pla, plb) - link.SetLinkedElement(model.PipePortA, pla) - nodea.SetLinkedElement(tap, model.NewPipeLink(link, model.PipePortA)) } else { nodea = repo1.getOrBuildLinkNode(ta) nodeb = repo1.getOrBuildLinkNode(tb) pla = model.NewPipeLink(nodea, tap) plb = model.NewPipeLink(nodeb, tbp) - exist, link = repo1.isLinkExist(pla, plb) - if exist { - return - } - link = model.NewLink(pla, plb) - link.SetLinkedElement(model.PipePortA, pla) - link.SetLinkedElement(model.PipePortB, plb) + } + exist, link = repo1.isLinkExist(pla, plb) + if exist { + return + } + link = model.NewLink(pla, plb) + link.SetLinkedElement(model.PipePortA, pla) + link.SetLinkedElement(model.PipePortB, plb) + if nodea != nil { nodea.SetLinkedElement(tap, model.NewPipeLink(link, model.PipePortA)) + } + if nodeb != nil { nodeb.SetLinkedElement(tbp, model.NewPipeLink(link, model.PipePortB)) } return