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 != "" {
|
||||
|
||||
Reference in New Issue
Block a user