add: multi-tenant

This commit is contained in:
2024-06-05 11:16:22 +08:00
parent 2139bbe9ee
commit 6ce288c3ef
4 changed files with 25 additions and 25 deletions

View File

@@ -24,7 +24,7 @@ type UDMSub struct {
ContextId string `json:"contextId" gorm:"column:context_id"`
ApnContext string `json:"apnContext" gorm:"column:apn_context"`
StaticIp string `json:"staticIp" gorm:"column:static_ip"`
TenantIDs string `json:"tenantIDs" gorm:"column:tenant_ids"`
TenantName string `json:"tenantName" gorm:"column:tenant_name"`
// ====== 非数据库字段属性 ======

View File

@@ -15,7 +15,7 @@ import (
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,
tenant_ids
tenant_name
from u_sub_user`,
resultMap: map[string]string{
@@ -40,7 +40,7 @@ var NewUDMSubImpl = &UDMSubImpl{
"context_id": "ContextId",
"apn_context": "ApnContext",
"static_ip": "StaticIp",
"tenant_ids": "TenantIDs", // Tenant ID for multi-tenancy
"tenant_name": "TenantName", // Tenant ID for multi-tenancy
},
}
@@ -96,8 +96,8 @@ func (r *UDMSubImpl) SelectPage(query map[string]any) map[string]any {
params = append(params, v)
}
// for multi-tenancy solution
if v, ok := query["tenantIDs"]; ok && v != "" {
conditions = append(conditions, "tenant_ids like concat(concat('%', ?), '%')")
if v, ok := query["tenantName"]; ok && v != "" {
conditions = append(conditions, "tenant_name = '?'")
params = append(params, v)
}