feat: 网元_参数配置可用属性值缓存并支持数据修改的功能接口
This commit is contained in:
@@ -2,6 +2,7 @@ package repository
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"be.ems/src/framework/datasource"
|
||||
"be.ems/src/framework/logger"
|
||||
@@ -12,18 +13,18 @@ import (
|
||||
|
||||
// NewNeConfigImpl 网元参数配置可用属性值 实例化数据层
|
||||
var NewNeConfigImpl = &NeConfigImpl{
|
||||
selectSql: `select
|
||||
id, ne_type, ne_id, top_tag, top_display, method, param_json
|
||||
from param_config`,
|
||||
selectSql: `select id, ne_type, param_name, param_display, param_type, param_json, param_sort, param_perms, update_time from ne_config`,
|
||||
|
||||
resultMap: map[string]string{
|
||||
"id": "ID",
|
||||
"ne_type": "NeType",
|
||||
"ne_id": "NeId",
|
||||
"top_tag": "TopTag",
|
||||
"top_display": "TopDisplay",
|
||||
"method": "Method",
|
||||
"param_json": "ParamJSONStr",
|
||||
"id": "ID",
|
||||
"ne_type": "NeType",
|
||||
"param_name": "ParamName",
|
||||
"param_display": "ParamDisplay",
|
||||
"param_type": "ParamType",
|
||||
"param_json": "ParamJson",
|
||||
"param_sort": "ParamSort",
|
||||
"param_perms": "ParamPerms",
|
||||
"update_time": "UpdateTime",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -59,8 +60,8 @@ func (r *NeConfigImpl) SelectPage(query map[string]any) map[string]any {
|
||||
conditions = append(conditions, "ne_type = ?")
|
||||
params = append(params, v)
|
||||
}
|
||||
if v, ok := query["topTag"]; ok && v != "" {
|
||||
conditions = append(conditions, "top_tag = ?")
|
||||
if v, ok := query["paramName"]; ok && v != "" {
|
||||
conditions = append(conditions, "param_name = ?")
|
||||
params = append(params, v)
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@ func (r *NeConfigImpl) SelectPage(query map[string]any) map[string]any {
|
||||
}
|
||||
|
||||
// 查询数量 长度为0直接返回
|
||||
totalSql := "select count(id) as 'total' from param_config"
|
||||
totalSql := "select count(id) as 'total' from ne_config"
|
||||
totalRows, err := datasource.RawDB("", totalSql+whereSql, params)
|
||||
if err != nil {
|
||||
logger.Errorf("total err => %v", err)
|
||||
@@ -117,9 +118,9 @@ func (r *NeConfigImpl) SelectList(param model.NeConfig) []model.NeConfig {
|
||||
conditions = append(conditions, "ne_type = ?")
|
||||
params = append(params, param.NeType)
|
||||
}
|
||||
if param.TopTag != "" {
|
||||
conditions = append(conditions, "top_tag = ?")
|
||||
params = append(params, param.TopTag)
|
||||
if param.ParamName != "" {
|
||||
conditions = append(conditions, "param_name = ?")
|
||||
params = append(params, param.ParamName)
|
||||
}
|
||||
|
||||
// 构建查询条件语句
|
||||
@@ -129,7 +130,7 @@ func (r *NeConfigImpl) SelectList(param model.NeConfig) []model.NeConfig {
|
||||
}
|
||||
|
||||
// 查询数据
|
||||
querySql := r.selectSql + whereSql + " order by id asc "
|
||||
querySql := r.selectSql + whereSql + " order by param_sort asc "
|
||||
results, err := datasource.RawDB("", querySql, params)
|
||||
if err != nil {
|
||||
logger.Errorf("query err => %v", err)
|
||||
@@ -160,25 +161,27 @@ func (r *NeConfigImpl) Insert(param model.NeConfig) string {
|
||||
if param.NeType != "" {
|
||||
params["ne_type"] = param.NeType
|
||||
}
|
||||
if param.NeId != "" {
|
||||
params["ne_id"] = param.NeId
|
||||
if param.ParamName != "" {
|
||||
params["param_name"] = param.ParamName
|
||||
}
|
||||
if param.TopTag != "" {
|
||||
params["top_tag"] = param.TopTag
|
||||
if param.ParamDisplay != "" {
|
||||
params["param_display"] = param.ParamDisplay
|
||||
}
|
||||
if param.TopDisplay != "" {
|
||||
params["top_display"] = param.TopDisplay
|
||||
if param.ParamType != "" {
|
||||
params["param_type"] = param.ParamType
|
||||
}
|
||||
if param.Method != "" {
|
||||
params["method"] = param.Method
|
||||
if param.ParamJson != "" {
|
||||
params["param_json"] = param.ParamJson
|
||||
}
|
||||
if param.ParamJSONStr != "" {
|
||||
params["param_json"] = param.ParamJSONStr
|
||||
params["param_sort"] = param.ParamSort
|
||||
if param.ParamPerms != "" {
|
||||
params["param_perms"] = param.ParamPerms
|
||||
}
|
||||
params["update_time"] = time.Now().UnixMilli()
|
||||
|
||||
// 构建执行语句
|
||||
keys, placeholder, values := repo.KeyPlaceholderValueByInsert(params)
|
||||
sql := "insert into param_config (" + strings.Join(keys, ",") + ")values(" + placeholder + ")"
|
||||
sql := "insert into ne_config (" + strings.Join(keys, ",") + ")values(" + placeholder + ")"
|
||||
|
||||
db := datasource.DefaultDB()
|
||||
// 开启事务
|
||||
@@ -210,25 +213,27 @@ func (r *NeConfigImpl) Update(param model.NeConfig) int64 {
|
||||
if param.NeType != "" {
|
||||
params["ne_type"] = param.NeType
|
||||
}
|
||||
if param.NeId != "" {
|
||||
params["ne_id"] = param.NeId
|
||||
if param.ParamName != "" {
|
||||
params["param_name"] = param.ParamName
|
||||
}
|
||||
if param.TopTag != "" {
|
||||
params["top_tag"] = param.TopTag
|
||||
if param.ParamDisplay != "" {
|
||||
params["param_display"] = param.ParamDisplay
|
||||
}
|
||||
if param.TopDisplay != "" {
|
||||
params["top_display"] = param.TopDisplay
|
||||
if param.ParamType != "" {
|
||||
params["param_type"] = param.ParamType
|
||||
}
|
||||
if param.Method != "" {
|
||||
params["method"] = param.Method
|
||||
if param.ParamJson != "" {
|
||||
params["param_json"] = param.ParamJson
|
||||
}
|
||||
if param.ParamJSONStr != "" {
|
||||
params["param_json"] = param.ParamJSONStr
|
||||
params["param_sort"] = param.ParamSort
|
||||
if param.ParamPerms != "" {
|
||||
params["param_perms"] = param.ParamPerms
|
||||
}
|
||||
params["update_time"] = time.Now().UnixMilli()
|
||||
|
||||
// 构建执行语句
|
||||
keys, values := repo.KeyValueByUpdate(params)
|
||||
sql := "update param_config set " + strings.Join(keys, ",") + " where id = ?"
|
||||
sql := "update ne_config set " + strings.Join(keys, ",") + " where id = ?"
|
||||
|
||||
// 执行更新
|
||||
values = append(values, param.ID)
|
||||
@@ -243,7 +248,7 @@ func (r *NeConfigImpl) Update(param model.NeConfig) int64 {
|
||||
// DeleteByIds 批量删除信息
|
||||
func (r *NeConfigImpl) DeleteByIds(ids []string) int64 {
|
||||
placeholder := repo.KeyPlaceholderByQuery(len(ids))
|
||||
sql := "delete from param_config where id in (" + placeholder + ")"
|
||||
sql := "delete from ne_config where id in (" + placeholder + ")"
|
||||
parameters := repo.ConvertIdsSlice(ids)
|
||||
results, err := datasource.ExecDB("", sql, parameters)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user