feat: 新增网元端公共配置文件读写接口

This commit is contained in:
TsMask
2024-04-16 19:40:29 +08:00
parent 4c37968925
commit 07f6b9c31a
9 changed files with 145 additions and 5 deletions

View File

@@ -184,7 +184,7 @@ func (s *NeInfoController) ConfigFileWrite(c *gin.Context) {
Content any `json:"content" binding:"required"` // 内容
Sync bool `json:"sync"` // 同步到网元
}
if err := c.ShouldBindJSON(&body); err != nil {
if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil {
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
return
}
@@ -204,6 +204,38 @@ func (s *NeInfoController) ConfigFileWrite(c *gin.Context) {
c.JSON(200, result.Ok(nil))
}
// 网元端公共配置文件读取
//
// GET /para5GFile
func (s *NeInfoController) Para5GFileRead(c *gin.Context) {
fileType := c.Query("fileType")
data := s.neInfoService.NeConfPara5GRead(fileType)
c.JSON(200, result.OkData(data))
}
// 网元端公共配置文件写入
//
// PUT /para5GFile
func (s *NeInfoController) Para5GFileWrite(c *gin.Context) {
language := ctx.AcceptLanguage(c)
var body struct {
FileType string `json:"fileType" binding:"oneof='' txt json yaml yml"` // 解析内容数据到对应文件类型
Content any `json:"content" binding:"required"` // 内容
SyncNE []string `json:"syncNe"` // 同步到网元
}
if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil {
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
return
}
err := s.neInfoService.NeConfPara5GWirte(body.FileType, body.Content, body.SyncNE)
if err != nil {
c.JSON(200, result.ErrMsg(err.Error()))
return
}
c.JSON(200, result.Ok(nil))
}
// 网元信息列表
//
// GET /list