diff --git a/build/database/lite/install/ne_license.sql b/build/database/lite/install/ne_license.sql index a83ba824..37480406 100644 --- a/build/database/lite/install/ne_license.sql +++ b/build/database/lite/install/ne_license.sql @@ -8,14 +8,15 @@ CREATE TABLE "ne_license" ( "ne_id" text(32) NOT NULL, "activation_request_code" text(255) NOT NULL, "license_path" text(255), + "capability" integer, "serial_num" text(32), "expiry_date" text(32), "status" text(32), "remark" text(255), "create_by" text(50), - "create_time" integer(20), + "create_time" integer, "update_by" text(50), - "update_time" integer(20), + "update_time" integer, PRIMARY KEY ("id") ); @@ -31,4 +32,4 @@ ON "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); diff --git a/build/database/std/install/ne_license.sql b/build/database/std/install/ne_license.sql index 6bae442b..b5414da5 100644 --- a/build/database/std/install/ne_license.sql +++ b/build/database/std/install/ne_license.sql @@ -13,6 +13,7 @@ CREATE TABLE `ne_license` ( `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 '激活申请代码', `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 '序列号', `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有效', @@ -26,22 +27,7 @@ CREATE TABLE `ne_license` ( ) 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 (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); +INSERT INTO `ne_license` VALUES (1, 'OMC', '001', '', '', 0, '', '', '0', '', 'system', 1713928436971, '', 0); SET FOREIGN_KEY_CHECKS=1; diff --git a/src/modules/network_element/controller/ne_license.go b/src/modules/network_element/controller/ne_license.go index 92a37ba8..64bc1a84 100644 --- a/src/modules/network_element/controller/ne_license.go +++ b/src/modules/network_element/controller/ne_license.go @@ -156,6 +156,7 @@ func (s *NeLicenseController) Code(c *gin.Context) { if licensePath != "" { neLicense.LicensePath = licensePath } else { + neLicense.Capability = 0 neLicense.SerialNum = "" neLicense.ExpiryDate = "" 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 { neLicense.Status = "1" + neLicense.Capability = parse.Number(neState["capability"]) neLicense.SerialNum = fmt.Sprint(neState["sn"]) neLicense.ExpiryDate = fmt.Sprint(neState["expire"]) } else { @@ -274,9 +276,10 @@ func (s *NeLicenseController) State(c *gin.Context) { s.neLicenseService.Update(neLicense) if neLicense.Status == "1" { - c.JSON(200, resp.OkData(map[string]string{ - "sn": neLicense.SerialNum, - "expire": neLicense.ExpiryDate, + c.JSON(200, resp.OkData(map[string]any{ + "capability": neLicense.Capability, + "sn": neLicense.SerialNum, + "expire": neLicense.ExpiryDate, })) return } diff --git a/src/modules/network_element/model/ne_license.go b/src/modules/network_element/model/ne_license.go index 9b98c39f..016593b6 100644 --- a/src/modules/network_element/model/ne_license.go +++ b/src/modules/network_element/model/ne_license.go @@ -7,6 +7,7 @@ type NeLicense struct { NeId string `json:"neId" gorm:"column:ne_id" binding:"required"` // 网元ID ActivationRequestCode string `json:"activationRequestCode" gorm:"column:activation_request_code"` // 激活申请代码 LicensePath string `json:"licensePath" gorm:"column:license_path"` // 激活授权文件 + Capability int64 `json:"capability" gorm:"column:capability"` // 用户容量 SerialNum string `json:"serialNum" gorm:"column:serial_num"` // 序列号 ExpiryDate string `json:"expiryDate" gorm:"column:expiry_date"` // 许可证到期日期 Status string `json:"status" gorm:"column:status"` // 状态 0无效 1有效