feat: 网元软件包查询支持通过文件版本和路径查询

This commit is contained in:
TsMask
2024-03-18 11:20:57 +08:00
parent f43b551e9d
commit fd3390e0a3
3 changed files with 19 additions and 0 deletions

View File

@@ -125,6 +125,10 @@ func (r *NeSoftwareImpl) SelectList(neSoftware model.NeSoftware) []model.NeSoftw
conditions = append(conditions, "ne_type = ?") conditions = append(conditions, "ne_type = ?")
params = append(params, neSoftware.NeType) params = append(params, neSoftware.NeType)
} }
if neSoftware.Path != "" {
conditions = append(conditions, "path = ?")
params = append(params, neSoftware.Path)
}
if neSoftware.Version != "" { if neSoftware.Version != "" {
conditions = append(conditions, "version = ?") conditions = append(conditions, "version = ?")
params = append(params, neSoftware.Version) params = append(params, neSoftware.Version)

View File

@@ -22,6 +22,9 @@ type INeSoftware interface {
// DeleteByIds 批量删除信息 // DeleteByIds 批量删除信息
DeleteByIds(ids []string) (int64, error) DeleteByIds(ids []string) (int64, error)
// SelectByVersionAndPath 通过文件版本和路径查询
SelectByVersionAndPath(version, path string) model.NeSoftware
// CheckUniqueTypeAndFileNameAndVersion 校验网元类型和文件名版本是否唯一 // CheckUniqueTypeAndFileNameAndVersion 校验网元类型和文件名版本是否唯一
CheckUniqueTypeAndFileNameAndVersion(neType, fileName, version, id string) bool CheckUniqueTypeAndFileNameAndVersion(neType, fileName, version, id string) bool

View File

@@ -66,6 +66,18 @@ func (r *NeSoftwareImpl) DeleteByIds(ids []string) (int64, error) {
return 0, fmt.Errorf("delete fail") 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 校验网元类型和文件名版本是否唯一 // CheckUniqueTypeAndFileNameAndVersion 校验网元类型和文件名版本是否唯一
func (r *NeSoftwareImpl) CheckUniqueTypeAndFileNameAndVersion(neType, fileName, version, id string) bool { func (r *NeSoftwareImpl) CheckUniqueTypeAndFileNameAndVersion(neType, fileName, version, id string) bool {
uniqueId := r.neSoftwareRepository.CheckUniqueTypeAndFileNameAndVersion(model.NeSoftware{ uniqueId := r.neSoftwareRepository.CheckUniqueTypeAndFileNameAndVersion(model.NeSoftware{