feat: 网元软件接口安装接口
This commit is contained in:
@@ -70,8 +70,8 @@ func (s *NeSoftwareController) Add(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 检查属性值唯一
|
||||
uniqueVersion := s.neSoftwareService.CheckUniqueTypeAndFileNameAndVersion(body.NeType, body.FileName, body.Version, "")
|
||||
if !uniqueVersion {
|
||||
uniqueSoftware := s.neSoftwareService.CheckUniqueTypeAndFileNameAndVersion(body.NeType, body.FileName, body.Version, "")
|
||||
if !uniqueSoftware {
|
||||
// 网元软件包操作【%s】失败,网元类型与文件名版本已存在
|
||||
msg := i18n.TTemplate(language, "neSoftware.errKeyExists", map[string]any{"name": body.FileName})
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
@@ -99,8 +99,8 @@ func (s *NeSoftwareController) Edit(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 检查属性值唯一
|
||||
uniqueVersion := s.neSoftwareService.CheckUniqueTypeAndFileNameAndVersion(body.NeType, body.FileName, body.Version, body.ID)
|
||||
if !uniqueVersion {
|
||||
uniqueSoftware := s.neSoftwareService.CheckUniqueTypeAndFileNameAndVersion(body.NeType, body.FileName, body.Version, body.ID)
|
||||
if !uniqueSoftware {
|
||||
// 网元软件包操作【%s】失败,网元类型与文件名版本已存在
|
||||
msg := i18n.TTemplate(language, "neSoftware.errKeyExists", map[string]any{"name": body.FileName})
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
@@ -148,3 +148,33 @@ func (s *NeSoftwareController) Remove(c *gin.Context) {
|
||||
msg := i18n.TTemplate(language, "app.common.deleteSuccess", map[string]any{"num": rows})
|
||||
c.JSON(200, result.OkMsg(msg))
|
||||
}
|
||||
|
||||
// 网元软件包安装
|
||||
//
|
||||
// POST /install
|
||||
func (s *NeSoftwareController) Install(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(body)
|
||||
if len(neSoftwares) == 0 {
|
||||
// 没有可访问网元版本数据!
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "neSoftware.noData")))
|
||||
return
|
||||
}
|
||||
neSoftware := neSoftwares[0]
|
||||
|
||||
// 进行安装
|
||||
output, err := s.neSoftwareService.Install(neSoftware)
|
||||
if err != nil {
|
||||
c.JSON(200, result.OkData(output))
|
||||
return
|
||||
}
|
||||
c.JSON(200, result.Err(nil))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user