feat: 网元软件包设为网元新版本的更新接口
This commit is contained in:
@@ -162,6 +162,36 @@ func (s *NeSoftwareController) Remove(c *gin.Context) {
|
||||
c.JSON(200, result.OkMsg(msg))
|
||||
}
|
||||
|
||||
// 网元软件包设为网元新版本
|
||||
//
|
||||
// POST /newNeVersion
|
||||
func (s *NeSoftwareController) NewNeVersion(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var body model.NeSoftware
|
||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||
if err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
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.UpdateVersions(neSoftware, model.NeVersion{
|
||||
NeType: neSoftware.NeType,
|
||||
UpdateBy: ctx.LoginUserToUserName(c),
|
||||
})
|
||||
c.JSON(200, result.Ok(nil))
|
||||
return
|
||||
}
|
||||
c.JSON(200, result.Err(nil))
|
||||
}
|
||||
|
||||
// 网元软件包安装
|
||||
//
|
||||
// POST /install
|
||||
|
||||
@@ -25,6 +25,9 @@ type INeSoftware interface {
|
||||
// CheckUniqueTypeAndNameAndVersion 校验网元类型和文件名版本是否唯一
|
||||
CheckUniqueTypeAndNameAndVersion(neType, name, version, id string) bool
|
||||
|
||||
// UpdateVersions 更新软件包对应网元的新版本
|
||||
UpdateVersions(neSoftware model.NeSoftware, neVersion model.NeVersion) int64
|
||||
|
||||
// InstallToNeHost 安装包上传到网元主机执行安装命令
|
||||
InstallToNeHost(neSoftware model.NeSoftware, preinput map[string]string) (string, error)
|
||||
}
|
||||
|
||||
@@ -127,6 +127,24 @@ func (r *NeSoftwareImpl) CheckUniqueTypeAndNameAndVersion(neType, name, version,
|
||||
return uniqueId == ""
|
||||
}
|
||||
|
||||
// UpdateVersions 更新软件包对应网元的新版本
|
||||
func (r *NeSoftwareImpl) UpdateVersions(neSoftware model.NeSoftware, neVersion model.NeVersion) int64 {
|
||||
var rows int64 = 0
|
||||
// 更新同类型的新包版本
|
||||
neVersions := NewNeVersionImpl.SelectList(neVersion)
|
||||
if len(neVersions) > 0 {
|
||||
for _, v := range neVersions {
|
||||
v.NewName = neSoftware.Name
|
||||
v.NewVersion = neSoftware.Version
|
||||
v.NewPath = neSoftware.Path
|
||||
v.Status = "3"
|
||||
v.UpdateBy = neVersion.UpdateBy
|
||||
rows += NewNeVersionImpl.Update(v)
|
||||
}
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
// InstallToNeHost 安装包上传到网元主机执行安装命令
|
||||
func (r *NeSoftwareImpl) InstallToNeHost(neSoftware model.NeSoftware, preinput map[string]string) (string, error) {
|
||||
// 检查文件是否存在
|
||||
|
||||
Reference in New Issue
Block a user