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.
ims/app/models/department.go

32 lines
1.9 KiB

2 months ago
package models
import (
"ims/util/db/dts"
"time"
"gorm.io/gorm"
)
// Department 部门
type Department struct {
ID uint `json:"id" gorm:"primaryKey"` // 部门编号
PID dts.NullUint `json:"pid" gorm:"column:pid;default:null;index:,unique,composite:uni_name_with_pid_and_company"` // 上级部门编号
Name string `json:"name" gorm:"index:,unique,composite:uni_name_with_pid_and_company"` // 部门名称
ManagerId dts.NullUint `json:"manager_id"` // 部门经理编号
Manager *Employee `json:"manager,omitempty" gorm:"foreignKey:ManagerId"` // 部门经理
Children []Department `json:"children,omitempty" gorm:"foreignKey:PID"` // 下级部门
Employees []Employee `json:"employees,omitempty" gorm:"many2many:department_employees;"` // 部门员工
CreatedBy uint `json:"created_by"` // 创建者(员工编号)
CreatedAt time.Time `json:"created_at"` // 创建时间
UpdatedBy dts.NullUint `json:"updated_by"` // 创建者(员工编号)
UpdatedAt dts.NullTime `json:"updated_at" gorm:"autoUpdateTime:false"` // 上次操作时间
DeletedBy dts.NullUint `json:"deleted_by"` // 删除者(员工编号)
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"` // 删除数据时间
Creator *Employee `json:"creator,omitempty" gorm:"foreignKey:CreatedBy"` // 创建数据的员工
Updater *Employee `json:"updater,omitempty" gorm:"foreignKey:UpdatedBy"` // 上次更新数据的员工
Deleter *Employee `json:"deleter,omitempty" gorm:"foreignKey:DeletedBy"` // 删除数据的员工
}