feat: 实现工程管理模块
- 新增 Project ProjectStyleRecord Task 数据模型 - 新增 ProjectService 服务层,支持工程和风格的 CRUD 操作 - 新增工程相关 handler,实现前端所需的所有工程接口 - 数据库层新增 GetDB 方法,便于服务层获取数据库连接 涉及接口: - GET /api/v1/projects - 获取工程列表 - POST /api/v1/projects - 创建工程 - GET /api/v1/projects/:projectId - 获取工程详情 - PUT /api/v1/projects/:projectId - 更新工程信息 - DELETE /api/v1/projects/:projectId - 删除工程 - GET /api/v1/projects/:projectId/style - 获取工程风格 - PUT /api/v1/projects/:projectId/style - 更新工程风格 - GET /api/v1/projects/:projectId/tasks - 获取工程任务列表
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// Project 工程数据模型,对应数据库表。
|
||||
type Project struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
UserID uint `gorm:"index" json:"-"` // 用户ID,用于权限控制
|
||||
Name string `gorm:"size:100;not null" json:"name"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt,omitempty"`
|
||||
}
|
||||
|
||||
// ProjectStyleRecord 工程风格记录,用于存储键值对。
|
||||
type ProjectStyleRecord struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
ProjectID uint `gorm:"index" json:"-"`
|
||||
Key string `gorm:"size:50;not null" json:"-"`
|
||||
Value string `gorm:"size:100;not null" json:"-"`
|
||||
CreatedAt time.Time `json:"-"`
|
||||
}
|
||||
|
||||
// ProjectResponse 工程响应,包含风格键值对和元数据。
|
||||
type ProjectResponse struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Style *ProjectStyleResponse `json:"style"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
UpdatedAt string `json:"updatedAt,omitempty"`
|
||||
TaskCount int `json:"taskCount,omitempty"`
|
||||
LastActivityAt string `json:"lastActivityAt,omitempty"`
|
||||
}
|
||||
|
||||
// ProjectStyleResponse 工程风格响应。
|
||||
type ProjectStyleResponse struct {
|
||||
KvPairs map[string]string `json:"kvPairs"`
|
||||
}
|
||||
|
||||
// ProjectsListResponse 工程列表响应。
|
||||
type ProjectsListResponse struct {
|
||||
Total int `json:"total"`
|
||||
Projects []ProjectResponse `json:"projects"`
|
||||
}
|
||||
Reference in New Issue
Block a user