mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-07 02:20:24 +08:00
优化API命名
This commit is contained in:
@@ -258,8 +258,8 @@ func (this *NodeService) ListEnabledNodesMatch(ctx context.Context, req *pb.List
|
||||
MaxCPU: types.Int32(node.MaxCPU),
|
||||
IsOn: node.IsOn == 1,
|
||||
IsUp: node.IsUp == 1,
|
||||
Group: pbGroup,
|
||||
Region: pbRegion,
|
||||
NodeGroup: pbGroup,
|
||||
NodeRegion: pbRegion,
|
||||
DnsRoutes: pbRoutes,
|
||||
})
|
||||
}
|
||||
@@ -524,8 +524,8 @@ func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnable
|
||||
InstallStatus: installStatusResult,
|
||||
MaxCPU: types.Int32(node.MaxCPU),
|
||||
IsOn: node.IsOn == 1,
|
||||
Group: pbGroup,
|
||||
Region: pbRegion,
|
||||
NodeGroup: pbGroup,
|
||||
NodeRegion: pbRegion,
|
||||
MaxCacheDiskCapacity: pbMaxCacheDiskCapacity,
|
||||
MaxCacheMemoryCapacity: pbMaxCacheMemoryCapacity,
|
||||
}}, nil
|
||||
@@ -731,7 +731,7 @@ func (this *NodeService) CountAllEnabledNodesWithNodeGrantId(ctx context.Context
|
||||
|
||||
tx := this.NullTx()
|
||||
|
||||
count, err := models.SharedNodeDAO.CountAllEnabledNodesWithGrantId(tx, req.GrantId)
|
||||
count, err := models.SharedNodeDAO.CountAllEnabledNodesWithGrantId(tx, req.NodeGrantId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -748,7 +748,7 @@ func (this *NodeService) FindAllEnabledNodesWithNodeGrantId(ctx context.Context,
|
||||
|
||||
tx := this.NullTx()
|
||||
|
||||
nodes, err := models.SharedNodeDAO.FindAllEnabledNodesWithGrantId(tx, req.GrantId)
|
||||
nodes, err := models.SharedNodeDAO.FindAllEnabledNodesWithGrantId(tx, req.NodeGrantId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func (this *NodeClusterService) CreateNodeCluster(ctx context.Context, req *pb.C
|
||||
|
||||
var clusterId int64
|
||||
err = this.RunTx(func(tx *dbs.Tx) error {
|
||||
clusterId, err = models.SharedNodeClusterDAO.CreateCluster(tx, adminId, req.Name, req.GrantId, req.InstallDir, req.DnsDomainId, req.DnsName, req.HttpCachePolicyId, req.HttpFirewallPolicyId, systemServices)
|
||||
clusterId, err = models.SharedNodeClusterDAO.CreateCluster(tx, adminId, req.Name, req.NodeGrantId, req.InstallDir, req.DnsDomainId, req.DnsName, req.HttpCachePolicyId, req.HttpFirewallPolicyId, systemServices)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -62,7 +62,7 @@ func (this *NodeClusterService) UpdateNodeCluster(ctx context.Context, req *pb.U
|
||||
|
||||
tx := this.NullTx()
|
||||
|
||||
err = models.SharedNodeClusterDAO.UpdateCluster(tx, req.NodeClusterId, req.Name, req.GrantId, req.InstallDir)
|
||||
err = models.SharedNodeClusterDAO.UpdateCluster(tx, req.NodeClusterId, req.Name, req.NodeGrantId, req.InstallDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -120,7 +120,7 @@ func (this *NodeClusterService) FindEnabledNodeCluster(ctx context.Context, req
|
||||
Name: cluster.Name,
|
||||
CreatedAt: int64(cluster.CreatedAt),
|
||||
InstallDir: cluster.InstallDir,
|
||||
GrantId: int64(cluster.GrantId),
|
||||
NodeGrantId: int64(cluster.GrantId),
|
||||
UniqueId: cluster.UniqueId,
|
||||
Secret: cluster.Secret,
|
||||
HttpCachePolicyId: int64(cluster.CachePolicyId),
|
||||
@@ -252,7 +252,7 @@ func (this *NodeClusterService) ListEnabledNodeClusters(ctx context.Context, req
|
||||
Id: int64(cluster.Id),
|
||||
Name: cluster.Name,
|
||||
CreatedAt: int64(cluster.CreatedAt),
|
||||
GrantId: int64(cluster.GrantId),
|
||||
NodeGrantId: int64(cluster.GrantId),
|
||||
InstallDir: cluster.InstallDir,
|
||||
UniqueId: cluster.UniqueId,
|
||||
Secret: cluster.Secret,
|
||||
@@ -341,7 +341,7 @@ func (this *NodeClusterService) CountAllEnabledNodeClustersWithNodeGrantId(ctx c
|
||||
|
||||
tx := this.NullTx()
|
||||
|
||||
count, err := models.SharedNodeClusterDAO.CountAllEnabledClustersWithGrantId(tx, req.GrantId)
|
||||
count, err := models.SharedNodeClusterDAO.CountAllEnabledClustersWithGrantId(tx, req.NodeGrantId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -358,7 +358,7 @@ func (this *NodeClusterService) FindAllEnabledNodeClustersWithNodeGrantId(ctx co
|
||||
|
||||
tx := this.NullTx()
|
||||
|
||||
clusters, err := models.SharedNodeClusterDAO.FindAllEnabledClustersWithGrantId(tx, req.GrantId)
|
||||
clusters, err := models.SharedNodeClusterDAO.FindAllEnabledClustersWithGrantId(tx, req.NodeGrantId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ func (this *NodeGroupService) CreateNodeGroup(ctx context.Context, req *pb.Creat
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &pb.CreateNodeGroupResponse{GroupId: groupId}, nil
|
||||
return &pb.CreateNodeGroupResponse{NodeGroupId: groupId}, nil
|
||||
}
|
||||
|
||||
// UpdateNodeGroup 修改分组
|
||||
@@ -39,7 +39,7 @@ func (this *NodeGroupService) UpdateNodeGroup(ctx context.Context, req *pb.Updat
|
||||
|
||||
tx := this.NullTx()
|
||||
|
||||
err = models.SharedNodeGroupDAO.UpdateNodeGroup(tx, req.GroupId, req.Name)
|
||||
err = models.SharedNodeGroupDAO.UpdateNodeGroup(tx, req.NodeGroupId, req.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -57,7 +57,7 @@ func (this *NodeGroupService) DeleteNodeGroup(ctx context.Context, req *pb.Delet
|
||||
|
||||
tx := this.NullTx()
|
||||
|
||||
_, err = models.SharedNodeGroupDAO.DisableNodeGroup(tx, req.GroupId)
|
||||
_, err = models.SharedNodeGroupDAO.DisableNodeGroup(tx, req.NodeGroupId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -86,7 +86,7 @@ func (this *NodeGroupService) FindAllEnabledNodeGroupsWithNodeClusterId(ctx cont
|
||||
Name: group.Name,
|
||||
})
|
||||
}
|
||||
return &pb.FindAllEnabledNodeGroupsWithNodeClusterIdResponse{Groups: result}, nil
|
||||
return &pb.FindAllEnabledNodeGroupsWithNodeClusterIdResponse{NodeGroups: result}, nil
|
||||
}
|
||||
|
||||
// UpdateNodeGroupOrders 修改分组排序
|
||||
@@ -99,7 +99,7 @@ func (this *NodeGroupService) UpdateNodeGroupOrders(ctx context.Context, req *pb
|
||||
|
||||
tx := this.NullTx()
|
||||
|
||||
err = models.SharedNodeGroupDAO.UpdateGroupOrders(tx, req.GroupIds)
|
||||
err = models.SharedNodeGroupDAO.UpdateGroupOrders(tx, req.NodeGroupIds)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -116,18 +116,18 @@ func (this *NodeGroupService) FindEnabledNodeGroup(ctx context.Context, req *pb.
|
||||
|
||||
tx := this.NullTx()
|
||||
|
||||
group, err := models.SharedNodeGroupDAO.FindEnabledNodeGroup(tx, req.GroupId)
|
||||
group, err := models.SharedNodeGroupDAO.FindEnabledNodeGroup(tx, req.NodeGroupId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if group == nil {
|
||||
return &pb.FindEnabledNodeGroupResponse{
|
||||
Group: nil,
|
||||
NodeGroup: nil,
|
||||
}, nil
|
||||
}
|
||||
|
||||
return &pb.FindEnabledNodeGroupResponse{
|
||||
Group: &pb.NodeGroup{
|
||||
NodeGroup: &pb.NodeGroup{
|
||||
Id: int64(group.Id),
|
||||
Name: group.Name,
|
||||
},
|
||||
|
||||
@@ -580,7 +580,7 @@ func (this *ServerService) ListEnabledServersMatch(ctx context.Context, req *pb.
|
||||
Id: int64(server.ClusterId),
|
||||
Name: clusterName,
|
||||
},
|
||||
Groups: pbGroups,
|
||||
ServerGroups: pbGroups,
|
||||
User: pbUser,
|
||||
})
|
||||
}
|
||||
@@ -711,7 +711,7 @@ func (this *ServerService) FindEnabledServer(ctx context.Context, req *pb.FindEn
|
||||
Id: int64(server.ClusterId),
|
||||
Name: clusterName,
|
||||
},
|
||||
Groups: pbGroups,
|
||||
ServerGroups: pbGroups,
|
||||
User: pbUser,
|
||||
}}, nil
|
||||
}
|
||||
|
||||
@@ -7,12 +7,12 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
// 服务分组相关服务
|
||||
// ServerGroupService 服务分组相关服务
|
||||
type ServerGroupService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建分组
|
||||
// CreateServerGroup 创建分组
|
||||
func (this *ServerGroupService) CreateServerGroup(ctx context.Context, req *pb.CreateServerGroupRequest) (*pb.CreateServerGroupResponse, error) {
|
||||
// 校验请求
|
||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||
@@ -26,10 +26,10 @@ func (this *ServerGroupService) CreateServerGroup(ctx context.Context, req *pb.C
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &pb.CreateServerGroupResponse{GroupId: groupId}, nil
|
||||
return &pb.CreateServerGroupResponse{ServerGroupId: groupId}, nil
|
||||
}
|
||||
|
||||
// 修改分组
|
||||
// UpdateServerGroup 修改分组
|
||||
func (this *ServerGroupService) UpdateServerGroup(ctx context.Context, req *pb.UpdateServerGroupRequest) (*pb.RPCSuccess, error) {
|
||||
// 校验请求
|
||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||
@@ -39,7 +39,7 @@ func (this *ServerGroupService) UpdateServerGroup(ctx context.Context, req *pb.U
|
||||
|
||||
tx := this.NullTx()
|
||||
|
||||
err = models.SharedServerGroupDAO.UpdateGroup(tx, req.GroupId, req.Name)
|
||||
err = models.SharedServerGroupDAO.UpdateGroup(tx, req.ServerGroupId, req.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -47,7 +47,7 @@ func (this *ServerGroupService) UpdateServerGroup(ctx context.Context, req *pb.U
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 删除分组
|
||||
// DeleteServerGroup 删除分组
|
||||
func (this *ServerGroupService) DeleteServerGroup(ctx context.Context, req *pb.DeleteServerGroupRequest) (*pb.RPCSuccess, error) {
|
||||
// 校验请求
|
||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||
@@ -57,7 +57,7 @@ func (this *ServerGroupService) DeleteServerGroup(ctx context.Context, req *pb.D
|
||||
|
||||
tx := this.NullTx()
|
||||
|
||||
err = models.SharedServerGroupDAO.DisableServerGroup(tx, req.GroupId)
|
||||
err = models.SharedServerGroupDAO.DisableServerGroup(tx, req.ServerGroupId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -65,7 +65,7 @@ func (this *ServerGroupService) DeleteServerGroup(ctx context.Context, req *pb.D
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 查询所有分组
|
||||
// FindAllEnabledServerGroups 查询所有分组
|
||||
func (this *ServerGroupService) FindAllEnabledServerGroups(ctx context.Context, req *pb.FindAllEnabledServerGroupsRequest) (*pb.FindAllEnabledServerGroupsResponse, error) {
|
||||
// 校验请求
|
||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||
@@ -86,10 +86,10 @@ func (this *ServerGroupService) FindAllEnabledServerGroups(ctx context.Context,
|
||||
Name: group.Name,
|
||||
})
|
||||
}
|
||||
return &pb.FindAllEnabledServerGroupsResponse{Groups: result}, nil
|
||||
return &pb.FindAllEnabledServerGroupsResponse{ServerGroups: result}, nil
|
||||
}
|
||||
|
||||
// 修改分组排序
|
||||
// UpdateServerGroupOrders 修改分组排序
|
||||
func (this *ServerGroupService) UpdateServerGroupOrders(ctx context.Context, req *pb.UpdateServerGroupOrdersRequest) (*pb.RPCSuccess, error) {
|
||||
// 校验请求
|
||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||
@@ -99,14 +99,14 @@ func (this *ServerGroupService) UpdateServerGroupOrders(ctx context.Context, req
|
||||
|
||||
tx := this.NullTx()
|
||||
|
||||
err = models.SharedServerGroupDAO.UpdateGroupOrders(tx, req.GroupIds)
|
||||
err = models.SharedServerGroupDAO.UpdateGroupOrders(tx, req.ServerGroupIds)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 查找单个分组信息
|
||||
// FindEnabledServerGroup 查找单个分组信息
|
||||
func (this *ServerGroupService) FindEnabledServerGroup(ctx context.Context, req *pb.FindEnabledServerGroupRequest) (*pb.FindEnabledServerGroupResponse, error) {
|
||||
// 校验请求
|
||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||
@@ -116,18 +116,18 @@ func (this *ServerGroupService) FindEnabledServerGroup(ctx context.Context, req
|
||||
|
||||
tx := this.NullTx()
|
||||
|
||||
group, err := models.SharedServerGroupDAO.FindEnabledServerGroup(tx, req.GroupId)
|
||||
group, err := models.SharedServerGroupDAO.FindEnabledServerGroup(tx, req.ServerGroupId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if group == nil {
|
||||
return &pb.FindEnabledServerGroupResponse{
|
||||
Group: nil,
|
||||
ServerGroup: nil,
|
||||
}, nil
|
||||
}
|
||||
|
||||
return &pb.FindEnabledServerGroupResponse{
|
||||
Group: &pb.ServerGroup{
|
||||
ServerGroup: &pb.ServerGroup{
|
||||
Id: int64(group.Id),
|
||||
Name: group.Name,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user