44 lines
898 B
Go
44 lines
898 B
Go
package toolbox
|
|
|
|
import (
|
|
"context"
|
|
|
|
"tyc-server/app/main/api/internal/svc"
|
|
"tyc-server/app/main/api/internal/types"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type ToolboxListLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewToolboxListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ToolboxListLogic {
|
|
return &ToolboxListLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *ToolboxListLogic) ToolboxList() (resp *types.ToolboxListResp, err error) {
|
|
// 调用toolboxService获取工具列表
|
|
tools := l.svcCtx.ToolboxService.ListTools()
|
|
|
|
// 转换为响应格式
|
|
var toolInfos []types.ToolInfo
|
|
for _, tool := range tools {
|
|
toolInfos = append(toolInfos, types.ToolInfo{
|
|
Key: tool.Key,
|
|
Name: tool.Name,
|
|
Desc: tool.Desc,
|
|
})
|
|
}
|
|
|
|
return &types.ToolboxListResp{
|
|
Tools: toolInfos,
|
|
}, nil
|
|
}
|