1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package agent
- import (
- "context"
- "fmt"
- "wechat-api/hook/fastgpt"
- "wechat-api/internal/svc"
- "wechat-api/internal/types"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type BatchDeleteAgentDataLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewBatchDeleteAgentDataLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BatchDeleteAgentDataLogic {
- return &BatchDeleteAgentDataLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx}
- }
- func (l *BatchDeleteAgentDataLogic) BatchDeleteAgentData(req *types.BatchDeleteIds) (*types.BaseDataInfo, error) {
- var success, fail int
- if len(req.Ids) > 0 {
- for _, sid := range req.Ids {
- response, err := fastgpt.DeleteData(sid)
- fmt.Printf("id=%s, response=%+v\n", sid, response)
- if err != nil {
- fail++
- fmt.Printf("delete fastgpt data failed:%v\n", err)
- }
- if response != nil && response.Code == 200 {
- success++
- }
- }
- }
- resp := types.BaseDataInfo{}
- resp.Msg = fmt.Sprintf("succeed %d rows, fail %d rows", success, fail)
- return &resp, nil
- }
|