Ver código fonte

增加增删改接口

boweniac 1 mês atrás
pai
commit
f1a887bddf

+ 2 - 2
desc/all.api

@@ -43,6 +43,6 @@ import "./wechat/credit_usage.api"
 import "./wechat/pay_recharge.api"
 import "./wechat/whatsapp.api"
 import "./wechat/whatsapp_channel.api"
-import "./wechat/api_key.api"
+import "./wechat/fastgpt.api"
 import "./wechat/department.api"
-import "./wechat/fastgpt.api"
+import "./wechat/api_key.api"

+ 2 - 2
desc/wechat/fastgpt.api

@@ -38,13 +38,13 @@ type (
     CreateAppsReq {
         Type string `json:"type"`
         Name string `json:"name"`
-        Intro string `json:"intro,optional"`
+        Intro *string `json:"intro,optional"`
     }
 
     UpdateAppsReq {
         Id string `json:"id"`
         Name string `json:"name"`
-        Intro string `json:"intro,optional"`
+        Intro *string `json:"intro,optional"`
     }
 
     DeleteAppsReq {

+ 31 - 31
internal/handler/routes.go

@@ -2070,28 +2070,43 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 	)
 
 	server.AddRoutes(
+		[]rest.Route{
+			{
+				Method:  http.MethodGet,
+				Path:    "/api/fastgpt/set_token",
+				Handler: fastgpt.SetTokenHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/api/fastgpt/create",
+				Handler: fastgpt.CreateFastgptHandler(serverCtx),
+			},
+		},
+	)
+
+	server.AddRoutes(
 		rest.WithMiddlewares(
 			[]rest.Middleware{serverCtx.Authority},
 			[]rest.Route{
 				{
 					Method:  http.MethodPost,
-					Path:    "/api_key/create",
-					Handler: api_key.CreateApiKeyHandler(serverCtx),
+					Path:    "/api/fastgpt/apps_list",
+					Handler: fastgpt.GetAppsListHandler(serverCtx),
 				},
 				{
 					Method:  http.MethodPost,
-					Path:    "/api_key/update",
-					Handler: api_key.UpdateApiKeyHandler(serverCtx),
+					Path:    "/api/fastgpt/create_app",
+					Handler: fastgpt.CreateAppHandler(serverCtx),
 				},
 				{
 					Method:  http.MethodPost,
-					Path:    "/api_key/delete",
-					Handler: api_key.DeleteApiKeyHandler(serverCtx),
+					Path:    "/api/fastgpt/update_app",
+					Handler: fastgpt.UpdateAppHandler(serverCtx),
 				},
 				{
 					Method:  http.MethodPost,
-					Path:    "/api_key/list",
-					Handler: api_key.GetApiKeyListHandler(serverCtx),
+					Path:    "/api/fastgpt/delete_app",
+					Handler: fastgpt.DeleteAppHandler(serverCtx),
 				},
 			}...,
 		),
@@ -2133,43 +2148,28 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 	)
 
 	server.AddRoutes(
-		[]rest.Route{
-			{
-				Method:  http.MethodGet,
-				Path:    "/api/fastgpt/set_token",
-				Handler: fastgpt.SetTokenHandler(serverCtx),
-			},
-			{
-				Method:  http.MethodPost,
-				Path:    "/api/fastgpt/create",
-				Handler: fastgpt.CreateFastgptHandler(serverCtx),
-			},
-		},
-	)
-
-	server.AddRoutes(
 		rest.WithMiddlewares(
 			[]rest.Middleware{serverCtx.Authority},
 			[]rest.Route{
 				{
 					Method:  http.MethodPost,
-					Path:    "/api/fastgpt/apps_list",
-					Handler: fastgpt.GetAppsListHandler(serverCtx),
+					Path:    "/api_key/create",
+					Handler: api_key.CreateApiKeyHandler(serverCtx),
 				},
 				{
 					Method:  http.MethodPost,
-					Path:    "/api/fastgpt/create_app",
-					Handler: fastgpt.CreateAppHandler(serverCtx),
+					Path:    "/api_key/update",
+					Handler: api_key.UpdateApiKeyHandler(serverCtx),
 				},
 				{
 					Method:  http.MethodPost,
-					Path:    "/api/fastgpt/update_app",
-					Handler: fastgpt.UpdateAppHandler(serverCtx),
+					Path:    "/api_key/delete",
+					Handler: api_key.DeleteApiKeyHandler(serverCtx),
 				},
 				{
 					Method:  http.MethodPost,
-					Path:    "/api/fastgpt/delete_app",
-					Handler: fastgpt.DeleteAppHandler(serverCtx),
+					Path:    "/api_key/list",
+					Handler: api_key.GetApiKeyListHandler(serverCtx),
 				},
 			}...,
 		),

+ 383 - 2
internal/logic/fastgpt/create_app_logic.go

@@ -2,6 +2,11 @@ package fastgpt
 
 import (
 	"context"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/zeromicro/go-zero/core/errorx"
+	"strconv"
+	"time"
+	apps "wechat-api/mongo_model/apps"
 
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
@@ -23,7 +28,383 @@ func NewCreateAppLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateA
 }
 
 func (l *CreateAppLogic) CreateApp(req *types.CreateAppsReq) (resp *types.BaseMsgResp, err error) {
-	// todo: add your logic here and delete this line
+	organizationId := l.ctx.Value("organizationId").(uint64)
 
-	return
+	organizationIdStr := strconv.FormatUint(organizationId, 10)
+
+	user, err := l.svcCtx.MongoModel.UsersModel.FindOneByUsername(context.TODO(), organizationIdStr)
+	if err != nil {
+		return nil, errorx.NewInvalidArgumentError("fastgpt get list failed " + err.Error())
+	}
+
+	teamMember, err := l.svcCtx.MongoModel.TeamMembersModel.FindOneByUserId(context.TODO(), user.ID)
+	if err != nil {
+		return nil, errorx.NewInvalidArgumentError("fastgpt get list failed " + err.Error())
+	}
+
+	intro := ""
+	if req.Intro != nil {
+		intro = *req.Intro
+	}
+	var apps_info *apps.Apps
+	if req.Type == "simple" {
+		// 创建默认智能体
+		apps_info = &apps.Apps{
+			ParentID: nil,
+			TeamID:   teamMember.TeamID,
+			TmbID:    teamMember.ID,
+			Name:     req.Name,
+			Type:     "simple",
+			Version:  "v2",
+			Avatar:   "/imgs/app/avatar/simple.svg",
+			Intro:    intro,
+			TeamTags: []string{},
+			Modules: []apps.AppModule{
+				{
+					NodeID:       "userGuide",
+					Name:         "系统配置",
+					Intro:        "",
+					FlowNodeType: "userGuide",
+					Position: apps.Position{
+						X: 531.242273606555,
+						Y: -486.761172954975,
+					},
+					Version: "481",
+					Inputs:  []apps.AppInput{},
+					Outputs: []apps.AppOutput{},
+				},
+				{
+					NodeID:       "workflowStartNodeId",
+					Name:         "流程开始",
+					Intro:        "",
+					Avatar:       "core/workflow/template/workflowStart",
+					FlowNodeType: "workflowStart",
+					Position: apps.Position{
+						X: 558.40823764155,
+						Y: 123.723874291941,
+					},
+					Version: "481",
+					Inputs: []apps.AppInput{
+						{
+							Key:             "userChatInput",
+							RenderTypeList:  []string{"reference", "textarea"},
+							ValueType:       "string",
+							Label:           "workflow:user_question",
+							ToolDescription: "workflow:user_question",
+							Required:        true,
+						},
+					},
+					Outputs: []apps.AppOutput{
+						{
+							ID:        "userChatInput",
+							Key:       "userChatInput",
+							Label:     "common:core.module.input.label.user question",
+							Type:      "static",
+							ValueType: "string",
+						},
+						{
+							ID:          "userFiles",
+							Key:         "userFiles",
+							Label:       "app:workflow.user_file_input",
+							Description: "app:workflow.user_file_input_desc",
+							Type:        "static",
+							ValueType:   "arrayString",
+						},
+					},
+				},
+				{
+					NodeID:       "7BdojPlukIQw",
+					Name:         "AI 对话",
+					Intro:        "AI 大模型对话",
+					Avatar:       "core/workflow/template/aiChat",
+					FlowNodeType: "chatNode",
+					ShowStatus:   true,
+					Position: apps.Position{
+						X: 1106.32383879608,
+						Y: -350.603067468347,
+					},
+					Version: "4813",
+					Inputs: []apps.AppInput{
+						{
+							Key:            "model",
+							RenderTypeList: []string{"settingLLMModel", "reference"},
+							ValueType:      "string",
+							Value:          "DeepSeek-V3",
+						},
+						{
+							Key:            "temperature",
+							RenderTypeList: []string{"hidden"},
+							ValueType:      "number",
+							Value:          int32(0),
+							Min:            getInt32(0),
+							Max:            getInt32(10),
+							Step:           getInt32(1),
+						},
+						{
+							Key:            "maxToken",
+							RenderTypeList: []string{"hidden"},
+							ValueType:      "number",
+							Value:          int32(2000),
+							Min:            getInt32(100),
+							Max:            getInt32(4000),
+							Step:           getInt32(50),
+						},
+						{
+							Key:            "isResponseAnswerText",
+							RenderTypeList: []string{"hidden"},
+							ValueType:      "boolean",
+							Value:          true,
+						},
+						{
+							Key:            "aiChatQuoteRole",
+							RenderTypeList: []string{"hidden"},
+							ValueType:      "string",
+							Value:          "system",
+						},
+						{
+							Key:            "quoteTemplate",
+							RenderTypeList: []string{"hidden"},
+							ValueType:      "string",
+						},
+						{
+							Key:            "quotePrompt",
+							RenderTypeList: []string{"hidden"},
+							ValueType:      "string",
+						},
+						{
+							Key:            "systemPrompt",
+							RenderTypeList: []string{"textarea", "reference"},
+							Max:            getInt32(3000),
+							ValueType:      "string",
+							Label:          "core.ai.Prompt",
+							Description:    "core.app.tip.systemPromptTip",
+							Placeholder:    "core.app.tip.chatNodeSystemPromptTip",
+							Value:          "",
+						},
+						{
+							Key:            "history",
+							RenderTypeList: []string{"numberInput", "reference"},
+							ValueType:      "chatHistory",
+							Label:          "core.module.input.label.chat history",
+							Required:       true,
+							Min:            getInt32(0),
+							Max:            getInt32(30),
+							Value:          int32(6),
+						},
+						{
+							Key:             "userChatInput",
+							RenderTypeList:  []string{"reference", "textarea"},
+							ValueType:       "string",
+							Label:           "common:core.module.input.label.user question",
+							Required:        true,
+							ToolDescription: "common:core.module.input.label.user question",
+							Value:           []interface{}{"workflowStartNodeId", "userChatInput"},
+						},
+						{
+							Key:            "quoteQA",
+							RenderTypeList: []string{"settingDatasetQuotePrompt"},
+							Label:          "",
+							DebugLabel:     "common:core.module.Dataset quote.label",
+							Description:    "",
+							ValueType:      "datasetQuote",
+						},
+						{
+							Key:            "fileUrlList",
+							RenderTypeList: []string{"reference", "input"},
+							Label:          "app:file_quote_link",
+							DebugLabel:     "app:file_quote_link",
+							ValueType:      "arrayString",
+							Value:          [][]interface{}{{"workflowStartNodeId", "userFiles"}},
+						},
+						{
+							Key:            "aiChatVision",
+							RenderTypeList: []string{"hidden"},
+							ValueType:      "boolean",
+							Value:          true,
+						},
+					},
+					Outputs: []apps.AppOutput{
+						{
+							ID:          "history",
+							Key:         "history",
+							Required:    true,
+							Label:       "common:core.module.output.label.New context",
+							Description: "common:core.module.output.description.New context",
+							ValueType:   "chatHistory",
+							ValueDesc:   "{\n  obj: System | Human | AI;\n  value: string;\n}[]",
+							Type:        "static",
+						},
+						{
+							ID:          "answerText",
+							Key:         "answerText",
+							Required:    true,
+							Label:       "common:core.module.output.label.Ai response content",
+							Description: "common:core.module.output.description.Ai response content",
+							ValueType:   "string",
+							Type:        "static",
+						},
+					},
+				},
+			},
+			Edges: []apps.Edge{
+				{
+					Source:       "workflowStartNodeId",
+					Target:       "7BdojPlukIQw",
+					SourceHandle: "workflowStartNodeId-source-right",
+					TargetHandle: "7BdojPlukIQw-target-left",
+				},
+			},
+			PluginData: apps.PluginData{
+				ID:          mustParseObjectID("67da46b29667c5bf21203554"),
+				NodeVersion: "67da46d29667c5bf2120361a",
+			},
+			InheritPermission: true,
+			VersionNumber:     int32(0),
+			ChatConfig: apps.ChatConfig{
+				WelcomeText:   "",
+				Variables:     []interface{}{},
+				QuestionGuide: false,
+				TTSConfig: apps.TTSConfig{
+					Type: "web",
+				},
+				WhisperConfig: apps.WhisperConfig{
+					Open:            false,
+					AutoSend:        false,
+					AutoTTSResponse: false,
+				},
+				ScheduledTriggerConfig: nil,
+				ChatInputGuide: apps.ChatInputGuide{
+					Open:      false,
+					TextList:  []string{},
+					CustomUrl: "",
+				},
+				Instruction: "",
+				ID:          mustParseObjectID("67da46d29667c5bf2120361d"),
+			},
+			UpdateTime:               time.Date(2025, 3, 19, 4, 24, 4, 394000000, time.UTC),
+			ScheduledTriggerConfig:   nil,
+			ScheduledTriggerNextTime: nil,
+		}
+	} else {
+		apps_info = &apps.Apps{
+			ParentID: nil,
+			TeamID:   teamMember.TeamID,
+			TmbID:    teamMember.ID,
+			Name:     req.Name,
+			Type:     "advanced",
+			Version:  "v2",
+			Avatar:   "/imgs/app/avatar/workflow.svg",
+			Intro:    intro,
+			TeamTags: []string{},
+			Modules: []apps.AppModule{
+				{
+					NodeID:       "userGuide",
+					Name:         "common:core.module.template.system_config",
+					Intro:        "common:core.module.template.system_config_info",
+					Avatar:       "core/workflow/template/systemConfig",
+					FlowNodeType: "userGuide",
+					Position: apps.Position{
+						X: 262.273233881709,
+						Y: -476.002411365981,
+					},
+					Version: "481",
+					Inputs: []apps.AppInput{
+						{
+							Key:            "welcomeText",
+							RenderTypeList: []string{"hidden"},
+							ValueType:      "string",
+							Label:          "core.app.Welcome Text",
+							Value:          "",
+						}, {
+							Key:            "variables",
+							RenderTypeList: []string{"hidden"},
+							ValueType:      "any",
+							Label:          "core.app.Chat Variable",
+							Value:          []string{},
+						}, {
+							Key:            "questionGuide",
+							RenderTypeList: []string{"hidden"},
+							ValueType:      "boolean",
+							Label:          "core.app.Question Guide",
+							Value:          false,
+						}, {
+							Key:            "tts",
+							RenderTypeList: []string{"hidden"},
+							ValueType:      "any",
+							Label:          "",
+							Value: apps.AppInputValue{
+								Type: "web",
+							},
+						}, {
+							Key:            "whisper",
+							RenderTypeList: []string{"hidden"},
+							ValueType:      "any",
+							Label:          "",
+							Value: apps.AppInputValue{
+								Open:            false,
+								AutoSend:        false,
+								AutoTTSResponse: false,
+							},
+						}, {
+							Key:            "scheduleTrigger",
+							RenderTypeList: []string{"hidden"},
+							ValueType:      "any",
+							Label:          "",
+						},
+					},
+					Outputs: []apps.AppOutput{},
+				},
+				{
+					NodeID:       "448745",
+					Name:         "common:core.module.template.work_start",
+					Intro:        "",
+					Avatar:       "core/workflow/template/workflowStart",
+					FlowNodeType: "workflowStart",
+					Position: apps.Position{
+						X: 632.368838596004,
+						Y: -347.744649294401,
+					},
+					Version: "481",
+					Inputs: []apps.AppInput{
+						{
+							Key:             "userChatInput",
+							RenderTypeList:  []string{"reference", "textarea"},
+							ValueType:       "string",
+							Label:           "common:core.module.input.label.user question",
+							ToolDescription: "common:core.module.input.label.user question",
+							Required:        true,
+						},
+					},
+					Outputs: []apps.AppOutput{
+						{
+							ID:        "userChatInput",
+							Key:       "userChatInput",
+							Label:     "common:core.module.input.label.user question",
+							Type:      "static",
+							ValueType: "string",
+						},
+					},
+				},
+			},
+			Edges: []apps.Edge{},
+			PluginData: apps.PluginData{
+				ID:          mustParseObjectID("67dce247bd93cb6e085a6bda"),
+				NodeVersion: "481",
+			},
+			InheritPermission: true,
+			VersionNumber:     int32(0),
+			UpdateTime:        time.Date(2025, 3, 19, 4, 24, 4, 394000000, time.UTC),
+		}
+	}
+
+	if apps_info != nil {
+		err = l.svcCtx.MongoModel.AppsModel.Insert(context.TODO(), apps_info)
+		if err != nil {
+			return nil, errorx.NewInvalidArgumentError("fastgpt create failed " + err.Error())
+		}
+	} else {
+		return nil, errorx.NewInvalidArgumentError("fastgpt create failed ")
+	}
+
+	return &types.BaseMsgResp{Msg: errormsg.Success}, nil
 }

+ 8 - 3
internal/logic/fastgpt/delete_app_logic.go

@@ -2,7 +2,8 @@ package fastgpt
 
 import (
 	"context"
-
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/zeromicro/go-zero/core/errorx"
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
 
@@ -23,7 +24,11 @@ func NewDeleteAppLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteA
 }
 
 func (l *DeleteAppLogic) DeleteApp(req *types.DeleteAppsReq) (resp *types.BaseMsgResp, err error) {
-	// todo: add your logic here and delete this line
 
-	return
+	_, err = l.svcCtx.MongoModel.AppsModel.Delete(context.TODO(), req.Id)
+	if err != nil {
+		return nil, errorx.NewInvalidArgumentError("fastgpt create failed " + err.Error())
+	}
+
+	return &types.BaseMsgResp{Msg: errormsg.Success}, nil
 }

+ 17 - 3
internal/logic/fastgpt/update_app_logic.go

@@ -2,9 +2,11 @@ package fastgpt
 
 import (
 	"context"
-
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/zeromicro/go-zero/core/errorx"
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
+	apps "wechat-api/mongo_model/apps"
 
 	"github.com/zeromicro/go-zero/core/logx"
 )
@@ -23,7 +25,19 @@ func NewUpdateAppLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateA
 }
 
 func (l *UpdateAppLogic) UpdateApp(req *types.UpdateAppsReq) (resp *types.BaseMsgResp, err error) {
-	// todo: add your logic here and delete this line
+	intro := ""
+	if req.Intro != nil {
+		intro = *req.Intro
+	}
+	apps_info := &apps.Apps{
+		ID:    mustParseObjectID(req.Id),
+		Name:  req.Name,
+		Intro: intro,
+	}
+	_, err = l.svcCtx.MongoModel.AppsModel.UpdateInfo(context.TODO(), apps_info)
+	if err != nil {
+		return nil, errorx.NewInvalidArgumentError("fastgpt create failed " + err.Error())
+	}
 
-	return
+	return &types.BaseMsgResp{Msg: errormsg.Success}, nil
 }

+ 74 - 74
internal/types/types.go

@@ -4182,47 +4182,53 @@ type WhatsappChannelInfoResp struct {
 	Data WhatsappChannelInfo `json:"data"`
 }
 
-// The data of api_key information | ApiKey信息
-// swagger:model ApiKeyInfo
-type ApiKeyInfo struct {
-	BaseIDInfo
-	// Title
-	Title *string `json:"title,optional"`
-	// Key
-	Key *string `json:"key,optional"`
-	// 租户ID
-	OrganizationId  *uint64    `json:"organization_id,optional"`
-	AgentId         *uint64    `json:"agent_id,optional"`
-	AgentInfo       *AgentInfo `json:"agent_info,optional"`
-	CustomAgentBase *string    `json:"custom_agent_base,optional"`
-	CustomAgentKey  *string    `json:"custom_agent_key,optional"`
-	OpenaiBase      *string    `json:"openai_base,optional"`
-	OpenaiKey       *string    `json:"openai_key,optional"`
+// swagger:model CreateInfo
+type CreateInfo struct {
+	// Translated Name | 展示名称
+	UserName string `json:"username"`
+	// Name | 部门名称
+	Title *string `json:"title"`
 }
 
-// The response data of api_key list | ApiKey列表数据
-// swagger:model ApiKeyListResp
-type ApiKeyListResp struct {
+// swagger:model AppsListReq
+type AppsListReq struct {
+	Type    string  `json:"type"`
+	Keyword *string `json:"keyword,optional"`
+}
+
+// swagger:model AppsListResp
+type AppsListResp struct {
 	BaseDataInfo
-	// ApiKey list data | ApiKey列表数据
-	Data ApiKeyListInfo `json:"data"`
+	Data []*AppsListRespInfo `json:"data"`
 }
 
-// ApiKey list data | ApiKey列表数据
-// swagger:model ApiKeyListInfo
-type ApiKeyListInfo struct {
-	BaseListInfo
-	// The API list data | ApiKey列表数据
-	Data []ApiKeyInfo `json:"data"`
+// swagger:model AppsListRespInfo
+type AppsListRespInfo struct {
+	Id     string `json:"_id"`
+	TeamId string `json:"teamId"`
+	TmbId  string `json:"tmbId"`
+	Avatar string `json:"avatar"`
+	Name   string `json:"name"`
+	Intro  string `json:"intro"`
 }
 
-// Get ApiKey list request params | ApiKey列表请求参数
-// swagger:model ApiKeyListReq
-type ApiKeyListReq struct {
-	PageInfo
-	// Key
-	Key            *string `json:"key,optional"`
-	OrganizationId *uint64 `json:"organization_id,optional"`
+// swagger:model CreateAppsReq
+type CreateAppsReq struct {
+	Type  string  `json:"type"`
+	Name  string  `json:"name"`
+	Intro *string `json:"intro,optional"`
+}
+
+// swagger:model UpdateAppsReq
+type UpdateAppsReq struct {
+	Id    string  `json:"id"`
+	Name  string  `json:"name"`
+	Intro *string `json:"intro,optional"`
+}
+
+// swagger:model DeleteAppsReq
+type DeleteAppsReq struct {
+	Id string `json:"id"`
 }
 
 // The response data of department information | 部门信息
@@ -4296,51 +4302,45 @@ type DepartmentInfoResp struct {
 	Data DepartmentInfo `json:"data"`
 }
 
-// swagger:model CreateInfo
-type CreateInfo struct {
-	// Translated Name | 展示名称
-	UserName string `json:"username"`
-	// Name | 部门名称
-	Title *string `json:"title"`
-}
-
-// swagger:model AppsListReq
-type AppsListReq struct {
-	Type    string  `json:"type"`
-	Keyword *string `json:"keyword,optional"`
+// The data of api_key information | ApiKey信息
+// swagger:model ApiKeyInfo
+type ApiKeyInfo struct {
+	BaseIDInfo
+	// Title
+	Title *string `json:"title,optional"`
+	// Key
+	Key *string `json:"key,optional"`
+	// 租户ID
+	OrganizationId  *uint64    `json:"organization_id,optional"`
+	AgentId         *uint64    `json:"agent_id,optional"`
+	AgentInfo       *AgentInfo `json:"agent_info,optional"`
+	CustomAgentBase *string    `json:"custom_agent_base,optional"`
+	CustomAgentKey  *string    `json:"custom_agent_key,optional"`
+	OpenaiBase      *string    `json:"openai_base,optional"`
+	OpenaiKey       *string    `json:"openai_key,optional"`
 }
 
-// swagger:model AppsListResp
-type AppsListResp struct {
+// The response data of api_key list | ApiKey列表数据
+// swagger:model ApiKeyListResp
+type ApiKeyListResp struct {
 	BaseDataInfo
-	Data []*AppsListRespInfo `json:"data"`
-}
-
-// swagger:model AppsListRespInfo
-type AppsListRespInfo struct {
-	Id     string `json:"_id"`
-	TeamId string `json:"teamId"`
-	TmbId  string `json:"tmbId"`
-	Avatar string `json:"avatar"`
-	Name   string `json:"name"`
-	Intro  string `json:"intro"`
-}
-
-// swagger:model CreateAppsReq
-type CreateAppsReq struct {
-	Type  string `json:"type"`
-	Name  string `json:"name"`
-	Intro string `json:"intro,optional"`
+	// ApiKey list data | ApiKey列表数据
+	Data ApiKeyListInfo `json:"data"`
 }
 
-// swagger:model UpdateAppsReq
-type UpdateAppsReq struct {
-	Id    string `json:"id"`
-	Name  string `json:"name"`
-	Intro string `json:"intro,optional"`
+// ApiKey list data | ApiKey列表数据
+// swagger:model ApiKeyListInfo
+type ApiKeyListInfo struct {
+	BaseListInfo
+	// The API list data | ApiKey列表数据
+	Data []ApiKeyInfo `json:"data"`
 }
 
-// swagger:model DeleteAppsReq
-type DeleteAppsReq struct {
-	Id string `json:"id"`
+// Get ApiKey list request params | ApiKey列表请求参数
+// swagger:model ApiKeyListReq
+type ApiKeyListReq struct {
+	PageInfo
+	// Key
+	Key            *string `json:"key,optional"`
+	OrganizationId *uint64 `json:"organization_id,optional"`
 }

+ 13 - 0
mongo_model/apps/appsmodelgen.go

@@ -17,6 +17,7 @@ type appsModel interface {
 	Insert(ctx context.Context, data *Apps) error
 	FindOne(ctx context.Context, id string) (*Apps, error)
 	Update(ctx context.Context, data *Apps) (*mongo.UpdateResult, error)
+	UpdateInfo(ctx context.Context, data *Apps) (*mongo.UpdateResult, error)
 	Delete(ctx context.Context, id string) (int64, error)
 	FindAll(ctx context.Context, teamId primitive. ObjectID, apptype string, keyword *string) ([]*Apps, error)
 }
@@ -65,6 +66,18 @@ func (m *defaultAppsModel) Update(ctx context.Context, data *Apps) (*mongo.Updat
 	return res, err
 }
 
+func (m *defaultAppsModel) UpdateInfo(ctx context.Context, data *Apps) (*mongo.UpdateResult, error) {
+	data.UpdateTime = time.Now()
+
+	res, err := m.conn.UpdateOne(ctx, bson.M{"_id": data.ID}, bson.M{
+		"$set": bson.M{
+			"name":  data.Name,
+			"intro": data.Intro,
+		},
+	})
+	return res, err
+}
+
 func (m *defaultAppsModel) Delete(ctx context.Context, id string) (int64, error) {
 	oid, err := primitive.ObjectIDFromHex(id)
 	if err != nil {

+ 7 - 0
mongo_model/apps/appstypes.go

@@ -40,6 +40,13 @@ type AppInput struct {
 	Placeholder     string      `bson:"placeholder,omitempty" json:"placeholder,omitempty"`
 }
 
+type AppInputValue struct {
+	Type            string `bson:"type" json:"type"`
+	Open            bool   `bson:"open" json:"open"`
+	AutoSend        bool   `bson:"autoSend" json:"autoSend"`
+	AutoTTSResponse bool   `bson:"autoTTSResponse" json:"autoTTSResponse"`
+}
+
 type AppOutput struct {
 	ID          string `bson:"id" json:"id"`
 	Key         string `bson:"key" json:"key"`