From 9690778945b968fcb6d1c6e99fed04df5e141565 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Mon, 18 Mar 2024 11:20:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BD=91=E5=85=83=E8=BD=AF=E4=BB=B6?= =?UTF-8?q?=E5=8C=85=E6=9F=A5=E8=AF=A2=E6=94=AF=E6=8C=81=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=89=88=E6=9C=AC=E5=92=8C=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../network_element/repository/ne_software.impl.go | 4 ++++ src/modules/network_element/service/ne_software.go | 3 +++ .../network_element/service/ne_software.impl.go | 12 ++++++++++++ 3 files changed, 19 insertions(+) diff --git a/src/modules/network_element/repository/ne_software.impl.go b/src/modules/network_element/repository/ne_software.impl.go index 835ca51a..3116b52e 100644 --- a/src/modules/network_element/repository/ne_software.impl.go +++ b/src/modules/network_element/repository/ne_software.impl.go @@ -125,6 +125,10 @@ func (r *NeSoftwareImpl) SelectList(neSoftware model.NeSoftware) []model.NeSoftw conditions = append(conditions, "ne_type = ?") params = append(params, neSoftware.NeType) } + if neSoftware.Path != "" { + conditions = append(conditions, "path = ?") + params = append(params, neSoftware.Path) + } if neSoftware.Version != "" { conditions = append(conditions, "version = ?") params = append(params, neSoftware.Version) diff --git a/src/modules/network_element/service/ne_software.go b/src/modules/network_element/service/ne_software.go index 3f9160a3..c4936ac2 100644 --- a/src/modules/network_element/service/ne_software.go +++ b/src/modules/network_element/service/ne_software.go @@ -22,6 +22,9 @@ type INeSoftware interface { // DeleteByIds 批量删除信息 DeleteByIds(ids []string) (int64, error) + // SelectByVersionAndPath 通过文件版本和路径查询 + SelectByVersionAndPath(version, path string) model.NeSoftware + // CheckUniqueTypeAndFileNameAndVersion 校验网元类型和文件名版本是否唯一 CheckUniqueTypeAndFileNameAndVersion(neType, fileName, version, id string) bool diff --git a/src/modules/network_element/service/ne_software.impl.go b/src/modules/network_element/service/ne_software.impl.go index 3a6409a5..9978f4bf 100644 --- a/src/modules/network_element/service/ne_software.impl.go +++ b/src/modules/network_element/service/ne_software.impl.go @@ -66,6 +66,18 @@ func (r *NeSoftwareImpl) DeleteByIds(ids []string) (int64, error) { return 0, fmt.Errorf("delete fail") } +// SelectByVersionAndPath 通过文件版本和路径查询 +func (r *NeSoftwareImpl) SelectByVersionAndPath(version, path string) model.NeSoftware { + neSoftwares := r.neSoftwareRepository.SelectList(model.NeSoftware{ + Version: version, + Path: path, + }) + if len(neSoftwares) > 0 { + return neSoftwares[0] + } + return model.NeSoftware{} +} + // CheckUniqueTypeAndFileNameAndVersion 校验网元类型和文件名版本是否唯一 func (r *NeSoftwareImpl) CheckUniqueTypeAndFileNameAndVersion(neType, fileName, version, id string) bool { uniqueId := r.neSoftwareRepository.CheckUniqueTypeAndFileNameAndVersion(model.NeSoftware{