1
0

merge: 合并代码20240531

This commit is contained in:
TsMask
2024-06-01 18:56:18 +08:00
parent 3cc193f57d
commit 3b50e2f3f8
129 changed files with 3705 additions and 11065 deletions

View File

@@ -10,9 +10,9 @@ import (
"strings"
"be.ems/features/sys_role/model"
"be.ems/lib/log"
"be.ems/lib/oauth"
"be.ems/src/modules/system/model"
_ "github.com/go-sql-driver/mysql"
"xorm.io/xorm"
@@ -1402,11 +1402,11 @@ type MeasureThreshold struct {
type NeSoftware struct {
Id int `json:"id" xorm:"pk 'id' autoincr"`
NeType string `json:"neType" xorm:"ne_type"`
FileName string `json:"neName" xorm:"file_name"`
Path string `json:"path"`
Version string `json:"version"`
Md5Sum string `json:"md5Sum" xorm:"md5_sum"`
Comment string `json:"comment"`
FileName string `json:"fileName" xorm:"name"`
Path string `json:"path" xorm:"path"`
Version string `json:"version" `
Md5Sum string `json:"md5Sum" xorm:"-"`
Comment string `json:"comment" xorm:"description"`
// Status string `json:"status"`
UpdateTime string `json:"createTime" xorm:"-" `
}
@@ -1415,18 +1415,18 @@ type NeVersion struct {
Id int `json:"id" xorm:"pk 'id' autoincr"`
NeType string `json:"neType" xorm:"ne_type"`
NeId string `json:"neId" xorm:"ne_id"`
Version string `json:"version"`
FilePath string `json:"filePath" xorm:"file_path"`
Version string `json:"version" `
FilePath string `json:"filePath" xorm:"path"`
NewVersion string `json:"newVersion" xorm:"new_version"`
NewFile string `json:"newFile" xorm:"new_file"`
NewFile string `json:"newFile" xorm:"new_path"`
PreVersion string `json:"preVersion" xorm:"pre_version"`
PreFile string `json:"preFile" xorm:"pre_file"`
Status string `json:"status"`
PreFile string `json:"preFile" xorm:"pre_path"`
Status string `json:"status" xorm:"status"`
UpdateTime string `json:"createTime" xorm:"-" `
}
func XormGetDataBySQL(sql string) (*[]map[string]string, error) {
//log.Debug("XormGetDataBySQL processing... ")
log.Debug("XormGetDataBySQL processing... ")
rows := make([]map[string]string, 0)
rows, err := DbClient.XEngine.QueryString(sql)
@@ -1708,25 +1708,26 @@ func IsPermissionAllowed(token, method, module, dbname, tbname, pack string) (bo
type NeLicense struct {
NeType string `json:"neType" xorm:"ne_type"`
NeID string `json:"neID" xorm:"ne_id"`
SerialNo string `json:"serialNo" xorm:"serial_no"`
Capcity int `json:"capcity" xorm:"capcity"`
Used int `json:"used" xorm:"used"`
FeatureEnabled string `json:"featureEnabled" xorm:"feature_enabled"`
ExpirationDate string `json:"expirationDate" xorm:"expiration_date"`
SerialNo string `json:"serialNo" xorm:"serial_num"`
Capcity int `json:"capcity" xorm:"-"`
Used int `json:"used" xorm:"-"`
FeatureEnabled string `json:"featureEnabled" xorm:"-"`
ExpirationDate string `json:"expirationDate" xorm:"expiry_date"`
Status string `json:"status" xorm:"status"`
Path string `json:"path" xorm:"path"`
FileName string `json:"file_name" xorm:"file_name"`
Comment string `json:"comment" xorm:"comment"`
Path string `json:"path" xorm:"license_path"`
FileName string `json:"file_name" xorm:"-"`
Comment string `json:"comment" xorm:"remark"`
CreatedAt string `json:"createdAt" xorm:"-"`
UpdatedAt string `json:"updatedAt" xorm:"-"`
DeletedAt string `json:"deletedAt" xorm:"-"`
}
func XormAdjustmentNeLicense(neType, neID string, value int) (int64, error) {
return 1, nil
//neLicense := NeLicense{NeType: neType, NeID: neID, Capability: value}
// session.LogoutTime.Valid = true
// session.LogoutTime.Time = time.Now()
res, err := xEngine.Exec("update ne_license set capcity=capcity+? where IFNULL(ne_type, '')=? and IFNULL(ne_id, '')=?", value, neType, neID)
// res, err := xEngine.Exec("update ne_license set capcity=capcity+? where IFNULL(ne_type, '')=? and IFNULL(ne_id, '')=?", value, neType, neID)
// defer xSession.Close()
//affected, err := xSession.Table("ne_license").Where("ne_type=? and ne_id=?", neType, neID).Update(&neLicense)
@@ -1734,25 +1735,26 @@ func XormAdjustmentNeLicense(neType, neID string, value int) (int64, error) {
// //affected, err := xSession.Table("ne_license").SQL("ne_tye=? and ne_id=?", neType, neID).Update(session)
// err := xSession.SQL("update ne_license set capability=capability+? where ne_type=? and ne_id=?", value, neType, neID)
//xSession.Commit()
affected, err := res.RowsAffected()
return affected, err
// affected, err := res.RowsAffected()
// return affected, err
}
func XormUpdateNeLicense(neType, neID string, capcity int) (int64, error) {
var err error
var res sql.Result
if neType != "" && neID != "" {
res, err = xEngine.Exec("update ne_license set capcity=? where ne_type=? and ne_id=?", capcity, neType, neID)
} else if neType != "" && neID == "" {
res, err = xEngine.Exec("update ne_license set capcity=? where ne_type=?", capcity, neType)
} else if neType == "" && neID != "" {
res, err = xEngine.Exec("update ne_license set capcity=? where ne_id=?", capcity, neID)
} else {
res, err = xEngine.Exec("update ne_license set capcity=?", capcity)
}
return 1, nil
// var err error
// var res sql.Result
// if neType != "" && neID != "" {
// res, err = xEngine.Exec("update ne_license set capcity=? where ne_type=? and ne_id=?", capcity, neType, neID)
// } else if neType != "" && neID == "" {
// res, err = xEngine.Exec("update ne_license set capcity=? where ne_type=?", capcity, neType)
// } else if neType == "" && neID != "" {
// res, err = xEngine.Exec("update ne_license set capcity=? where ne_id=?", capcity, neID)
// } else {
// res, err = xEngine.Exec("update ne_license set capcity=?", capcity)
// }
affected, err := res.RowsAffected()
return affected, err
// affected, err := res.RowsAffected()
// return affected, err
}
type NorthboundCm struct {
@@ -1777,21 +1779,21 @@ func XormGetNorthboundCm(neType string, cmResults *[]NorthboundCm) error {
log.Info("XormGetNorthboundCm processing... ")
cmResult := new(NorthboundCm)
rows, err := xEngine.Table("northbound_cm").
rows, err := xEngine.Table("nbi_cm").
Distinct("object_type").
Where("`ne_type` = ?", neType).
Desc("timestamp").
Cols("*").
Rows(cmResult)
if err != nil {
log.Error("Failed to get table northbound_cm:", err)
log.Error("Failed to get table nbi_cm:", err)
return err
}
defer rows.Close()
for rows.Next() {
err := rows.Scan(cmResult)
if err != nil {
log.Error("Failed to get table northbound_cm:", err)
log.Error("Failed to get table nbi_cm:", err)
return err
}
*cmResults = append(*cmResults, *cmResult)
@@ -1803,14 +1805,14 @@ func XormGetNorthboundCmLatestObject(neType, neID, objectType string) (*Northbou
log.Info("XormGetNorthboundCmLatestObject processing... ")
cmResult := new(NorthboundCm)
_, err := xEngine.Table("northbound_cm").
_, err := xEngine.Table("nbi_cm").
Where("`ne_type`=? and `ne_id`=? and `object_type`=?", neType, neID, objectType).
Desc("timestamp").
Cols("*").
Limit(1).
Get(cmResult)
if err != nil {
log.Error("Failed to get table northbound_cm:", err)
log.Error("Failed to get table nbi_cm:", err)
return nil, err
}