优化代码

This commit is contained in:
GoEdgeLab
2022-12-14 17:32:24 +08:00
parent 4213f03ded
commit 47b5512eea
3 changed files with 6 additions and 6 deletions

View File

@@ -88,7 +88,7 @@ func (this *ClientAgentIPDAO) ListIPsAfterId(tx *dbs.Tx, id int64, size int64) (
} }
_, err = this.Query(tx). _, err = this.Query(tx).
Result("id", "ip", "agentId"). Result("id", "ip", "ptr", "agentId").
Gt("id", id). Gt("id", id).
AscPk(). AscPk().
Limit(size). // 限制单次读取个数 Limit(size). // 限制单次读取个数

View File

@@ -6,6 +6,7 @@ import (
"context" "context"
"github.com/TeaOSLab/EdgeAPI/internal/db/models/clients" "github.com/TeaOSLab/EdgeAPI/internal/db/models/clients"
"github.com/TeaOSLab/EdgeAPI/internal/rpc/services" "github.com/TeaOSLab/EdgeAPI/internal/rpc/services"
rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
) )
@@ -16,8 +17,7 @@ type ClientAgentIPService struct {
// CreateClientAgentIPs 创建一组IP // CreateClientAgentIPs 创建一组IP
func (this *ClientAgentIPService) CreateClientAgentIPs(ctx context.Context, req *pb.CreateClientAgentIPsRequest) (*pb.RPCSuccess, error) { func (this *ClientAgentIPService) CreateClientAgentIPs(ctx context.Context, req *pb.CreateClientAgentIPsRequest) (*pb.RPCSuccess, error) {
// 先不支持网站服务节点,避免影响普通用户 _, _, err := this.ValidateNodeId(ctx, rpcutils.UserTypeAdmin, rpcutils.UserTypeDNS)
_, err := this.ValidateNSNode(ctx)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -47,7 +47,7 @@ func (this *ClientAgentIPService) CreateClientAgentIPs(ctx context.Context, req
// ListClientAgentIPsAfterId 查询最新的IP // ListClientAgentIPsAfterId 查询最新的IP
func (this *ClientAgentIPService) ListClientAgentIPsAfterId(ctx context.Context, req *pb.ListClientAgentIPsAfterIdRequest) (*pb.ListClientAgentIPsAfterIdResponse, error) { func (this *ClientAgentIPService) ListClientAgentIPsAfterId(ctx context.Context, req *pb.ListClientAgentIPsAfterIdRequest) (*pb.ListClientAgentIPsAfterIdResponse, error) {
_, err := this.ValidateNSNode(ctx) _, _, err := this.ValidateNodeId(ctx, rpcutils.UserTypeAdmin, rpcutils.UserTypeDNS)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -81,7 +81,7 @@ func (this *ClientAgentIPService) ListClientAgentIPsAfterId(ctx context.Context,
pbIPs = append(pbIPs, &pb.ClientAgentIP{ pbIPs = append(pbIPs, &pb.ClientAgentIP{
Id: int64(agentIP.Id), Id: int64(agentIP.Id),
Ip: agentIP.IP, Ip: agentIP.IP,
Ptr: "", Ptr: agentIP.Ptr, // 导出时需要
ClientAgent: &pb.ClientAgent{ ClientAgent: &pb.ClientAgent{
Id: agentId, Id: agentId,
Name: "", Name: "",

File diff suppressed because one or more lines are too long