1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package agent
- import (
- "context"
- "github.com/suyuan32/simple-admin-common/msg/errormsg"
- "github.com/zeromicro/go-zero/core/errorx"
- "wechat-api/hook/fastgpt"
- "wechat-api/internal/svc"
- "wechat-api/internal/types"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type UpdateAgentDataLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewUpdateAgentDataLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateAgentDataLogic {
- return &UpdateAgentDataLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx}
- }
- func (l *UpdateAgentDataLogic) UpdateAgentData(req *types.UpdateDataInfoReq) (*types.BaseDataInfo, error) {
- params := fastgpt.UpdateDataReq{}
- params.DataId = *req.DataId
- params.Q = *req.Q
- params.A = *req.A
- resp, err := fastgpt.UpdateData(¶ms)
- if err != nil {
- return nil, errorx.NewInvalidArgumentError("fastgpt update data failed " + err.Error())
- }
- if resp.Code == 200 {
- return &types.BaseDataInfo{
- Code: 0,
- Msg: errormsg.Success,
- Data: "",
- }, nil
- }
- return nil, errorx.NewInvalidArgumentError(resp.Message)
- }
|