mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-06 01:50:25 +08:00
统计创建浏览器、系统时限制名称长度
This commit is contained in:
@@ -104,6 +104,11 @@ func (this *ClientBrowserDAO) FindBrowserIdWithNameCacheable(tx *dbs.Tx, browser
|
|||||||
|
|
||||||
// CreateBrowser 创建浏览器
|
// CreateBrowser 创建浏览器
|
||||||
func (this *ClientBrowserDAO) CreateBrowser(tx *dbs.Tx, browserName string) (int64, error) {
|
func (this *ClientBrowserDAO) CreateBrowser(tx *dbs.Tx, browserName string) (int64, error) {
|
||||||
|
var maxlength = 50
|
||||||
|
if len(browserName) > maxlength {
|
||||||
|
browserName = browserName[:50]
|
||||||
|
}
|
||||||
|
|
||||||
SharedCacheLocker.Lock()
|
SharedCacheLocker.Lock()
|
||||||
defer SharedCacheLocker.Unlock()
|
defer SharedCacheLocker.Unlock()
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,11 @@ func (this *ClientSystemDAO) FindSystemIdWithNameCacheable(tx *dbs.Tx, systemNam
|
|||||||
|
|
||||||
// CreateSystem 创建浏览器
|
// CreateSystem 创建浏览器
|
||||||
func (this *ClientSystemDAO) CreateSystem(tx *dbs.Tx, systemName string) (int64, error) {
|
func (this *ClientSystemDAO) CreateSystem(tx *dbs.Tx, systemName string) (int64, error) {
|
||||||
|
var maxlength = 50
|
||||||
|
if len(systemName) > maxlength {
|
||||||
|
systemName = systemName[:50]
|
||||||
|
}
|
||||||
|
|
||||||
SharedCacheLocker.Lock()
|
SharedCacheLocker.Lock()
|
||||||
defer SharedCacheLocker.Unlock()
|
defer SharedCacheLocker.Unlock()
|
||||||
|
|
||||||
|
|||||||
@@ -23,10 +23,16 @@ func (this *NodeClusterMetricItemService) EnableNodeClusterMetricItem(ctx contex
|
|||||||
}
|
}
|
||||||
|
|
||||||
var tx = this.NullTx()
|
var tx = this.NullTx()
|
||||||
err = models.SharedNodeClusterMetricItemDAO.EnableClusterItem(tx, req.NodeClusterId, req.MetricItemId)
|
exists, err := models.SharedNodeClusterMetricItemDAO.ExistsClusterItem(tx, req.NodeClusterId, req.MetricItemId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if !exists {
|
||||||
|
err = models.SharedNodeClusterMetricItemDAO.EnableClusterItem(tx, req.NodeClusterId, req.MetricItemId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
return this.Success()
|
return this.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +59,7 @@ func (this *NodeClusterMetricItemService) FindAllNodeClusterMetricItems(ctx cont
|
|||||||
}
|
}
|
||||||
|
|
||||||
var tx = this.NullTx()
|
var tx = this.NullTx()
|
||||||
clusterItems, err := models.SharedNodeClusterMetricItemDAO.FindAllClusterItems(tx, req.NodeClusterId)
|
clusterItems, err := models.SharedNodeClusterMetricItemDAO.FindAllClusterItems(tx, req.NodeClusterId, req.Category)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -79,3 +85,18 @@ func (this *NodeClusterMetricItemService) FindAllNodeClusterMetricItems(ctx cont
|
|||||||
}
|
}
|
||||||
return &pb.FindAllNodeClusterMetricItemsResponse{MetricItems: pbItems}, nil
|
return &pb.FindAllNodeClusterMetricItemsResponse{MetricItems: pbItems}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExistsNodeClusterMetricItem 检查是否已添加某个指标
|
||||||
|
func (this *NodeClusterMetricItemService) ExistsNodeClusterMetricItem(ctx context.Context, req *pb.ExistsNodeClusterMetricItemRequest) (*pb.RPCExists, error) {
|
||||||
|
_, err := this.ValidateAdmin(ctx, 0)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var tx = this.NullTx()
|
||||||
|
b, err := models.SharedNodeClusterMetricItemDAO.ExistsClusterItem(tx, req.NodeClusterId, req.MetricItemId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return this.Exists(b)
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 操作系统统计
|
// ServerClientBrowserMonthlyStatService 操作系统统计
|
||||||
type ServerClientBrowserMonthlyStatService struct {
|
type ServerClientBrowserMonthlyStatService struct {
|
||||||
BaseService
|
BaseService
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找前N个操作系统
|
// FindTopServerClientBrowserMonthlyStats 查找前N个操作系统
|
||||||
func (this *ServerClientBrowserMonthlyStatService) FindTopServerClientBrowserMonthlyStats(ctx context.Context, req *pb.FindTopServerClientBrowserMonthlyStatsRequest) (*pb.FindTopServerClientBrowserMonthlyStatsResponse, error) {
|
func (this *ServerClientBrowserMonthlyStatService) FindTopServerClientBrowserMonthlyStats(ctx context.Context, req *pb.FindTopServerClientBrowserMonthlyStatsRequest) (*pb.FindTopServerClientBrowserMonthlyStatsResponse, error) {
|
||||||
_, userId, err := this.ValidateAdminAndUser(ctx, 0, 0)
|
_, userId, err := this.ValidateAdminAndUser(ctx, 0, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 操作系统统计
|
// ServerClientSystemMonthlyStatService 操作系统统计
|
||||||
type ServerClientSystemMonthlyStatService struct {
|
type ServerClientSystemMonthlyStatService struct {
|
||||||
BaseService
|
BaseService
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找前N个操作系统
|
// FindTopServerClientSystemMonthlyStats 查找前N个操作系统
|
||||||
func (this *ServerClientSystemMonthlyStatService) FindTopServerClientSystemMonthlyStats(ctx context.Context, req *pb.FindTopServerClientSystemMonthlyStatsRequest) (*pb.FindTopServerClientSystemMonthlyStatsResponse, error) {
|
func (this *ServerClientSystemMonthlyStatService) FindTopServerClientSystemMonthlyStats(ctx context.Context, req *pb.FindTopServerClientSystemMonthlyStatsRequest) (*pb.FindTopServerClientSystemMonthlyStatsResponse, error) {
|
||||||
_, userId, err := this.ValidateAdminAndUser(ctx, 0, 0)
|
_, userId, err := this.ValidateAdminAndUser(ctx, 0, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user