feat: ne_config参数配置文件数据解析工具
This commit is contained in:
40
ne_config_parse_tool/ne_config.go
Normal file
40
ne_config_parse_tool/ne_config.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// NeConfig 网元_参数配置可用属性值
|
||||
type NeConfig struct {
|
||||
ID string `json:"id" gorm:"column:id;primaryKey;autoIncrement"`
|
||||
NeType string `gorm:"ne_type"` // 网元类型
|
||||
ParamName string `gorm:"param_name"` // 参数名
|
||||
ParamDisplay string `gorm:"param_display"` // 参数显示名
|
||||
ParamType string `gorm:"param_type"` // 参数类型 list列表单层 array数组多层
|
||||
ParamJson string `gorm:"param_json"` // accesss属性控制:只读read-only/read/ro 读写read-write
|
||||
ParamSort string `gorm:"param_sort"` // 参数排序
|
||||
ParamPerms string `gorm:"param_perms"` // 操作权限 get只读 put可编辑 delete可删除 post可新增
|
||||
UpdateTime int64 `gorm:"update_time"` // 更新时间
|
||||
}
|
||||
|
||||
// TableName 表名称
|
||||
func (*NeConfig) TableName() string {
|
||||
return "ne_config"
|
||||
}
|
||||
|
||||
// Save 表插入或更新
|
||||
func (s *NeConfig) Save() string {
|
||||
db := connDB()
|
||||
// 检查是否存在
|
||||
var id string
|
||||
db.Raw("SELECT id FROM ne_config WHERE ne_type = ? AND param_name = ?", s.NeType, s.ParamName).Scan(&id)
|
||||
// 更新时间
|
||||
s.UpdateTime = time.Now().UnixMilli()
|
||||
if id != "" {
|
||||
s.ID = id
|
||||
db.Save(s)
|
||||
} else {
|
||||
db.Create(s)
|
||||
}
|
||||
return s.ID
|
||||
}
|
||||
Reference in New Issue
Block a user