feat: 新增 MCP 模块
- mcp_handler.go, mcp.go, mcp_repo.go, mcp_service.go Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
42
server/internal/service/mcp_service.go
Normal file
42
server/internal/service/mcp_service.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"x-agents/server/internal/model"
|
||||
"x-agents/server/internal/repository"
|
||||
)
|
||||
|
||||
type MCPService struct {
|
||||
mcpRepo *repository.MCPRepository
|
||||
}
|
||||
|
||||
func NewMCPService(mcpRepo *repository.MCPRepository) *MCPService {
|
||||
return &MCPService{mcpRepo: mcpRepo}
|
||||
}
|
||||
|
||||
func (s *MCPService) GetAllMCPs() ([]model.MCP, error) {
|
||||
return s.mcpRepo.FindAll()
|
||||
}
|
||||
|
||||
func (s *MCPService) GetMCPByID(id string) (*model.MCP, error) {
|
||||
return s.mcpRepo.FindByID(id)
|
||||
}
|
||||
|
||||
func (s *MCPService) GetMCPByName(name string) (*model.MCP, error) {
|
||||
return s.mcpRepo.FindByName(name)
|
||||
}
|
||||
|
||||
func (s *MCPService) GetMCPsByCategory(category string) ([]model.MCP, error) {
|
||||
return s.mcpRepo.FindByCategory(category)
|
||||
}
|
||||
|
||||
func (s *MCPService) CreateMCP(mcp *model.MCP) error {
|
||||
return s.mcpRepo.Create(mcp)
|
||||
}
|
||||
|
||||
func (s *MCPService) UpdateMCP(mcp *model.MCP) error {
|
||||
return s.mcpRepo.Update(mcp)
|
||||
}
|
||||
|
||||
func (s *MCPService) DeleteMCP(id string) error {
|
||||
return s.mcpRepo.Delete(id)
|
||||
}
|
||||
Reference in New Issue
Block a user