43 lines
1.3 KiB
Go
43 lines
1.3 KiB
Go
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,
|
||
}
|
||
}
|