package models

type Purview struct {
	Id                  int64      `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
	Parentid            int64      `json:"pid"`                                                // 父级ID
	Module              int8       `json:"module"`                                             // 所属应用类型 1.病友经营;2.科普号;3.血透经营;4.慢病管理;
	Name                string     `json:"name"`                                               // 规则名称(也是菜单名)
	Urlfor              string     `json:"urlfor"`                                             // 规则唯一英文标识,(Controller.Method)
	MenuIconClass       string     `gorm:"menu_icon_class" json:"menu_icon_class"`             // 菜单图标的 css 样式
	SuperAdminExclusive int8       `gorm:"super_admin_exclusive" json:"super_admin_exclusive"` // 是否为超级管理员专属 0否1是
	Listorder           int        `json:"-"`                                                  // 排序ID
	Status              int8       `json:"status"`                                             // 状态 0.无效 1.有效 2.禁用
	CreateTime          int64      `gorm:"column:ctime" json:"-"`                              // 创建时间
	ModifyTime          int64      `gorm:"column:mtime" json:"-"`                              // 修改时间
	Purview             []*Purview `gorm:"ForeignKey:Parentid;AssociationForeignKey:ID" json:"sub_purview"`
	IconUrl             string     `gorm:"column:icon_url" json:"icon_url" form:"icon_url"`
	Desc                string     `gorm:"column:desc" json:"desc" form:"desc"`
	Link                string     `gorm:"-" json:"link"`   // urlfor 解析后的链接
	Childs              []*Purview `gorm:"-" json:"childs"` // 子节点
	ParentUrl           string     `gorm:"column:parent_url" json:"parent_url" form:"parent_url"`
}

func (Purview) TableName() string {
	return "sgj_user_purview"
}

type RolePurview struct {
	Id         int64 `gorm:"PRIMARY_KEY;AUTO_INCREMENT"`
	RoleId     int64
	OrgId      int64
	AppId      int64
	PurviewIds string `gorm:"column:purview_ids"`
	Status     int8   // 状态 0.无效 1.有效 2.禁用
	CreateTime int64  `gorm:"column:ctime"` // 创建时间
	ModifyTime int64  `gorm:"column:mtime"` // 修改时间
	Role       Role   `gorm:"ForeignKey:RoleId;AssociationForeignKey:ID" json:"role_info"`
}

func (RolePurview) TableName() string {
	return "sgj_user_role_purview"
}

type SgjUserOperatePurview struct {
	ID       int64  `gorm:"column:id" json:"id" form:"id"`
	Module   int64  `gorm:"column:module" json:"module" form:"module"`
	Name     string `gorm:"column:name" json:"name" form:"name"`
	Urlfor   string `gorm:"column:urlfor" json:"urlfor" form:"urlfor"`
	Parentid int64  `gorm:"column:parentid" json:"parentid" form:"parentid"`
	ErrorMsg string `gorm:"column:error_msg" json:"error_msg" form:"error_msg"`
	Status   int64  `gorm:"column:status" json:"status" form:"status"`
	Ctime    int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
	Mtime    int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
}

func (SgjUserOperatePurview) TableName() string {
	return "sgj_user_operate_purview"
}