feat: 网元参数配置数据j功能接口
This commit is contained in:
@@ -132,16 +132,16 @@ func (s *NeConfigController) Edit(c *gin.Context) {
|
||||
|
||||
// 网元参数配置可用属性值删除
|
||||
//
|
||||
// DELETE /:ids
|
||||
// DELETE /
|
||||
func (s *NeConfigController) Remove(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
ids := c.Param("ids")
|
||||
if ids == "" {
|
||||
id, okId := c.GetQuery("id")
|
||||
if id == "" || !okId {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
// 处理字符转id数组后去重
|
||||
idsArr := strings.Split(ids, ",")
|
||||
idsArr := strings.Split(id, ",")
|
||||
uniqueIDs := parse.RemoveDuplicates(idsArr)
|
||||
if len(uniqueIDs) <= 0 {
|
||||
c.JSON(200, result.Err(nil))
|
||||
@@ -173,26 +173,26 @@ func (s *NeConfigController) ListByNeType(c *gin.Context) {
|
||||
// 网元参数配置数据信息
|
||||
//
|
||||
// GET /data
|
||||
func (s *NeConfigController) Data(c *gin.Context) {
|
||||
func (s *NeConfigController) DataInfo(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var querys struct {
|
||||
var query struct {
|
||||
NeType string `form:"neType" binding:"required"` // 网元类型
|
||||
NeId string `form:"neId" binding:"required"` // 网元ID
|
||||
ParamName string `form:"paramName" binding:"required"` // 可用属性
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
|
||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(querys.NeType, querys.NeId)
|
||||
if neInfo.NeId != querys.NeId || neInfo.IP == "" {
|
||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(query.NeType, query.NeId)
|
||||
if neInfo.NeId != query.NeId || neInfo.IP == "" {
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
|
||||
// 网元直连
|
||||
resData, err := neFetchlink.NeConfigInfo(neInfo, querys.ParamName)
|
||||
resData, err := neFetchlink.NeConfigInfo(neInfo, query.ParamName)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
@@ -200,3 +200,116 @@ func (s *NeConfigController) Data(c *gin.Context) {
|
||||
|
||||
c.JSON(200, result.Ok(resData))
|
||||
}
|
||||
|
||||
// 网元参数配置数据修改
|
||||
//
|
||||
// PUT /data
|
||||
func (s *NeConfigController) DataEdit(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var body struct {
|
||||
NeType string `json:"neType" binding:"required"` // 网元类型
|
||||
NeId string `json:"neId" binding:"required"` // 网元ID
|
||||
ParamName string `json:"paramName" binding:"required"`
|
||||
ParamData map[string]any `json:"paramData" binding:"required"`
|
||||
}
|
||||
if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
|
||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
|
||||
if neInfo.NeId != body.NeId || neInfo.IP == "" {
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
|
||||
// 网元直连
|
||||
resData, err := neFetchlink.NeConfigInfoEdit(neInfo, body.ParamName, body.ParamData)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
c.JSON(200, result.Ok(resData))
|
||||
}
|
||||
|
||||
// 网元参数配置数据新增(array)
|
||||
//
|
||||
// POST /data
|
||||
func (s *NeConfigController) DataAdd(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var body struct {
|
||||
NeType string `json:"neType" binding:"required"` // 网元类型
|
||||
NeId string `json:"neId" binding:"required"` // 网元ID
|
||||
ParamName string `json:"paramName" binding:"required"`
|
||||
ParamData map[string]any `json:"paramData" binding:"required"`
|
||||
}
|
||||
if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否array
|
||||
info := s.neConfigService.SelectNeConfigByNeTypeAndParamName(body.NeType, body.ParamName)
|
||||
if info.ParamType != "array" {
|
||||
c.JSON(400, result.CodeMsg(400, "this attribute does not support adding"))
|
||||
return
|
||||
}
|
||||
// 必须含有index
|
||||
_, idxOk := body.ParamData["index"]
|
||||
if info.ParamType == "array" && !idxOk {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
|
||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
|
||||
if neInfo.NeId != body.NeId || neInfo.IP == "" {
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
|
||||
// 网元直连
|
||||
resData, err := neFetchlink.NeConfigInfoAdd(neInfo, body.ParamName, body.ParamData)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
c.JSON(200, result.Ok(resData))
|
||||
}
|
||||
|
||||
// 网元参数配置数据删除(array)
|
||||
//
|
||||
// DELETE /data
|
||||
func (s *NeConfigController) DataRemove(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
NeType string `form:"neType" binding:"required"` // 网元类型
|
||||
NeId string `form:"neId" binding:"required"` // 网元ID
|
||||
ParamName string `form:"paramName" binding:"required"`
|
||||
Index string `form:"index" binding:"required"`
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否array
|
||||
info := s.neConfigService.SelectNeConfigByNeTypeAndParamName(query.NeType, query.ParamName)
|
||||
if info.ParamType != "array" {
|
||||
c.JSON(400, result.CodeMsg(400, "this attribute does not support adding"))
|
||||
return
|
||||
}
|
||||
|
||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(query.NeType, query.NeId)
|
||||
if neInfo.NeId != query.NeId || neInfo.IP == "" {
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
|
||||
// 网元直连
|
||||
resData, err := neFetchlink.NeConfigInfoDel(neInfo, query.ParamName, query.Index)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
c.JSON(200, result.Ok(resData))
|
||||
}
|
||||
|
||||
@@ -260,6 +260,7 @@ func Setup(router *gin.Engine) {
|
||||
// 网元参数配置
|
||||
neConfigGroup := neGroup.Group("/config")
|
||||
{
|
||||
// 网元参数配置可用属性值
|
||||
neConfigGroup.GET("/list",
|
||||
middleware.PreAuthorize(nil),
|
||||
controller.NewNeConfig.List,
|
||||
@@ -278,7 +279,7 @@ func Setup(router *gin.Engine) {
|
||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.neConfig", collectlogs.BUSINESS_TYPE_UPDATE)),
|
||||
controller.NewNeConfig.Edit,
|
||||
)
|
||||
neConfigGroup.DELETE("/:ids",
|
||||
neConfigGroup.DELETE("",
|
||||
middleware.PreAuthorize(nil),
|
||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.neConfig", collectlogs.BUSINESS_TYPE_DELETE)),
|
||||
controller.NewNeConfig.Remove,
|
||||
@@ -287,9 +288,25 @@ func Setup(router *gin.Engine) {
|
||||
middleware.PreAuthorize(nil),
|
||||
controller.NewNeConfig.ListByNeType,
|
||||
)
|
||||
// 网元参数配置数据
|
||||
neConfigGroup.GET("/data",
|
||||
middleware.PreAuthorize(nil),
|
||||
controller.NewNeConfig.Data,
|
||||
controller.NewNeConfig.DataInfo,
|
||||
)
|
||||
neConfigGroup.PUT("/data",
|
||||
middleware.PreAuthorize(nil),
|
||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.neConfig", collectlogs.BUSINESS_TYPE_UPDATE)),
|
||||
controller.NewNeConfig.DataEdit,
|
||||
)
|
||||
neConfigGroup.POST("/data",
|
||||
middleware.PreAuthorize(nil),
|
||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.neConfig", collectlogs.BUSINESS_TYPE_INSERT)),
|
||||
controller.NewNeConfig.DataAdd,
|
||||
)
|
||||
neConfigGroup.DELETE("/data",
|
||||
middleware.PreAuthorize(nil),
|
||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.neConfig", collectlogs.BUSINESS_TYPE_DELETE)),
|
||||
controller.NewNeConfig.DataRemove,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@ type INeConfig interface {
|
||||
// SelectNeConfigByNeType 查询网元类型参数配置
|
||||
SelectNeConfigByNeType(neType string) []model.NeConfig
|
||||
|
||||
// SelectNeConfigByNeTypeAndParamName 查询网元类型参数配置By参数名
|
||||
SelectNeConfigByNeTypeAndParamName(neType, paramName string) model.NeConfig
|
||||
|
||||
// SelectNeHostPage 分页查询列表数据
|
||||
SelectPage(query map[string]any) map[string]any
|
||||
|
||||
|
||||
@@ -102,6 +102,19 @@ func (r *NeConfigImpl) SelectNeConfigByNeType(neType string) []model.NeConfig {
|
||||
return neConfigList
|
||||
}
|
||||
|
||||
// SelectNeConfigByNeTypeAndParamName 查询网元类型参数配置By参数名
|
||||
func (r *NeConfigImpl) SelectNeConfigByNeTypeAndParamName(neType, paramName string) model.NeConfig {
|
||||
neConfigList := r.SelectNeConfigByNeType(neType)
|
||||
var neConfig model.NeConfig
|
||||
for _, v := range neConfigList {
|
||||
if v.ParamName == paramName {
|
||||
neConfig = v
|
||||
break
|
||||
}
|
||||
}
|
||||
return neConfig
|
||||
}
|
||||
|
||||
// SelectNeHostPage 分页查询列表数据
|
||||
func (r *NeConfigImpl) SelectPage(query map[string]any) map[string]any {
|
||||
return r.neConfigRepository.SelectPage(query)
|
||||
|
||||
Reference in New Issue
Block a user