fix: 网元软件包新增找到已存在的删除后重新添加
This commit is contained in:
@@ -69,15 +69,26 @@ func (s *NeSoftwareController) Add(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 检查属性值唯一
|
||||
uniqueSoftware := s.neSoftwareService.CheckUniqueTypeAndNameAndVersion(body.NeType, body.Name, body.Version, "")
|
||||
if !uniqueSoftware {
|
||||
// 网元软件包操作【%s】失败,网元类型与文件名版本已存在
|
||||
msg := i18n.TTemplate(language, "neSoftware.errKeyExists", map[string]any{"name": body.Name})
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
// 找到已存在的删除后重新添加
|
||||
neSoftwares := s.neSoftwareService.SelectList(model.NeSoftware{
|
||||
NeType: body.NeType,
|
||||
Name: body.Name,
|
||||
Version: body.Version,
|
||||
})
|
||||
if len(neSoftwares) > 0 {
|
||||
neSoftware := neSoftwares[0]
|
||||
s.neSoftwareService.DeleteByIds([]string{neSoftware.ID})
|
||||
}
|
||||
|
||||
// 检查属性值唯一
|
||||
// uniqueSoftware := s.neSoftwareService.CheckUniqueTypeAndNameAndVersion(body.NeType, body.Name, body.Version, "")
|
||||
// if !uniqueSoftware {
|
||||
// // 网元软件包操作【%s】失败,网元类型与文件名版本已存在
|
||||
// msg := i18n.TTemplate(language, "neSoftware.errKeyExists", map[string]any{"name": body.Name})
|
||||
// c.JSON(200, result.ErrMsg(msg))
|
||||
// return
|
||||
// }
|
||||
|
||||
body.CreateBy = ctx.LoginUserToUserName(c)
|
||||
insertId := s.neSoftwareService.Insert(body)
|
||||
if insertId != "" {
|
||||
|
||||
@@ -71,14 +71,14 @@ func (r *NeSoftwareImpl) Update(neSoftware model.NeSoftware) int64 {
|
||||
if rows > 0 {
|
||||
// 更新同类型的新包版本
|
||||
neVersions := NewNeVersionImpl.SelectList(model.NeVersion{
|
||||
NeType: neSoftware.NeType,
|
||||
NewPath: neSoftware.Path,
|
||||
Status: "3",
|
||||
NeType: neSoftware.NeType,
|
||||
Status: "3",
|
||||
})
|
||||
if len(neVersions) > 0 {
|
||||
for _, neVersion := range neVersions {
|
||||
neVersion.NewName = neSoftware.Name
|
||||
neVersion.NewVersion = neSoftware.Version
|
||||
neVersion.NewPath = neSoftware.Path
|
||||
neVersion.Status = "3"
|
||||
neVersion.UpdateBy = neSoftware.UpdateBy
|
||||
NewNeVersionImpl.Update(neVersion)
|
||||
|
||||
Reference in New Issue
Block a user