mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-23 15:00:25 +08:00
智能DNS初步支持搜索引擎线路
This commit is contained in:
40
internal/rpc/services/clients/service_client_agent.go
Normal file
40
internal/rpc/services/clients/service_client_agent.go
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package clients
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/db/models/clients"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/rpc/services"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
// ClientAgentService Agent服务
|
||||
type ClientAgentService struct {
|
||||
services.BaseService
|
||||
}
|
||||
|
||||
// FindAllClientAgents 查找所有Agent
|
||||
func (this *ClientAgentService) FindAllClientAgents(ctx context.Context, req *pb.FindAllClientAgentsRequest) (*pb.FindAllClientAgentsResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var tx = this.NullTx()
|
||||
agents, err := clients.SharedClientAgentDAO.FindAllAgents(tx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var pbAgents = []*pb.ClientAgent{}
|
||||
for _, agent := range agents {
|
||||
pbAgents = append(pbAgents, &pb.ClientAgent{
|
||||
Id: int64(agent.Id),
|
||||
Name: agent.Name,
|
||||
Code: agent.Code,
|
||||
Description: agent.Description,
|
||||
CountIPs: int64(agent.CountIPs),
|
||||
})
|
||||
}
|
||||
return &pb.FindAllClientAgentsResponse{ClientAgents: pbAgents}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user