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{