mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-11-25 05:18:47 +00:00
style: Format subscriber models with consistent spacing and add inactive status
- Reformat struct field alignment for improved readability - Add SubscriberStatusInactive to SubscriberStatus enum - Add blank lines after type declarations for consistency - Adjust whitespace and alignment across all model structs
This commit is contained in:
@@ -2,130 +2,136 @@ package models
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IMSI string
|
type IMSI string
|
||||||
|
|
||||||
type Subscriber struct {
|
type Subscriber struct {
|
||||||
ID uint `json:"id" gorm:"primaryKey"`
|
ID uint `json:"id" gorm:"primaryKey"`
|
||||||
IMSI IMSI `json:"imsi" gorm:"uniqueIndex;not null"`
|
IMSI IMSI `json:"imsi" gorm:"uniqueIndex;not null"`
|
||||||
MSISDN string `json:"msisdn" gorm:"uniqueIndex"` // Mobile phone number
|
MSISDN string `json:"msisdn" gorm:"uniqueIndex"` // Mobile phone number
|
||||||
IMEI string `json:"imei"` // Device identifier
|
IMEI string `json:"imei"` // Device identifier
|
||||||
|
|
||||||
FirstName string `json:"first_name" gorm:"not null"`
|
FirstName string `json:"first_name" gorm:"not null"`
|
||||||
LastName string `json:"last_name" gorm:"not null"`
|
LastName string `json:"last_name" gorm:"not null"`
|
||||||
Email string `json:"email" gorm:"uniqueIndex"`
|
Email string `json:"email" gorm:"uniqueIndex"`
|
||||||
OrganizationID string `json:"organization_id"`
|
OrganizationID string `json:"organization_id"`
|
||||||
|
|
||||||
Status SubscriberStatus `json:"status" gorm:"default:'active'"`
|
Status SubscriberStatus `json:"status" gorm:"default:'active'"`
|
||||||
PlanID uint `json:"plan_id"`
|
PlanID uint `json:"plan_id"`
|
||||||
|
|
||||||
AuthKey string `json:"auth_key" gorm:"not null"`
|
AuthKey string `json:"auth_key" gorm:"not null"`
|
||||||
OPc string `json:"opc" gorm:"not null"`
|
OPc string `json:"opc" gorm:"not null"`
|
||||||
ServingPLMN PLMN `json:"serving_plmn" gorm:"not null"`
|
ServingPLMN PLMN `json:"serving_plmn" gorm:"not null"`
|
||||||
|
|
||||||
EUICCID string `json:"euicc_id"`
|
EUICCID string `json:"euicc_id"`
|
||||||
ProfileID string `json:"profile_id"`
|
ProfileID string `json:"profile_id"`
|
||||||
ProfileStatus ProfileStatus `json:"profile_status" gorm:"default:'inactive'"`
|
ProfileStatus ProfileStatus `json:"profile_status" gorm:"default:'inactive'"`
|
||||||
|
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
||||||
|
|
||||||
Plan ServicePlan `json:"plan,omitempty" gorm:"foreignKey:PlanID"`
|
Plan ServicePlan `json:"plan,omitempty" gorm:"foreignKey:PlanID"`
|
||||||
Sessions []Session `json:"sessions,omitempty" gorm:"foreignKey:SubscriberID"`
|
Sessions []Session `json:"sessions,omitempty" gorm:"foreignKey:SubscriberID"`
|
||||||
UsageRecords []UsageRecord `json:"usage_records,omitempty" gorm:"foreignKey:SubscriberID"`
|
UsageRecords []UsageRecord `json:"usage_records,omitempty" gorm:"foreignKey:SubscriberID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServicePlan struct {
|
type ServicePlan struct {
|
||||||
ID uint `json:"id" gorm:"primaryKey"`
|
ID uint `json:"id" gorm:"primaryKey"`
|
||||||
Name string `json:"name" gorm:"not null"`
|
Name string `json:"name" gorm:"not null"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
|
|
||||||
DataLimit int64 `json:"data_limit"`
|
DataLimit int64 `json:"data_limit"`
|
||||||
VoiceLimit int `json:"voice_limit"`
|
VoiceLimit int `json:"voice_limit"`
|
||||||
SMSLimit int `json:"sms_limit"`
|
SMSLimit int `json:"sms_limit"`
|
||||||
|
|
||||||
MonthlyFee float64 `json:"monthly_fee"`
|
MonthlyFee float64 `json:"monthly_fee"`
|
||||||
DataRate float64 `json:"data_rate"`
|
DataRate float64 `json:"data_rate"`
|
||||||
VoiceRate float64 `json:"voice_rate"`
|
VoiceRate float64 `json:"voice_rate"`
|
||||||
SMSRate float64 `json:"sms_rate"`
|
SMSRate float64 `json:"sms_rate"`
|
||||||
|
|
||||||
ARPA int `json:"arpa"`
|
ARPA int `json:"arpa"`
|
||||||
AMBR AMBR `json:"ambr"`
|
AMBR AMBR `json:"ambr"`
|
||||||
|
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Session struct {
|
type Session struct {
|
||||||
ID uint `json:"id" gorm:"primaryKey"`
|
ID uint `json:"id" gorm:"primaryKey"`
|
||||||
SubscriberID uint `json:"subscriber_id" gorm:"not null"`
|
SubscriberID uint `json:"subscriber_id" gorm:"not null"`
|
||||||
SessionID string `json:"session_id" gorm:"uniqueIndex;not null"`
|
SessionID string `json:"session_id" gorm:"uniqueIndex;not null"`
|
||||||
|
|
||||||
PDUAddress string `json:"pdu_address"`
|
PDUAddress string `json:"pdu_address"`
|
||||||
DNN string `json:"dnn"`
|
DNN string `json:"dnn"`
|
||||||
SNSSAI SNSSAI `json:"snssai"`
|
SNSSAI SNSSAI `json:"snssai"`
|
||||||
QoS QoSProfile `json:"qos" gorm:"embedded"`
|
QoS QoSProfile `json:"qos" gorm:"embedded"`
|
||||||
|
|
||||||
Status SessionStatus `json:"status" gorm:"default:'active'"`
|
Status SessionStatus `json:"status" gorm:"default:'active'"`
|
||||||
StartTime time.Time `json:"start_time"`
|
StartTime time.Time `json:"start_time"`
|
||||||
EndTime *time.Time `json:"end_time,omitempty"`
|
EndTime *time.Time `json:"end_time,omitempty"`
|
||||||
|
|
||||||
DataUsed int64 `json:"data_used"`
|
DataUsed int64 `json:"data_used"`
|
||||||
VoiceUsed int `json:"voice_used"`
|
VoiceUsed int `json:"voice_used"`
|
||||||
SMSUsed int `json:"sms_used"`
|
SMSUsed int `json:"sms_used"`
|
||||||
|
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UsageRecord struct {
|
type UsageRecord struct {
|
||||||
ID uint `json:"id" gorm:"primaryKey"`
|
ID uint `json:"id" gorm:"primaryKey"`
|
||||||
SubscriberID uint `json:"subscriber_id" gorm:"not null"`
|
SubscriberID uint `json:"subscriber_id" gorm:"not null"`
|
||||||
SessionID uint `json:"session_id"`
|
SessionID uint `json:"session_id"`
|
||||||
|
|
||||||
UsageType UsageType `json:"usage_type"`
|
UsageType UsageType `json:"usage_type"`
|
||||||
StartTime time.Time `json:"start_time"`
|
StartTime time.Time `json:"start_time"`
|
||||||
EndTime time.Time `json:"end_time"`
|
EndTime time.Time `json:"end_time"`
|
||||||
Volume int64 `json:"volume"`
|
Volume int64 `json:"volume"`
|
||||||
Rate float64 `json:"rate"`
|
Rate float64 `json:"rate"`
|
||||||
Cost float64 `json:"cost"`
|
Cost float64 `json:"cost"`
|
||||||
|
|
||||||
BillingCycle string `json:"billing_cycle"`
|
BillingCycle string `json:"billing_cycle"`
|
||||||
InvoiceID *uint `json:"invoice_id,omitempty"`
|
InvoiceID *uint `json:"invoice_id,omitempty"`
|
||||||
|
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SubscriberStatus string
|
type SubscriberStatus string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SubscriberStatusActive SubscriberStatus = "active"
|
SubscriberStatusActive SubscriberStatus = "active"
|
||||||
SubscriberStatusSuspended SubscriberStatus = "suspended"
|
SubscriberStatusInactive SubscriberStatus = "inactive"
|
||||||
SubscriberStatusTerminated SubscriberStatus = "terminated"
|
SubscriberStatusSuspended SubscriberStatus = "suspended"
|
||||||
|
SubscriberStatusTerminated SubscriberStatus = "terminated"
|
||||||
SubscriberStatusProvisioning SubscriberStatus = "provisioning"
|
SubscriberStatusProvisioning SubscriberStatus = "provisioning"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProfileStatus string
|
type ProfileStatus string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ProfileStatusInactive ProfileStatus = "inactive"
|
ProfileStatusInactive ProfileStatus = "inactive"
|
||||||
ProfileStatusActive ProfileStatus = "active"
|
ProfileStatusActive ProfileStatus = "active"
|
||||||
ProfileStatusDownloading ProfileStatus = "downloading"
|
ProfileStatusDownloading ProfileStatus = "downloading"
|
||||||
ProfileStatusError ProfileStatus = "error"
|
ProfileStatusError ProfileStatus = "error"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SessionStatus string
|
type SessionStatus string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SessionStatusActive SessionStatus = "active"
|
SessionStatusActive SessionStatus = "active"
|
||||||
SessionStatusInactive SessionStatus = "inactive"
|
SessionStatusInactive SessionStatus = "inactive"
|
||||||
SessionStatusTerminating SessionStatus = "terminating"
|
SessionStatusTerminating SessionStatus = "terminating"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UsageType string
|
type UsageType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
UsageTypeData UsageType = "data"
|
UsageTypeData UsageType = "data"
|
||||||
UsageTypeVoice UsageType = "voice"
|
UsageTypeVoice UsageType = "voice"
|
||||||
@@ -138,7 +144,7 @@ type PLMN struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SNSSAI struct {
|
type SNSSAI struct {
|
||||||
SST uint8 `json:"sst"`
|
SST uint8 `json:"sst"`
|
||||||
SD uint32 `json:"sd"`
|
SD uint32 `json:"sd"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,11 +154,11 @@ type AMBR struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type QoSProfile struct {
|
type QoSProfile struct {
|
||||||
QCI uint8 `json:"qci"`
|
QCI uint8 `json:"qci"`
|
||||||
ARPA uint32 `json:"arpa"`
|
ARPA uint32 `json:"arpa"`
|
||||||
MBR AMBR `json:"mbr"`
|
MBR AMBR `json:"mbr"`
|
||||||
GBR AMBR `json:"gbr"`
|
GBR AMBR `json:"gbr"`
|
||||||
Priority uint8 `json:"priority"`
|
Priority uint8 `json:"priority"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Subscriber) TableName() string {
|
func (Subscriber) TableName() string {
|
||||||
|
|||||||
Reference in New Issue
Block a user