后端:
1.阶段 6 CP4/CP5 目录收口与共享边界纯化
- 将 backend 根目录收口为 services、client、gateway、cmd、shared 五个一级目录
- 收拢 bootstrap、inits、infra/kafka、infra/outbox、conv、respond、pkg、middleware,移除根目录旧实现与空目录
- 将 utils 下沉到 services/userauth/internal/auth,将 logic 下沉到 services/schedule/core/planning
- 将迁移期 runtime 桥接实现统一收拢到 services/runtime/{conv,dao,eventsvc,model},删除 shared/legacy 与未再被 import 的旧 service 实现
- 将 gateway/shared/respond 收口为 HTTP/Gin 错误写回适配,shared/respond 仅保留共享错误语义与状态映射
- 将 HTTP IdempotencyMiddleware 与 RateLimitMiddleware 收口到 gateway/middleware
- 将 GormCachePlugin 下沉到 shared/infra/gormcache,将共享 RateLimiter 下沉到 shared/infra/ratelimit,将 agent token budget 下沉到 services/agent/shared
- 删除 InitEino 兼容壳,收缩 cmd/internal/coreinit 仅保留旧组合壳残留域初始化语义
- 更新微服务迁移计划与桌面 checklist,补齐 CP4/CP5 当前切流点、目录终态与验证结果
- 完成 go test ./...、git diff --check 与最终真实 smoke;health、register/login、task/create+get、schedule/today、task-class/list、memory/items、agent chat/meta/timeline/context-stats 全部 200,SSE 合并结果为 CP5_OK 且 [DONE] 只有 1 个
95 lines
2.8 KiB
Go
95 lines
2.8 KiB
Go
package conv
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/LoveLosita/smartflow/backend/services/runtime/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,
|
|
}
|
|
}
|