package agent import ( "context" "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 GetAgentCollectionListLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } func NewGetAgentCollectionListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAgentCollectionListLogic { return &GetAgentCollectionListLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx} } func (l *GetAgentCollectionListLogic) GetAgentCollectionList(req *types.CollectionListReq) (*types.CollectionListResp, error) { collectionResp := types.CollectionListResp{} collectionResp.PageNum = req.PageNum collectionResp.PageSize = req.PageSize var total int params := fastgpt.GetCollectionListReq{} params.DatasetId = *req.DatasetId params.PageNum = *req.PageNum params.PageSize = *req.PageSize resp, err := fastgpt.GetCollectionList(¶ms) if err != nil { return nil, errorx.NewInvalidArgumentError("fastgpt error" + err.Error()) } collectionResp.Data = make([]types.CollectionSimpleInfo, 0, 1) collectionResp.Total = &total if resp.Code == 200 && resp.Data.Total > 0 { for _, val := range resp.Data.Data { collectionResp.Data = append(collectionResp.Data, types.CollectionSimpleInfo{ ID: &val.ID, ParentID: &val.ParentID, TmbId: &val.TmbID, Type: &val.Type, Name: &val.Name, DataAmount: &val.DataAmount, TrainingAmount: &val.TrainingAmount, }) } collectionResp.Total = &resp.Data.Total } return &collectionResp, nil }