|
@@ -2,8 +2,7 @@ package agent
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
- "errors"
|
|
|
- "fmt"
|
|
|
+ "github.com/zeromicro/go-zero/core/errorx"
|
|
|
"wechat-api/hook/fastgpt"
|
|
|
|
|
|
"wechat-api/internal/svc"
|
|
@@ -27,26 +26,23 @@ func NewGetAgentCollectionListLogic(ctx context.Context, svcCtx *svc.ServiceCont
|
|
|
|
|
|
func (l *GetAgentCollectionListLogic) GetAgentCollectionList(req *types.CollectionListReq) (*types.CollectionListResp, error) {
|
|
|
collectionResp := types.CollectionListResp{}
|
|
|
+ collectionResp.PageNum = req.PageNum
|
|
|
+ collectionResp.PageSize = req.PageSize
|
|
|
+ var total int
|
|
|
|
|
|
- var params fastgpt.GetCollectionListReq
|
|
|
+ params := fastgpt.GetCollectionListReq{}
|
|
|
params.DatasetId = *req.DatasetId
|
|
|
params.PageNum = *req.PageNum
|
|
|
- params.PageSize = *req.PageNum
|
|
|
+ params.PageSize = *req.PageSize
|
|
|
resp, err := fastgpt.GetCollectionList(¶ms)
|
|
|
if err != nil {
|
|
|
- return nil, err
|
|
|
+ return nil, errorx.NewInvalidArgumentError("fastgpt error" + err.Error())
|
|
|
}
|
|
|
|
|
|
- for _, val := range resp.Data.Data {
|
|
|
- fmt.Printf("id=%v, parentId=%v, total=%v \n", val.ID, val.ParentID, resp.Data.Total)
|
|
|
- }
|
|
|
-
|
|
|
- fmt.Printf("code=%v, message=%v, data=%v len=%v\n", resp.Code, resp.Message, resp.Data, len(resp.Data.Data))
|
|
|
-
|
|
|
- if resp.Code == 200 && len(resp.Data.Data) > 0 {
|
|
|
- collectionResp.Data = make([]types.CollectionSimpleInfo, 0, len(resp.Data.Data))
|
|
|
+ collectionResp.Data = make([]types.CollectionSimpleInfo, 0, 1)
|
|
|
+ collectionResp.Total = &total
|
|
|
+ if resp.Code == 200 && resp.Data.Total > 0 {
|
|
|
for _, val := range resp.Data.Data {
|
|
|
- fmt.Printf("id=%v, parentId=%v \n", val.ID, val.ParentID)
|
|
|
collectionResp.Data = append(collectionResp.Data, types.CollectionSimpleInfo{
|
|
|
ID: &val.ID,
|
|
|
ParentID: &val.ParentID,
|
|
@@ -57,14 +53,8 @@ func (l *GetAgentCollectionListLogic) GetAgentCollectionList(req *types.Collecti
|
|
|
TrainingAmount: &val.TrainingAmount,
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
- //collectionResp.Data = listData
|
|
|
- collectionResp.PageNum = req.PageNum
|
|
|
- collectionResp.PageSize = req.PageSize
|
|
|
collectionResp.Total = &resp.Data.Total
|
|
|
-
|
|
|
- return &collectionResp, nil
|
|
|
}
|
|
|
|
|
|
- return nil, errors.New(resp.Message)
|
|
|
+ return &collectionResp, nil
|
|
|
}
|