fix: 网元激活码多行行内容提取
This commit is contained in:
@@ -2,6 +2,7 @@ package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
@@ -257,7 +258,9 @@ func (s *NeLicenseController) State(c *gin.Context) {
|
||||
neLicense.ExpiryDate = fmt.Sprint(neState["expire"])
|
||||
} else {
|
||||
neLicense.Status = "0"
|
||||
// 更新授权码
|
||||
}
|
||||
// 更新授权码
|
||||
if neLicense.ActivationRequestCode == "" || strings.HasPrefix(neLicense.ActivationRequestCode, "SN") || neLicense.Status == "0" {
|
||||
code, licensePath := s.neLicenseService.ReadLicenseInfo(neLicense)
|
||||
neLicense.ActivationRequestCode = code
|
||||
neLicense.LicensePath = licensePath
|
||||
|
||||
@@ -136,7 +136,13 @@ func (r *NeLicense) ReadLicenseInfo(neLicense model.NeLicense) (string, string)
|
||||
if err = sftpClient.CopyFileRemoteToLocal(nePath+"/system.ini", omcPath+"/system.ini"); err == nil {
|
||||
licensePath = omcPath + "/system.ini"
|
||||
}
|
||||
return strings.TrimSpace(string(bytes)), licensePath
|
||||
|
||||
activationRequestCode := string(bytes)
|
||||
parts := strings.Split(activationRequestCode, "\n")
|
||||
if len(parts) > 1 && strings.HasPrefix(parts[0], "SN") {
|
||||
activationRequestCode = parts[1] // 获取第二行内容
|
||||
}
|
||||
return strings.TrimSpace(activationRequestCode), licensePath
|
||||
}
|
||||
|
||||
// UploadLicense 授权文件上传到网元主机
|
||||
|
||||
Reference in New Issue
Block a user