You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

118 lines
5.1 KiB

package model
import (
"time"
"gorm.io/gorm"
)
// User 用户表
type User struct {
ID uint `json:"id" gorm:"primaryKey"`
Username string `json:"username" gorm:"uniqueIndex;size:50;not null"`
Email string `json:"email" gorm:"uniqueIndex;size:100;not null"`
Password string `json:"-" gorm:"size:255;not null"`
RealName string `json:"real_name" gorm:"size:50"`
Phone string `json:"phone" gorm:"size:20"`
Avatar string `json:"avatar" gorm:"size:255"`
Status int `json:"status" gorm:"default:1;comment:状态 1:启用 0:禁用"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}
// Organization 机构表
type Organization struct {
ID uint `json:"id" gorm:"primaryKey"`
Name string `json:"name" gorm:"size:100;not null"`
Code string `json:"code" gorm:"uniqueIndex;size:50;not null"`
ParentID uint `json:"parent_id" gorm:"default:0"`
Level int `json:"level" gorm:"default:1"`
Sort int `json:"sort" gorm:"default:0"`
Status int `json:"status" gorm:"default:1;comment:状态 1:启用 0:禁用"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}
// UserOrganization 用户机构关系表
type UserOrganization struct {
ID uint `json:"id" gorm:"primaryKey"`
UserID uint `json:"user_id" gorm:"not null"`
OrganizationID uint `json:"organization_id" gorm:"not null"`
Role string `json:"role" gorm:"size:20;default:'member';comment:角色 admin:管理员 member:成员"`
CreatedAt time.Time `json:"created_at"`
// 关联关系
User User `json:"user" gorm:"foreignKey:UserID"`
Organization Organization `json:"organization" gorm:"foreignKey:OrganizationID"`
}
// Task 任务表
type Task struct {
ID uint `json:"id" gorm:"primaryKey"`
Title string `json:"title" gorm:"size:255;not null"`
Description string `json:"description" gorm:"type:text"`
Type string `json:"type" gorm:"size:50"`
Priority string `json:"priority" gorm:"size:20;default:'medium';comment:优先级 urgent:紧急 high:高 medium:中 low:低"`
Status string `json:"status" gorm:"size:20;default:'pending';comment:状态 pending:待处理 in_progress:进行中 completed:已完成 cancelled:已取消"`
CreatorID uint `json:"creator_id" gorm:"not null"`
AssigneeID uint `json:"assignee_id"`
OrganizationID uint `json:"organization_id" gorm:"not null"`
StartTime *time.Time `json:"start_time"`
EndTime *time.Time `json:"end_time"`
CompletedAt *time.Time `json:"completed_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
// 关联关系
Creator User `json:"creator" gorm:"foreignKey:CreatorID"`
Assignee User `json:"assignee" gorm:"foreignKey:AssigneeID"`
Organization Organization `json:"organization" gorm:"foreignKey:OrganizationID"`
Comments []TaskComment `json:"comments" gorm:"foreignKey:TaskID"`
Attachments []TaskAttachment `json:"attachments" gorm:"foreignKey:TaskID"`
}
// TaskTag 任务标签表
type TaskTag struct {
ID uint `json:"id" gorm:"primaryKey"`
Name string `json:"name" gorm:"size:50;not null"`
Color string `json:"color" gorm:"size:20;default:'#409EFF'"`
OrganizationID uint `json:"organization_id" gorm:"not null"`
CreatedAt time.Time `json:"created_at"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}
// TaskTagRelation 任务标签关系表
type TaskTagRelation struct {
ID uint `json:"id" gorm:"primaryKey"`
TaskID uint `json:"task_id" gorm:"not null"`
TagID uint `json:"tag_id" gorm:"not null"`
}
// TaskComment 任务评论表
type TaskComment struct {
ID uint `json:"id" gorm:"primaryKey"`
TaskID uint `json:"task_id" gorm:"not null"`
UserID uint `json:"user_id" gorm:"not null"`
Content string `json:"content" gorm:"type:text;not null"`
CreatedAt time.Time `json:"created_at"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
// 关联关系
User User `json:"user" gorm:"foreignKey:UserID"`
}
// TaskAttachment 任务附件表
type TaskAttachment struct {
ID uint `json:"id" gorm:"primaryKey"`
TaskID uint `json:"task_id" gorm:"not null"`
FileName string `json:"file_name" gorm:"size:255;not null"`
FilePath string `json:"file_path" gorm:"size:500;not null"`
FileSize int64 `json:"file_size"`
FileType string `json:"file_type" gorm:"size:50"`
UploadedBy uint `json:"uploaded_by" gorm:"not null"`
CreatedAt time.Time `json:"created_at"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}