12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package agent
- import (
- "context"
- "errors"
- "fmt"
- "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{}
- var params fastgpt.GetCollectionListReq
- params.DatasetId = *req.DatasetId
- params.PageNum = *req.PageNum
- params.PageSize = *req.PageNum
- resp, err := fastgpt.GetCollectionList(¶ms)
- if err != nil {
- return nil, err
- }
- 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))
- 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,
- TmbId: &val.TmbID,
- Type: &val.Type,
- Name: &val.Name,
- DataAmount: &val.DataAmount,
- 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)
- }
|