feat: ne模块名称变更
This commit is contained in:
11
src/modules/network_element/repository/ne_info.go
Normal file
11
src/modules/network_element/repository/ne_info.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"ems.agt/src/modules/network_element/model"
|
||||
)
|
||||
|
||||
// 网元信息 数据层接口
|
||||
type INeInfo interface {
|
||||
// SelectNeInfoByNeTypeAndNeID 通过ne_type和ne_id查询网元信息
|
||||
SelectNeInfoByNeTypeAndNeID(neType, neID string) model.NeInfo
|
||||
}
|
||||
69
src/modules/network_element/repository/ne_info.impl.go
Normal file
69
src/modules/network_element/repository/ne_info.impl.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"ems.agt/src/framework/datasource"
|
||||
"ems.agt/src/framework/logger"
|
||||
"ems.agt/src/framework/utils/repo"
|
||||
"ems.agt/src/modules/network_element/model"
|
||||
)
|
||||
|
||||
// 实例化数据层 NeInfoImpl 结构体
|
||||
var NewNeInfoImpl = &NeInfoImpl{
|
||||
selectSql: `select id, ne_type, ne_id, rm_uid, ne_name, ip, port, pv_flag, province, vendor_name, dn, ne_address, status, update_time from ne_info`,
|
||||
|
||||
resultMap: map[string]string{
|
||||
"id": "ID",
|
||||
"ne_type": "NeType",
|
||||
"ne_id": "NeId",
|
||||
"rm_uid": "RmUID",
|
||||
"ne_name": "NeName",
|
||||
"ip": "IP",
|
||||
"port": "Port",
|
||||
"pv_flag": "PvFlag",
|
||||
"province": "Province",
|
||||
"vendor_name": "VendorName",
|
||||
"dn": "Dn",
|
||||
"ne_address": "NeAddress",
|
||||
"status": "Status",
|
||||
"update_time": "UpdateTime",
|
||||
},
|
||||
}
|
||||
|
||||
// NeInfoImpl 网元信息表 数据层处理
|
||||
type NeInfoImpl struct {
|
||||
// 查询视图对象SQL
|
||||
selectSql string
|
||||
// 结果字段与实体映射
|
||||
resultMap map[string]string
|
||||
}
|
||||
|
||||
// convertResultRows 将结果记录转实体结果组
|
||||
func (r *NeInfoImpl) convertResultRows(rows []map[string]any) []model.NeInfo {
|
||||
arr := make([]model.NeInfo, 0)
|
||||
for _, row := range rows {
|
||||
item := model.NeInfo{}
|
||||
for key, value := range row {
|
||||
if keyMapper, ok := r.resultMap[key]; ok {
|
||||
repo.SetFieldValue(&item, keyMapper, value)
|
||||
}
|
||||
}
|
||||
arr = append(arr, item)
|
||||
}
|
||||
return arr
|
||||
}
|
||||
|
||||
// SelectNeInfoByNeTypeAndNeID 通过ne_type和ne_id查询网元信息
|
||||
func (r *NeInfoImpl) SelectNeInfoByNeTypeAndNeID(neType, neID string) model.NeInfo {
|
||||
querySql := r.selectSql + " where ne_type = ? and ne_id = ?"
|
||||
results, err := datasource.RawDB("", querySql, []any{neType, neID})
|
||||
if err != nil {
|
||||
logger.Errorf("query err => %v", err)
|
||||
return model.NeInfo{}
|
||||
}
|
||||
// 转换实体
|
||||
rows := r.convertResultRows(results)
|
||||
if len(rows) > 0 {
|
||||
return rows[0]
|
||||
}
|
||||
return model.NeInfo{}
|
||||
}
|
||||
26
src/modules/network_element/repository/udm_auth.go
Normal file
26
src/modules/network_element/repository/udm_auth.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"ems.agt/src/modules/network_element/model"
|
||||
)
|
||||
|
||||
// UDM鉴权信息 数据层接口
|
||||
type IUDMAuth interface {
|
||||
// ClearAndInsert 清空ne_id后新增实体
|
||||
ClearAndInsert(neID string, authArr []model.UDMAuth) int64
|
||||
|
||||
// SelectPage 根据条件分页查询
|
||||
SelectPage(query map[string]any) map[string]any
|
||||
|
||||
// SelectList 根据实体查询
|
||||
SelectList(auth model.UDMAuth) []model.UDMAuth
|
||||
|
||||
// Insert 批量添加
|
||||
Inserts(authUsers []model.UDMAuth) int64
|
||||
|
||||
// Delete 删除实体
|
||||
Delete(neID, imsi string) int64
|
||||
|
||||
// DeletePrefixImsi 删除前缀匹配的实体
|
||||
DeletePrefixImsi(neID, imsi string) int64
|
||||
}
|
||||
191
src/modules/network_element/repository/udm_auth.impl.go
Normal file
191
src/modules/network_element/repository/udm_auth.impl.go
Normal file
@@ -0,0 +1,191 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"ems.agt/src/framework/datasource"
|
||||
"ems.agt/src/framework/logger"
|
||||
"ems.agt/src/framework/utils/parse"
|
||||
"ems.agt/src/framework/utils/repo"
|
||||
"ems.agt/src/modules/network_element/model"
|
||||
)
|
||||
|
||||
// 实例化数据层 UDMAuthImpl 结构体
|
||||
var NewUDMAuthImpl = &UDMAuthImpl{
|
||||
selectSql: `select id, imsi, amf, status, ki, algo_index, opc, ne_id from u_auth_user`,
|
||||
|
||||
resultMap: map[string]string{
|
||||
"id": "ID",
|
||||
"imsi": "Imsi",
|
||||
"amf": "Amf",
|
||||
"status": "Status",
|
||||
"ki": "Ki",
|
||||
"algo_index": "AlgoIndex",
|
||||
"opc": "Opc",
|
||||
"ne_id": "NeID",
|
||||
},
|
||||
}
|
||||
|
||||
// UDMAuthImpl UDM鉴权信息表 数据层处理
|
||||
type UDMAuthImpl struct {
|
||||
// 查询视图对象SQL
|
||||
selectSql string
|
||||
// 结果字段与实体映射
|
||||
resultMap map[string]string
|
||||
}
|
||||
|
||||
// convertResultRows 将结果记录转实体结果组
|
||||
func (r *UDMAuthImpl) convertResultRows(rows []map[string]any) []model.UDMAuth {
|
||||
arr := make([]model.UDMAuth, 0)
|
||||
for _, row := range rows {
|
||||
item := model.UDMAuth{}
|
||||
for key, value := range row {
|
||||
if keyMapper, ok := r.resultMap[key]; ok {
|
||||
repo.SetFieldValue(&item, keyMapper, value)
|
||||
}
|
||||
}
|
||||
arr = append(arr, item)
|
||||
}
|
||||
return arr
|
||||
}
|
||||
|
||||
// ClearAndInsert 清空ne_id后新增实体
|
||||
func (r *UDMAuthImpl) ClearAndInsert(neID string, authArr []model.UDMAuth) int64 {
|
||||
// 清空指定ne_id
|
||||
_, err := datasource.ExecDB("", "TRUNCATE TABLE u_auth_user", nil)
|
||||
if err != nil {
|
||||
logger.Errorf("TRUNCATE err => %v", err)
|
||||
}
|
||||
|
||||
return r.Inserts(authArr)
|
||||
}
|
||||
|
||||
// SelectPage 根据条件分页查询
|
||||
func (r *UDMAuthImpl) SelectPage(query map[string]any) map[string]any {
|
||||
// 查询条件拼接
|
||||
var conditions []string
|
||||
var params []any
|
||||
if v, ok := query["imsi"]; ok && v != "" {
|
||||
conditions = append(conditions, "imsi like concat(concat('%', ?), '%')")
|
||||
params = append(params, v)
|
||||
}
|
||||
if v, ok := query["neId"]; ok && v != "" {
|
||||
conditions = append(conditions, "ne_id = ?")
|
||||
params = append(params, v)
|
||||
}
|
||||
|
||||
// 构建查询条件语句
|
||||
whereSql := ""
|
||||
if len(conditions) > 0 {
|
||||
whereSql += " where " + strings.Join(conditions, " and ")
|
||||
}
|
||||
|
||||
result := map[string]any{
|
||||
"total": 0,
|
||||
"rows": []model.UDMAuth{},
|
||||
}
|
||||
|
||||
// 查询数量 长度为0直接返回
|
||||
totalSql := "select count(1) as 'total' from u_auth_user"
|
||||
totalRows, err := datasource.RawDB("", totalSql+whereSql, params)
|
||||
if err != nil {
|
||||
logger.Errorf("total err => %v", err)
|
||||
return result
|
||||
}
|
||||
total := parse.Number(totalRows[0]["total"])
|
||||
if total == 0 {
|
||||
return result
|
||||
} else {
|
||||
result["total"] = total
|
||||
}
|
||||
|
||||
// 分页
|
||||
pageNum, pageSize := repo.PageNumSize(query["pageNum"], query["pageSize"])
|
||||
pageSql := " limit ?,? "
|
||||
params = append(params, pageNum*pageSize)
|
||||
params = append(params, pageSize)
|
||||
|
||||
// 排序
|
||||
sortSql := ""
|
||||
if v, ok := query["sortField"]; ok && v != "" {
|
||||
if v == "imsi" {
|
||||
sortSql += " order by imsi "
|
||||
}
|
||||
if o, ok := query["sortOrder"]; ok && o != nil && v != "" {
|
||||
if o == "desc" {
|
||||
sortSql += " desc "
|
||||
} else {
|
||||
sortSql += " asc "
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 查询数据
|
||||
querySql := r.selectSql + whereSql + sortSql + pageSql
|
||||
results, err := datasource.RawDB("", querySql, params)
|
||||
if err != nil {
|
||||
logger.Errorf("query err => %v", err)
|
||||
}
|
||||
|
||||
// 转换实体
|
||||
result["rows"] = r.convertResultRows(results)
|
||||
return result
|
||||
}
|
||||
|
||||
// SelectList 根据实体查询
|
||||
func (r *UDMAuthImpl) SelectList(auth model.UDMAuth) []model.UDMAuth {
|
||||
// 查询条件拼接
|
||||
var conditions []string
|
||||
var params []any
|
||||
if auth.Imsi != "" {
|
||||
conditions = append(conditions, "imsi = ?")
|
||||
params = append(params, auth.Imsi)
|
||||
}
|
||||
if auth.NeID != "" {
|
||||
conditions = append(conditions, "ne_id = ?")
|
||||
params = append(params, auth.NeID)
|
||||
}
|
||||
|
||||
// 构建查询条件语句
|
||||
whereSql := ""
|
||||
if len(conditions) > 0 {
|
||||
whereSql += " where " + strings.Join(conditions, " and ")
|
||||
}
|
||||
|
||||
// 查询数据
|
||||
querySql := r.selectSql + whereSql + " order by imsi asc "
|
||||
results, err := datasource.RawDB("", querySql, params)
|
||||
if err != nil {
|
||||
logger.Errorf("query err => %v", err)
|
||||
}
|
||||
|
||||
// 转换实体
|
||||
return r.convertResultRows(results)
|
||||
}
|
||||
|
||||
// Insert 批量添加
|
||||
func (r *UDMAuthImpl) Inserts(authUsers []model.UDMAuth) int64 {
|
||||
tx := datasource.DefaultDB().CreateInBatches(authUsers, 3000)
|
||||
if err := tx.Error; err != nil {
|
||||
logger.Errorf("CreateInBatches err => %v", err)
|
||||
}
|
||||
return tx.RowsAffected
|
||||
}
|
||||
|
||||
// Delete 删除实体
|
||||
func (r *UDMAuthImpl) Delete(neID, imsi string) int64 {
|
||||
tx := datasource.DefaultDB().Where("imsi = ? and ne_id = ?", imsi, neID).Delete(&model.UDMAuth{})
|
||||
if err := tx.Error; err != nil {
|
||||
logger.Errorf("Delete err => %v", err)
|
||||
}
|
||||
return tx.RowsAffected
|
||||
}
|
||||
|
||||
// DeletePrefixImsi 删除前缀匹配的实体
|
||||
func (r *UDMAuthImpl) DeletePrefixImsi(neID, imsi string) int64 {
|
||||
tx := datasource.DefaultDB().Where("imsi like concat(?, '%') and ne_id = ?", imsi, neID).Delete(&model.UDMAuth{})
|
||||
if err := tx.Error; err != nil {
|
||||
logger.Errorf("DeletePrefixImsi err => %v", err)
|
||||
}
|
||||
return tx.RowsAffected
|
||||
}
|
||||
35
src/modules/network_element/repository/udm_sub.go
Normal file
35
src/modules/network_element/repository/udm_sub.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"ems.agt/src/modules/network_element/model"
|
||||
)
|
||||
|
||||
// UDM签约信息 数据层接口
|
||||
type IUDMSub interface {
|
||||
// ClearAndInsert 清空ne_id后新增实体
|
||||
ClearAndInsert(neID string, subArr []model.UDMSub) int64
|
||||
|
||||
// SelectPage 根据条件分页查询字典类型
|
||||
SelectPage(query map[string]any) map[string]any
|
||||
|
||||
// SelectList 根据实体查询
|
||||
SelectList(subUser model.UDMSub) []model.UDMSub
|
||||
|
||||
// Insert 新增实体
|
||||
Insert(subUser model.UDMSub) string
|
||||
|
||||
// Insert 批量添加
|
||||
Inserts(subUser []model.UDMSub) int64
|
||||
|
||||
// Update 修改更新
|
||||
Update(neID string, subUser model.UDMSub) int64
|
||||
|
||||
// Delete 删除实体
|
||||
Delete(neID, imsi string) int64
|
||||
|
||||
// DeletePrefixImsi 删除前缀匹配的实体
|
||||
DeletePrefixImsi(neID, imsi string) int64
|
||||
|
||||
// Delete 删除范围实体
|
||||
Deletes(neID, imsi, num string) int64
|
||||
}
|
||||
312
src/modules/network_element/repository/udm_sub.impl.go
Normal file
312
src/modules/network_element/repository/udm_sub.impl.go
Normal file
@@ -0,0 +1,312 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"ems.agt/src/framework/datasource"
|
||||
"ems.agt/src/framework/logger"
|
||||
"ems.agt/src/framework/utils/parse"
|
||||
"ems.agt/src/framework/utils/repo"
|
||||
"ems.agt/src/modules/network_element/model"
|
||||
)
|
||||
|
||||
// 实例化数据层 UDMSubImpl 结构体
|
||||
var NewUDMSubImpl = &UDMSubImpl{
|
||||
selectSql: `select
|
||||
id, msisdn, imsi, ambr, nssai, rat, arfb, sar, cn, sm_data, smf_sel, eps_dat, ne_id, eps_flag, eps_odb, hplmn_odb, ard, epstpl, context_id, apn_context, static_ip
|
||||
from u_sub_user`,
|
||||
|
||||
resultMap: map[string]string{
|
||||
"id": "ID",
|
||||
"msisdn": "Msisdn",
|
||||
"imsi": "Imsi",
|
||||
"ambr": "Ambr",
|
||||
"nssai": "Nssai",
|
||||
"rat": "Rat",
|
||||
"arfb": "Arfb",
|
||||
"sar": "Sar",
|
||||
"cn": "Cn",
|
||||
"sm_data": "SmData",
|
||||
"smf_sel": "SmfSel",
|
||||
"eps_dat": "EpsDat",
|
||||
"ne_id": "NeID",
|
||||
"eps_flag": "EpsFlag",
|
||||
"eps_odb": "EpsOdb",
|
||||
"hplmn_odb": "HplmnOdb",
|
||||
"ard": "Ard",
|
||||
"epstpl": "Epstpl",
|
||||
"context_id": "ContextId",
|
||||
"apn_context": "ApnContext",
|
||||
"static_ip": "StaticIp",
|
||||
},
|
||||
}
|
||||
|
||||
// UDMSubImpl UDM签约信息表 数据层处理
|
||||
type UDMSubImpl struct {
|
||||
// 查询视图对象SQL
|
||||
selectSql string
|
||||
// 结果字段与实体映射
|
||||
resultMap map[string]string
|
||||
}
|
||||
|
||||
// convertResultRows 将结果记录转实体结果组
|
||||
func (r *UDMSubImpl) convertResultRows(rows []map[string]any) []model.UDMSub {
|
||||
arr := make([]model.UDMSub, 0)
|
||||
for _, row := range rows {
|
||||
item := model.UDMSub{}
|
||||
for key, value := range row {
|
||||
if keyMapper, ok := r.resultMap[key]; ok {
|
||||
repo.SetFieldValue(&item, keyMapper, value)
|
||||
}
|
||||
}
|
||||
arr = append(arr, item)
|
||||
}
|
||||
return arr
|
||||
}
|
||||
|
||||
// ClearAndInsert 清空ne_id后新增实体
|
||||
func (r *UDMSubImpl) ClearAndInsert(neID string, subArr []model.UDMSub) int64 {
|
||||
// 清空指定ne_id
|
||||
_, err := datasource.ExecDB("", "TRUNCATE TABLE u_sub_user", nil)
|
||||
if err != nil {
|
||||
logger.Errorf("TRUNCATE err => %v", err)
|
||||
}
|
||||
|
||||
return r.Inserts(subArr)
|
||||
}
|
||||
|
||||
// SelectPage 根据条件分页查询字典类型
|
||||
func (r *UDMSubImpl) SelectPage(query map[string]any) map[string]any {
|
||||
// 查询条件拼接
|
||||
var conditions []string
|
||||
var params []any
|
||||
if v, ok := query["msisdn"]; ok && v != "" {
|
||||
conditions = append(conditions, "msisdn like concat(concat('%', ?), '%')")
|
||||
params = append(params, v)
|
||||
}
|
||||
if v, ok := query["imsi"]; ok && v != "" {
|
||||
conditions = append(conditions, "imsi like concat(concat('%', ?), '%')")
|
||||
params = append(params, v)
|
||||
}
|
||||
if v, ok := query["neId"]; ok && v != "" {
|
||||
conditions = append(conditions, "ne_id = ?")
|
||||
params = append(params, v)
|
||||
}
|
||||
|
||||
// 构建查询条件语句
|
||||
whereSql := ""
|
||||
if len(conditions) > 0 {
|
||||
whereSql += " where " + strings.Join(conditions, " and ")
|
||||
}
|
||||
|
||||
result := map[string]any{
|
||||
"total": 0,
|
||||
"rows": []model.UDMSub{},
|
||||
}
|
||||
|
||||
// 查询数量 长度为0直接返回
|
||||
totalSql := "select count(1) as 'total' from u_sub_user"
|
||||
totalRows, err := datasource.RawDB("", totalSql+whereSql, params)
|
||||
if err != nil {
|
||||
logger.Errorf("total err => %v", err)
|
||||
return result
|
||||
}
|
||||
total := parse.Number(totalRows[0]["total"])
|
||||
if total == 0 {
|
||||
return result
|
||||
} else {
|
||||
result["total"] = total
|
||||
}
|
||||
|
||||
// 分页
|
||||
pageNum, pageSize := repo.PageNumSize(query["pageNum"], query["pageSize"])
|
||||
pageSql := " limit ?,? "
|
||||
params = append(params, pageNum*pageSize)
|
||||
params = append(params, pageSize)
|
||||
|
||||
// 排序
|
||||
sortSql := ""
|
||||
if v, ok := query["sortField"]; ok && v != "" {
|
||||
if v == "imsi" {
|
||||
sortSql += " order by imsi "
|
||||
}
|
||||
if v == "msisdn" {
|
||||
sortSql += " order by msisdn "
|
||||
}
|
||||
if o, ok := query["sortOrder"]; ok && o != nil && v != "" {
|
||||
if o == "desc" {
|
||||
sortSql += " desc "
|
||||
} else {
|
||||
sortSql += " asc "
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 查询数据
|
||||
querySql := r.selectSql + whereSql + sortSql + pageSql
|
||||
results, err := datasource.RawDB("", querySql, params)
|
||||
if err != nil {
|
||||
logger.Errorf("query err => %v", err)
|
||||
return result
|
||||
}
|
||||
|
||||
// 转换实体
|
||||
result["rows"] = r.convertResultRows(results)
|
||||
return result
|
||||
}
|
||||
|
||||
// SelectList 根据实体查询
|
||||
func (r *UDMSubImpl) SelectList(subUser model.UDMSub) []model.UDMSub {
|
||||
// 查询条件拼接
|
||||
var conditions []string
|
||||
var params []any
|
||||
if subUser.Imsi != "" {
|
||||
conditions = append(conditions, "imsi = ?")
|
||||
params = append(params, subUser.Imsi)
|
||||
}
|
||||
if subUser.NeID != "" {
|
||||
conditions = append(conditions, "ne_id = ?")
|
||||
params = append(params, subUser.NeID)
|
||||
}
|
||||
|
||||
// 构建查询条件语句
|
||||
whereSql := ""
|
||||
if len(conditions) > 0 {
|
||||
whereSql += " where " + strings.Join(conditions, " and ")
|
||||
}
|
||||
|
||||
// 查询数据
|
||||
querySql := r.selectSql + whereSql + " order by imsi asc "
|
||||
results, err := datasource.RawDB("", querySql, params)
|
||||
if err != nil {
|
||||
logger.Errorf("query err => %v", err)
|
||||
}
|
||||
|
||||
// 转换实体
|
||||
return r.convertResultRows(results)
|
||||
}
|
||||
|
||||
// Insert 新增实体
|
||||
func (r *UDMSubImpl) Insert(subUser model.UDMSub) string {
|
||||
err := datasource.DefaultDB().Create(&subUser).Error
|
||||
if err != nil {
|
||||
logger.Errorf("Create err => %v", err)
|
||||
}
|
||||
return subUser.ID
|
||||
}
|
||||
|
||||
// Insert 批量添加
|
||||
func (r *UDMSubImpl) Inserts(subUser []model.UDMSub) int64 {
|
||||
tx := datasource.DefaultDB().CreateInBatches(subUser, 2000)
|
||||
if err := tx.Error; err != nil {
|
||||
logger.Errorf("CreateInBatches err => %v", err)
|
||||
}
|
||||
return tx.RowsAffected
|
||||
}
|
||||
|
||||
// Update 修改更新
|
||||
func (r *UDMSubImpl) Update(neID string, subUser model.UDMSub) int64 {
|
||||
// 查询先
|
||||
var user model.UDMSub
|
||||
err := datasource.DefaultDB().Where("imsi = ? and ne_id = ?", subUser.Imsi, neID).First(&user).Error
|
||||
if err != nil {
|
||||
logger.Errorf("Update First err => %v", err)
|
||||
}
|
||||
|
||||
if user.Msisdn != subUser.Msisdn {
|
||||
user.Msisdn = subUser.Msisdn
|
||||
}
|
||||
if user.Ambr != subUser.Ambr {
|
||||
user.Ambr = subUser.Ambr
|
||||
}
|
||||
if user.Arfb != subUser.Arfb {
|
||||
user.Arfb = subUser.Arfb
|
||||
}
|
||||
if user.Sar != subUser.Sar {
|
||||
user.Sar = subUser.Sar
|
||||
}
|
||||
if user.Rat != subUser.Rat {
|
||||
user.Rat = subUser.Rat
|
||||
}
|
||||
if user.Cn != subUser.Cn {
|
||||
user.Cn = subUser.Cn
|
||||
}
|
||||
if user.SmfSel != subUser.SmfSel {
|
||||
user.SmfSel = subUser.SmfSel
|
||||
}
|
||||
if user.SmData != subUser.SmData {
|
||||
user.SmData = subUser.SmData
|
||||
}
|
||||
if user.EpsDat != subUser.EpsDat {
|
||||
user.EpsDat = subUser.EpsDat
|
||||
}
|
||||
if user.EpsFlag != subUser.EpsFlag {
|
||||
user.EpsFlag = subUser.EpsFlag
|
||||
}
|
||||
if user.EpsDat != subUser.EpsDat {
|
||||
user.EpsOdb = subUser.EpsOdb
|
||||
}
|
||||
if user.HplmnOdb != subUser.HplmnOdb {
|
||||
user.HplmnOdb = subUser.HplmnOdb
|
||||
}
|
||||
if user.Epstpl != subUser.Epstpl {
|
||||
user.Epstpl = subUser.Epstpl
|
||||
}
|
||||
if user.Ard != subUser.Ard {
|
||||
user.Ard = subUser.Ard
|
||||
}
|
||||
if user.ContextId != subUser.ContextId {
|
||||
user.ContextId = subUser.ContextId
|
||||
}
|
||||
if user.ApnContext != subUser.ApnContext {
|
||||
user.ApnContext = subUser.ApnContext
|
||||
}
|
||||
if user.StaticIp != subUser.StaticIp {
|
||||
user.StaticIp = subUser.StaticIp
|
||||
}
|
||||
|
||||
tx := datasource.DefaultDB().Save(user)
|
||||
if err := tx.Error; err != nil {
|
||||
logger.Errorf("Update Save err => %v", err)
|
||||
return 0
|
||||
}
|
||||
return tx.RowsAffected
|
||||
}
|
||||
|
||||
// Delete 删除实体
|
||||
func (r *UDMSubImpl) Delete(neID, imsi string) int64 {
|
||||
tx := datasource.DefaultDB().Where("imsi = ? and ne_id = ?", imsi, neID).Delete(&model.UDMSub{})
|
||||
if err := tx.Error; err != nil {
|
||||
logger.Errorf("Delete err => %v", err)
|
||||
}
|
||||
return tx.RowsAffected
|
||||
}
|
||||
|
||||
// DeletePrefixImsi 删除前缀匹配的实体
|
||||
func (r *UDMSubImpl) DeletePrefixImsi(neID, imsi string) int64 {
|
||||
tx := datasource.DefaultDB().Where("imsi like concat(?, '%') and ne_id = ?", imsi, neID).Delete(&model.UDMSub{})
|
||||
if err := tx.Error; err != nil {
|
||||
logger.Errorf("DeletePrefixImsi err => %v", err)
|
||||
}
|
||||
return tx.RowsAffected
|
||||
}
|
||||
|
||||
// Delete 删除范围实体
|
||||
func (r *UDMSubImpl) Deletes(neID, imsi, num string) int64 {
|
||||
imsiV, err := strconv.Atoi(imsi)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
numV, err := strconv.Atoi(num)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
tx := datasource.DefaultDB().Where("imsi >= ? and imsi < ? and ne_id = ?", imsiV, imsiV+numV, neID).Delete(&model.UDMSub{})
|
||||
if err := tx.Error; err != nil {
|
||||
logger.Errorf("Deletes err => %v", err)
|
||||
}
|
||||
return tx.RowsAffected
|
||||
}
|
||||
Reference in New Issue
Block a user