263748af4a
Add canva/canda-compatible routes for lightweight project open/save and agent thread history: - POST /canva/project/queryProject, saveProject - POST /canva/agent/queryAgentLastThread, agentThreadList - GET /canda/chat-history, /canda/thread/status Canvas save now accepts a compressed SHAKKERDATA:// snapshot payload, preserves connections, and returns a SaveProject response; blank successful image nodes are backfilled from generated artifacts. Frontend designGateway adopts the new save/query flow. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
94 lines
2.1 KiB
Go
94 lines
2.1 KiB
Go
// Code scaffolded by goctl. Safe to edit.
|
|
// goctl 1.10.1
|
|
|
|
package logic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"img_infinite_canvas/internal/svc"
|
|
"img_infinite_canvas/internal/types"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type AgentThreadListLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewAgentThreadListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AgentThreadListLogic {
|
|
return &AgentThreadListLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *AgentThreadListLogic) AgentThreadList(req *types.AgentThreadListRequest) (resp *types.LovartAgentThreadListResponse, err error) {
|
|
project, err := l.svcCtx.DesignService.GetProject(l.ctx, req.ProjectId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
threads, err := l.svcCtx.DesignService.AgentThreads(l.ctx, req.ProjectId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
page := req.Page
|
|
if page <= 0 {
|
|
page = 1
|
|
}
|
|
pageSize := req.PageSize
|
|
if pageSize <= 0 {
|
|
pageSize = 100
|
|
}
|
|
if pageSize > 100 {
|
|
pageSize = 100
|
|
}
|
|
total := int64(len(threads))
|
|
start := (page - 1) * pageSize
|
|
if start > total {
|
|
start = total
|
|
}
|
|
end := start + pageSize
|
|
if end > total {
|
|
end = total
|
|
}
|
|
items := make([]types.LovartAgentThreadSummary, 0, end-start)
|
|
for index, thread := range threads[start:end] {
|
|
var cover *string
|
|
if thread.CoverImageURL != "" {
|
|
value := thread.CoverImageURL
|
|
cover = &value
|
|
}
|
|
items = append(items, types.LovartAgentThreadSummary{
|
|
Id: start + int64(index) + 1,
|
|
UserId: project.UserID,
|
|
ProjectId: req.ProjectId,
|
|
AgentThreadId: thread.AgentThreadID,
|
|
ThreadIdType: thread.ThreadIDType,
|
|
Title: "",
|
|
Text: thread.Text,
|
|
CoverImageUrl: cover,
|
|
FileType: nil,
|
|
UpdateTimestamp: thread.UpdateTimestamp,
|
|
Source: 1,
|
|
})
|
|
}
|
|
return &types.LovartAgentThreadListResponse{
|
|
Code: 0,
|
|
Msg: nil,
|
|
Data: types.LovartAgentThreadListData{
|
|
Page: page,
|
|
Total: total,
|
|
PageSize: pageSize,
|
|
Data: items,
|
|
UserIp: "",
|
|
TraceId: "",
|
|
HasMore: end < total,
|
|
},
|
|
}, nil
|
|
}
|