feat: add toolbox query, upload module, update config and gitignore
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
47
app/main/api/internal/logic/toolbox/toolboxquerylogic.go
Normal file
47
app/main/api/internal/logic/toolbox/toolboxquerylogic.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package toolbox
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"qnc-server/app/main/api/internal/svc"
|
||||
"qnc-server/app/main/api/internal/types"
|
||||
"qnc-server/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"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) (*types.ToolboxQueryResp, error) {
|
||||
if req.ToolKey == "" {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("tool_key 不能为空"), "")
|
||||
}
|
||||
if l.svcCtx.ToolboxService == nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "工具箱服务未初始化")
|
||||
}
|
||||
params := req.Params
|
||||
if params == nil {
|
||||
params = map[string]interface{}{}
|
||||
}
|
||||
result, err := l.svcCtx.ToolboxService.Query(l.ctx, req.ToolKey, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &types.ToolboxQueryResp{
|
||||
ToolKey: req.ToolKey,
|
||||
Result: result,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user