| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package api
-
- import (
- "git.x2erp.com/qdy/go-base/ctx"
- "git.x2erp.com/qdy/go-base/model/response"
- )
-
- // StartInstanceRequest 启动实例请求
- type StartInstanceRequest struct {
- ToolURL string `json:"tool_url" binding:"required"`
- Token string `json:"token" binding:"required"`
- }
-
- // InstanceInfo 实例信息
- type InstanceInfo struct {
- ProjectID string `json:"project_id"`
- Port int `json:"port"`
- PID int `json:"pid"`
- Status string `json:"status"`
- ConfigPath string `json:"config_path"`
- WorkDir string `json:"work_dir"`
- APIBase string `json:"api_base"`
- ToolURL string `json:"tool_url"`
- }
-
- // CreateSessionRequest 创建会话请求
- type CreateSessionRequest struct {
- Title string `json:"title,omitempty"`
- ParentID string `json:"parent_id,omitempty"`
- }
-
- // SendMessageRequest 发送消息请求
- type SendMessageRequest struct {
- ProjectID string `json:"project_id" binding:"required"`
- Message string `json:"message" binding:"required"`
- }
-
- // ErrorResponse 错误响应
- func ErrorResponse(err error) (*response.QueryResult[interface{}], error) {
- return &response.QueryResult[interface{}]{
- Success: false,
- Error: err.Error(),
- }, err
- }
-
- // SuccessResponse 成功响应
- func SuccessResponse(data interface{}) (*response.QueryResult[interface{}], error) {
- return &response.QueryResult[interface{}]{
- Success: true,
- Data: data,
- }, nil
- }
-
- // SuccessResponseWithMessage 带消息的成功响应
- func SuccessResponseWithMessage(data interface{}, message string) (*response.QueryResult[interface{}], error) {
- return &response.QueryResult[interface{}]{
- Success: true,
- Data: data,
- Message: message,
- }, nil
- }
-
- // GetRequestContext 获取请求上下文(简化函数)
- func GetRequestContext(reqCtx *ctx.RequestContext) (tenantID, userID string) {
- if reqCtx != nil {
- return reqCtx.TenantID, reqCtx.UserID
- }
- return "", ""
- }
|