fix: 网元版本表结构变更接口调整

This commit is contained in:
TsMask
2024-05-07 18:38:41 +08:00
parent 8d0de23635
commit 7a1ce0faea

View File

@@ -8,11 +8,13 @@ import (
"os/exec" "os/exec"
"strings" "strings"
"be.ems/lib/core/utils/ctx"
"be.ems/lib/dborm" "be.ems/lib/dborm"
"be.ems/lib/log" "be.ems/lib/log"
"be.ems/lib/services" "be.ems/lib/services"
"be.ems/restagent/config" "be.ems/restagent/config"
neModel "be.ems/src/modules/network_element/model"
neService "be.ems/src/modules/network_element/service"
"github.com/gorilla/mux" "github.com/gorilla/mux"
) )
@@ -503,22 +505,54 @@ func UploadLicenseFileData(w http.ResponseWriter, r *http.Request) {
} }
} }
*/ */
neLicense := dborm.NeLicense{
NeType: neTypeUpper, // neLicense := dborm.NeLicense{
NeID: neId, // NeType: neTypeUpper,
Status: "ACTIVE", // NeID: neId,
Path: licensePath, // Status: "ACTIVE",
FileName: licenseFileName, // Path: licensePath,
Comment: comment, // FileName: licenseFileName,
// Comment: comment,
// }
// log.Debug("neLicense:", neLicense)
// _, err = dborm.XormInsertTableOne("ne_license", neLicense)
// if err != nil {
// log.Error("Faile to XormInsertTableOne:", err)
// services.ResponseInternalServerError500ProcessError(w, err)
// }
neLicense := neModel.NeLicense{
NeType: neTypeUpper,
NeId: neId,
Status: "0",
LicensePath: neFilePath,
Remark: comment,
} }
log.Debug("neLicense:", neLicense) log.Debug("neLicense:", neLicense)
_, err = dborm.XormInsertTableOne("ne_license", neLicense)
if err != nil { // 检查是否存在授权记录
log.Error("Faile to XormInsertTableOne:", err) neLicense2 := neService.NewNeLicenseImpl.SelectByNeTypeAndNeID(neTypeUpper, neId)
services.ResponseInternalServerError500ProcessError(w, err) if neLicense2.NeId != neId {
return // 读取授权码
code, _ := neService.NewNeLicenseImpl.ReadLicenseInfo(neLicense)
neLicense.ActivationRequestCode = code
neLicense.CreateBy = ctx.LoginUserToUserName(r)
insertId := neService.NewNeLicenseImpl.Insert(neLicense)
if insertId != "" {
services.ResponseStatusOK204NoContent(w)
return
}
} else {
neLicense2.UpdateBy = ctx.LoginUserToUserName(r)
upRows := neService.NewNeLicenseImpl.Update(neLicense2)
if upRows > 0 {
services.ResponseStatusOK204NoContent(w)
return
}
} }
services.ResponseStatusOK204NoContent(w) services.ResponseInternalServerError500ProcessError(w, err)
} }