mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-03 07:00:26 +08:00
优化API命名
This commit is contained in:
@@ -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