Files
agent/backend/internal/logic/projects/dto.go

43 lines
1.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package projects
import "senlinai-agent/backend/internal/models"
// ProjectDTO 是项目 API 的稳定响应ID 使用公开 identity避免泄漏数据库自增主键。
type ProjectDTO struct {
ID string `json:"id"`
Name string `json:"name"`
Identifier string `json:"identifier"`
Icon string `json:"icon"`
Background string `json:"background"`
Description string `json:"description"`
}
// CreateProjectRequest 描述创建项目时允许客户端写入的字段。
type CreateProjectRequest struct {
Name string `json:"name"`
Identifier string `json:"identifier"`
Icon string `json:"icon"`
Background string `json:"background"`
Description string `json:"description"`
}
// UpdateProjectRequest 使用指针区分“未提供”和“显式清空”,且只开放项目设置字段。
type UpdateProjectRequest struct {
Name *string `json:"name"`
Identifier *string `json:"identifier"`
Icon *string `json:"icon"`
Background *string `json:"background"`
Description *string `json:"description"`
}
func projectDTO(project models.SenlinAgentProject) ProjectDTO {
return ProjectDTO{
ID: project.Identity,
Name: project.Name,
Identifier: project.Identifier,
Icon: project.Icon,
Background: project.Background,
Description: project.Description,
}
}