package models

import coreTypes "git.apinb.com/bsm-sdk/core/types"

// 角色模型
type MgtRole struct {
	coreTypes.Std_IICUDS                  // 标准字段
	Name                 string           `gorm:"column:name;type:varchar(255);uniqueIndex" json:"name,omitempty"`                                                                       // 角色名称
	Description          string           `gorm:"column:description;type:text" json:"description,omitempty"`                                                                             // 角色描述
	Users                []MgtUser        `gorm:"many2many:mgt_link_user_role;foreignKey:ID;joinForeignKey:role_id;References:ID;joinReferences:user_id" json:"users,omitempty"`         // 角色关联的用户
	Departments          []MgtDepartment  `gorm:"many2many:mgt_link_dpt_role;foreignKey:ID;joinForeignKey:role_id;References:ID;joinReferences:dpt_id" json:"departments,omitempty"`     // 关联的部门（部门替代用户组）
	Permissions          []MgtPermission  `gorm:"many2many:mgt_link_role_pmn;foreignKey:ID;joinForeignKey:role_id;References:ID;joinReferences:pmn_id" json:"permissions,omitempty"`     // 角色关联的权限
	PmnApplication       []MgtApplication `gorm:"many2many:mgt_link_role_pmn;foreignKey:ID;joinForeignKey:role_id;References:ID;joinReferences:app_id" json:"pmn_application,omitempty"` // 用户关联的角色
	Application          []MgtApplication `gorm:"many2many:mgt_link_role_app;foreignKey:ID;joinForeignKey:role_id;References:ID;joinReferences:app_id" json:"application,omitempty"`     // 用户关联的角色
}

// func init() {
// 	database.AppendMigrate(&Role{})
// }
