Browse Source

临时提交

boweniac 2 weeks ago
parent
commit
8cd0d14034
1 changed files with 42 additions and 0 deletions
  1. 42 0
      internal/logic/fastgpt/create_fastgpt_logic.go

+ 42 - 0
internal/logic/fastgpt/create_fastgpt_logic.go

@@ -4,7 +4,9 @@ import (
 	"context"
 	"github.com/suyuan32/simple-admin-common/msg/errormsg"
 	"github.com/zeromicro/go-zero/core/errorx"
+	"go.mongodb.org/mongo-driver/bson/primitive"
 	"time"
+	apps "wechat-api/mongo_model/apps"
 	team_members "wechat-api/mongo_model/team_members"
 	teams "wechat-api/mongo_model/teams"
 	users "wechat-api/mongo_model/users"
@@ -76,5 +78,45 @@ func (l *CreateFastgptLogic) CreateFastgpt(req *types.CreateInfo) (resp *types.B
 		return nil, errorx.NewInvalidArgumentError("fastgpt create failed " + err.Error())
 	}
 
+	// 创建app
+	apps_info := &apps.Apps{
+		ParentID: nil,
+		TeamID:   teams_info.ID,
+		TmbID:    team_members_info.ID,
+		Name:     "默认智能体",
+		Type:     "simple",
+		Version:  "v2",
+		Avatar:   "/imgs/app/avatar/simple.svg",
+		Intro:    "",
+		Modules: []apps.AppModule{
+			{
+				NodeID: "userGuide",
+				Name:   "系统配置",
+				Position: Position{
+					X: 531.24,
+					Y: -486.76,
+				},
+				Inputs:  [],
+				Outputs: []Output{},
+			},
+		},
+		Edges: []Edge{
+			{
+				Source: "workflowStartNodeId",
+				Target: "7BdojPlukIQw",
+			},
+		},
+		PluginData: PluginData{
+			ID:          primitive.NewObjectID(),
+			NodeVersion: "67da46d29667c5bf2120361a",
+		},
+		UpdateTime: time.Date(2025, 3, 19, 4, 24, 4, 0, time.UTC),
+	}
+
+	err = l.svcCtx.MongoModel.TeamMembersModel.Insert(context.TODO(), team_members_info)
+	if err != nil {
+		return nil, errorx.NewInvalidArgumentError("fastgpt create failed " + err.Error())
+	}
+
 	return &types.BaseMsgResp{Msg: errormsg.Success}, nil
 }