package model import ( model2 "Medical_OAuth/common/model" "errors" "fmt" "gorm.io/gorm" ) type SysDept struct { model2.Model ParentId int `json:"parentId" gorm:""` //上级部门 DeptPath string `json:"deptPath" gorm:"size:255;" swaggerignore:"true"` // DeptName string `json:"deptName" gorm:"size:128;"` //部门名称 Sort int `json:"sort" gorm:"size:4;"` //排序 Status int `json:"status" gorm:"size:4;"` //状态 1-停用 2-正常 Children []SysDept `json:"children" gorm:"-"` model2.ControlBy model2.ModelTime } func (SysDept) TableName() string { return "sys_dept" } func (e *SysDept) Generate() model2.ActiveRecord { o := *e return &o } func (e *SysDept) GetId() interface{} { return e.Id } func (e *SysDept) BeforeDelete(_ *gorm.DB) (err error) { if e.Id == 1 { return errors.New("禁止删除系统部门") } return } func GetEnterDeptCacheKey(userId int) string { return fmt.Sprintf("enter-dept-%d", userId) } func GetEnterDeptNameCacheKey(userId int) string { return fmt.Sprintf("enter-dept-name-%d", userId) }