后端: 1.收口阶段 6 agent 结构迁移,将 newAgent 内核与 agentsvc 编排层迁入 services/agent - 切换 Agent 启动装配与 HTTP handler 直连 agent sv,移除旧 service agent bridge - 补齐 Agent 对 memory、task、task-class、schedule 的 RPC 适配与契约字段 - 扩展 schedule、task、task-class RPC/contract 支撑 Agent 查询、写入与 provider 切流 - 更新迁移文档、README 与相关注释,明确 agent 当前切流点和剩余 memory 迁移面
95 lines
2.7 KiB
Go
95 lines
2.7 KiB
Go
package conv
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/LoveLosita/smartflow/backend/model"
|
|
)
|
|
|
|
func UserAddTaskRequestToModel(request *model.UserAddTaskRequest, userID int) *model.Task {
|
|
return &model.Task{
|
|
Title: request.Title,
|
|
Priority: request.PriorityGroup,
|
|
EstimatedSections: model.NormalizeEstimatedSections(&request.EstimatedSections),
|
|
DeadlineAt: request.DeadlineAt,
|
|
UrgencyThresholdAt: request.UrgencyThresholdAt,
|
|
UserID: userID,
|
|
}
|
|
}
|
|
|
|
func ModelToUserAddTaskResponse(task *model.Task) *model.UserAddTaskResponse {
|
|
status := "incomplete"
|
|
if task.IsCompleted {
|
|
status = "completed"
|
|
}
|
|
return &model.UserAddTaskResponse{
|
|
ID: task.ID,
|
|
Title: task.Title,
|
|
PriorityGroup: task.Priority,
|
|
EstimatedSections: model.NormalizeEstimatedSections(&task.EstimatedSections),
|
|
DeadlineAt: task.DeadlineAt,
|
|
Status: status,
|
|
CreatedAt: time.Now(), // 创建时间使用当前服务时间,保持既有响应语义。
|
|
}
|
|
}
|
|
|
|
func ModelToGetUserTasksResp(tasks []model.Task) []model.GetUserTaskResp {
|
|
var resp []model.GetUserTaskResp
|
|
for _, task := range tasks {
|
|
status := "incomplete"
|
|
if task.IsCompleted {
|
|
status = "completed"
|
|
}
|
|
|
|
deadline := ""
|
|
if task.DeadlineAt != nil {
|
|
deadline = task.DeadlineAt.Format("2006-01-02 15:04:05")
|
|
}
|
|
|
|
urgencyThreshold := ""
|
|
if task.UrgencyThresholdAt != nil {
|
|
urgencyThreshold = task.UrgencyThresholdAt.Format("2006-01-02 15:04:05")
|
|
}
|
|
|
|
resp = append(resp, model.GetUserTaskResp{
|
|
ID: task.ID,
|
|
UserID: task.UserID,
|
|
Title: task.Title,
|
|
PriorityGroup: task.Priority,
|
|
EstimatedSections: model.NormalizeEstimatedSections(&task.EstimatedSections),
|
|
Status: status,
|
|
Deadline: deadline,
|
|
IsCompleted: task.IsCompleted,
|
|
UrgencyThresholdAt: urgencyThreshold,
|
|
})
|
|
}
|
|
return resp
|
|
}
|
|
|
|
// ModelToGetUserTaskResp 将单个 Task 模型转换为 GetUserTaskResp。
|
|
func ModelToGetUserTaskResp(task *model.Task) model.GetUserTaskResp {
|
|
status := "incomplete"
|
|
if task.IsCompleted {
|
|
status = "completed"
|
|
}
|
|
deadline := ""
|
|
if task.DeadlineAt != nil {
|
|
deadline = task.DeadlineAt.Format("2006-01-02 15:04:05")
|
|
}
|
|
urgencyThreshold := ""
|
|
if task.UrgencyThresholdAt != nil {
|
|
urgencyThreshold = task.UrgencyThresholdAt.Format("2006-01-02 15:04:05")
|
|
}
|
|
return model.GetUserTaskResp{
|
|
ID: task.ID,
|
|
UserID: task.UserID,
|
|
Title: task.Title,
|
|
PriorityGroup: task.Priority,
|
|
EstimatedSections: model.NormalizeEstimatedSections(&task.EstimatedSections),
|
|
Status: status,
|
|
Deadline: deadline,
|
|
IsCompleted: task.IsCompleted,
|
|
UrgencyThresholdAt: urgencyThreshold,
|
|
}
|
|
}
|