merge: 合并OMC分支

This commit is contained in:
TsMask
2024-07-10 14:18:48 +08:00
parent 17c0011c6b
commit 625ed57a50
260 changed files with 9167 additions and 14857 deletions

View File

@@ -19,15 +19,15 @@ var NewNeSoftware = &NeSoftwareController{
neSoftwareService: neService.NewNeSoftwareImpl,
}
// 网元软件包信息请求
// 网元软件包请求
//
// PATH /software
type NeSoftwareController struct {
// 网元软件包信息服务
// 网元软件包服务
neSoftwareService neService.INeSoftware
}
// 网元软件包信息列表
// 网元软件包列表
//
// GET /list
func (s *NeSoftwareController) List(c *gin.Context) {
@@ -37,7 +37,7 @@ func (s *NeSoftwareController) List(c *gin.Context) {
c.JSON(200, result.Ok(data))
}
// 网元软件包信息信息
// 网元软件包信息
//
// GET /:softwareId
func (s *NeSoftwareController) Info(c *gin.Context) {
@@ -50,7 +50,7 @@ func (s *NeSoftwareController) Info(c *gin.Context) {
neSoftware := s.neSoftwareService.SelectById(softwareId)
if neSoftware.ID != softwareId {
// 没有可访问网元版本数据!
// 没有可访问网元包信息数据!
c.JSON(200, result.ErrMsg(i18n.TKey(language, "neSoftware.noData")))
return
}
@@ -58,27 +58,39 @@ func (s *NeSoftwareController) Info(c *gin.Context) {
c.JSON(200, result.OkData(neSoftware))
}
// 网元软件包信息新增
// 网元软件包新增
//
// POST /
func (s *NeSoftwareController) Add(c *gin.Context) {
language := ctx.AcceptLanguage(c)
var body model.NeSoftware
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.ID != "" {
if err != nil || body.Path == "" || body.ID != "" {
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
return
}
// 检查属性值唯一
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))
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 != "" {
c.JSON(200, result.Ok(nil))
@@ -87,23 +99,23 @@ func (s *NeSoftwareController) Add(c *gin.Context) {
c.JSON(200, result.Err(nil))
}
// 网元软件包信息修改
// 网元软件包修改
//
// PUT /
func (s *NeSoftwareController) Edit(c *gin.Context) {
language := ctx.AcceptLanguage(c)
var body model.NeSoftware
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.ID == "" {
if err != nil || body.Path == "" || body.ID == "" {
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
return
}
// 检查属性值唯一
uniqueSoftware := s.neSoftwareService.CheckUniqueTypeAndFileNameAndVersion(body.NeType, body.FileName, body.Version, body.ID)
uniqueSoftware := s.neSoftwareService.CheckUniqueTypeAndNameAndVersion(body.NeType, body.Name, body.Version, body.ID)
if !uniqueSoftware {
// 网元软件包操作【%s】失败网元类型与文件名版本已存在
msg := i18n.TTemplate(language, "neSoftware.errKeyExists", map[string]any{"name": body.FileName})
msg := i18n.TTemplate(language, "neSoftware.errKeyExists", map[string]any{"name": body.Name})
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -111,11 +123,12 @@ func (s *NeSoftwareController) Edit(c *gin.Context) {
// 检查是否存在
neSoftware := s.neSoftwareService.SelectById(body.ID)
if neSoftware.ID != body.ID {
// 没有可访问网元版本数据!
// 没有可访问网元包信息数据!
c.JSON(200, result.ErrMsg(i18n.TKey(language, "neSoftware.noData")))
return
}
body.UpdateBy = ctx.LoginUserToUserName(c)
rows := s.neSoftwareService.Update(body)
if rows > 0 {
c.JSON(200, result.Ok(nil))
@@ -124,7 +137,7 @@ func (s *NeSoftwareController) Edit(c *gin.Context) {
c.JSON(200, result.Err(nil))
}
// 网元软件包信息删除
// 网元软件包删除
//
// DELETE /:softwareIds
func (s *NeSoftwareController) Remove(c *gin.Context) {
@@ -150,10 +163,10 @@ func (s *NeSoftwareController) Remove(c *gin.Context) {
c.JSON(200, result.OkMsg(msg))
}
// 网元软件包安装
// 网元软件包设为网元新版本
//
// POST /install
func (s *NeSoftwareController) Install(c *gin.Context) {
// POST /newNeVersion
func (s *NeSoftwareController) NewNeVersion(c *gin.Context) {
language := ctx.AcceptLanguage(c)
var body model.NeSoftware
err := c.ShouldBindBodyWith(&body, binding.JSON)
@@ -162,19 +175,19 @@ func (s *NeSoftwareController) Install(c *gin.Context) {
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))
// 找到已存在的软件包信息
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))