feat: 网元授权添加用户容量列

This commit is contained in:
TsMask
2025-05-09 11:36:43 +08:00
parent 7592c8c4d5
commit 8fe41b136f
4 changed files with 13 additions and 22 deletions

View File

@@ -8,14 +8,15 @@ CREATE TABLE "ne_license" (
"ne_id" text(32) NOT NULL, "ne_id" text(32) NOT NULL,
"activation_request_code" text(255) NOT NULL, "activation_request_code" text(255) NOT NULL,
"license_path" text(255), "license_path" text(255),
"capability" integer,
"serial_num" text(32), "serial_num" text(32),
"expiry_date" text(32), "expiry_date" text(32),
"status" text(32), "status" text(32),
"remark" text(255), "remark" text(255),
"create_by" text(50), "create_by" text(50),
"create_time" integer(20), "create_time" integer,
"update_by" text(50), "update_by" text(50),
"update_time" integer(20), "update_time" integer,
PRIMARY KEY ("id") PRIMARY KEY ("id")
); );
@@ -31,4 +32,4 @@ ON "ne_license" (
-- ---------------------------- -- ----------------------------
-- Records of ne_license -- Records of ne_license
-- ---------------------------- -- ----------------------------
INSERT INTO "ne_license" VALUES (1, 'OMC', '001', '', '', '', '', '0', '', 'system', 1713928436971, '', 0); INSERT INTO "ne_license" VALUES (1, 'OMC', '001', '', '', 0, '', '', '0', '', 'system', 1713928436971, '', 0);

View File

@@ -13,6 +13,7 @@ CREATE TABLE `ne_license` (
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID', `ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID',
`activation_request_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '激活申请代码', `activation_request_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '激活申请代码',
`license_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '激活授权文件', `license_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '激活授权文件',
`capability` bigint DEFAULT '0' COMMENT '用户容量',
`serial_num` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '序列号', `serial_num` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '序列号',
`expiry_date` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '许可证到期日期', `expiry_date` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '许可证到期日期',
`status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '状态 0无效 1有效', `status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '状态 0无效 1有效',
@@ -26,22 +27,7 @@ CREATE TABLE `ne_license` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网元_授权激活信息'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网元_授权激活信息';
-- 初始数据对应网元 -- 初始数据对应网元
INSERT INTO `ne_license` VALUES (1, 'OMC', '001', '', '', '', '', '0', '', 'system', 1713928436971, '', 0); INSERT INTO `ne_license` VALUES (1, 'OMC', '001', '', '', 0, '', '', '0', '', 'system', 1713928436971, '', 0);
-- INSERT INTO `ne_license` VALUES (2, 'IMS', '001', '', '', '', '', '0', '', 'system', 1713928436971, '', 0);
-- INSERT INTO `ne_license` VALUES (3, 'AMF', '001', '', '', '', '', '0', '', 'system', 1713928436971, '', 0);
-- INSERT INTO `ne_license` VALUES (4, 'AUSF', '001', '', '', '', '', '0', '', 'system', 1713928436971, '', 0);
-- INSERT INTO `ne_license` VALUES (5, 'UDM', '001', '', '', '', '', '0', '', 'system', 1713928436971, '', 0);
-- INSERT INTO `ne_license` VALUES (6, 'SMF', '001', '', '', '', '', '0', '', 'system', 1713928436971, '', 0);
-- INSERT INTO `ne_license` VALUES (7, 'PCF', '001', '', '', '', '', '0', '', 'system', 1713928436971, '', 0);
-- INSERT INTO `ne_license` VALUES (8, 'NSSF', '001', '', '', '', '', '0', '', 'system', 1713928436971, '', 0);
-- INSERT INTO `ne_license` VALUES (9, 'NRF', '001', '', '', '', '', '0', '', 'system', 1713928436971, '', 0);
-- INSERT INTO `ne_license` VALUES (10, 'UPF', '001', '', '', '', '', '0', '', 'system', 1713928436971, '', 0);
-- INSERT INTO `ne_license` VALUES (11, 'LMF', '001', '', '', '', '', '0', '', 'system', 1713928436971, '', 0);
-- INSERT INTO `ne_license` VALUES (12, 'NEF', '001', '', '', '', '', '0', '', 'system', 1713928436971, '', 0);
-- INSERT INTO `ne_license` VALUES (13, 'MME', '001', '', '', '', '', '0', '', 'system', 1713928436971, '', 0);
-- INSERT INTO `ne_license` VALUES (14, 'N3IWF', '001', '', '', '', '', '0', '', 'system', 1713928436971, '', 0);
-- INSERT INTO `ne_license` VALUES (14, 'N3IWF', '001', '', '', '', '', '0', '', 'system', 1713928436971, '', 0);
-- INSERT INTO `ne_license` VALUES (15, 'SMSC', '001', '', '', '', '', '0', '', 'system', 1713928436971, '', 0);
SET FOREIGN_KEY_CHECKS=1; SET FOREIGN_KEY_CHECKS=1;

View File

@@ -156,6 +156,7 @@ func (s *NeLicenseController) Code(c *gin.Context) {
if licensePath != "" { if licensePath != "" {
neLicense.LicensePath = licensePath neLicense.LicensePath = licensePath
} else { } else {
neLicense.Capability = 0
neLicense.SerialNum = "" neLicense.SerialNum = ""
neLicense.ExpiryDate = "" neLicense.ExpiryDate = ""
neLicense.Status = "0" neLicense.Status = "0"
@@ -259,6 +260,7 @@ func (s *NeLicenseController) State(c *gin.Context) {
} }
if neState, err := neFetchlink.NeState(neInfo); err == nil && neState["sn"] != nil { if neState, err := neFetchlink.NeState(neInfo); err == nil && neState["sn"] != nil {
neLicense.Status = "1" neLicense.Status = "1"
neLicense.Capability = parse.Number(neState["capability"])
neLicense.SerialNum = fmt.Sprint(neState["sn"]) neLicense.SerialNum = fmt.Sprint(neState["sn"])
neLicense.ExpiryDate = fmt.Sprint(neState["expire"]) neLicense.ExpiryDate = fmt.Sprint(neState["expire"])
} else { } else {
@@ -274,9 +276,10 @@ func (s *NeLicenseController) State(c *gin.Context) {
s.neLicenseService.Update(neLicense) s.neLicenseService.Update(neLicense)
if neLicense.Status == "1" { if neLicense.Status == "1" {
c.JSON(200, resp.OkData(map[string]string{ c.JSON(200, resp.OkData(map[string]any{
"sn": neLicense.SerialNum, "capability": neLicense.Capability,
"expire": neLicense.ExpiryDate, "sn": neLicense.SerialNum,
"expire": neLicense.ExpiryDate,
})) }))
return return
} }

View File

@@ -7,6 +7,7 @@ type NeLicense struct {
NeId string `json:"neId" gorm:"column:ne_id" binding:"required"` // 网元ID NeId string `json:"neId" gorm:"column:ne_id" binding:"required"` // 网元ID
ActivationRequestCode string `json:"activationRequestCode" gorm:"column:activation_request_code"` // 激活申请代码 ActivationRequestCode string `json:"activationRequestCode" gorm:"column:activation_request_code"` // 激活申请代码
LicensePath string `json:"licensePath" gorm:"column:license_path"` // 激活授权文件 LicensePath string `json:"licensePath" gorm:"column:license_path"` // 激活授权文件
Capability int64 `json:"capability" gorm:"column:capability"` // 用户容量
SerialNum string `json:"serialNum" gorm:"column:serial_num"` // 序列号 SerialNum string `json:"serialNum" gorm:"column:serial_num"` // 序列号
ExpiryDate string `json:"expiryDate" gorm:"column:expiry_date"` // 许可证到期日期 ExpiryDate string `json:"expiryDate" gorm:"column:expiry_date"` // 许可证到期日期
Status string `json:"status" gorm:"column:status"` // 状态 0无效 1有效 Status string `json:"status" gorm:"column:status"` // 状态 0无效 1有效