f
This commit is contained in:
43
app/main/api/internal/logic/toolbox/toolboxlistlogic.go
Normal file
43
app/main/api/internal/logic/toolbox/toolboxlistlogic.go
Normal file
@@ -0,0 +1,43 @@
|
||||
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
|
||||
}
|
||||
37
app/main/api/internal/logic/toolbox/toolboxquerylogic.go
Normal file
37
app/main/api/internal/logic/toolbox/toolboxquerylogic.go
Normal file
@@ -0,0 +1,37 @@
|
||||
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 ToolboxQueryLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewToolboxQueryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ToolboxQueryLogic {
|
||||
return &ToolboxQueryLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ToolboxQueryLogic) ToolboxQuery(req *types.ToolboxQueryReq) (resp *types.ToolboxQueryResp, err error) {
|
||||
// 调用toolboxService执行工具查询
|
||||
result, err := l.svcCtx.ToolboxService.Query(l.ctx, req.ToolKey, req.Params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.ToolboxQueryResp{
|
||||
ToolKey: req.ToolKey,
|
||||
Result: result,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user