1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package model
- import (
- "ulink-admin/pkg/base"
- )
- type SysRole struct {
- base.BaseModel `xorm:"extends"`
- RoleName string `excel:"name=角色名称" xorm:"varchar(64)" json:"roleName" binding:"required"` //角色名称
- RoleKey string `excel:"name=角色权限" xorm:"varchar(64)" json:"roleKey" binding:"required"` //角色权限标识
- RoleSort int `excel:"name=角色排序" xorm:"int" json:"roleSort" ` //角色顺序
- DataScope string `excel:"-" json:"dataScope"` //数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)
- MenuCheckStrictly bool `excel:"-" json:"menuCheckStrictly"` //菜单树选择项是否关联显示
- DeptCheckStrictly bool `excel:"-" json:"deptCheckStrictly"` //部门树选择项是否关联显示
- Status string `excel:"name=角色状态,format=0=正常,1=停用" xorm:"char(1)" json:"status"` //角色状态 0正常1停用
- DelFlag string `excel:"" xorm:"char(1)" json:"delFlag"` //删除标记0正常1删除
- Remark string `excel:"" json:"remark" binding:"required" msg:"备注不能为空"` //备注
- Rights []string `xorm:"longtext json" excel:"" json:"rights" ` //控制权限
- CompanyId int64 `excel:"name=公司Id" xorm:"bigint(20)" json:"companyId" ` //公司Id
- MenuIds []int64 `xorm:"-" json:"menuIds"` //菜单组
- DeptIds []int64 `xorm:"-" json:"deptIds"` //部门组
- }
- func (r SysRole) TableName() string {
- return "sys_role"
- }
- func (r *SysRole) Key() int64 {
- return r.Id
- }
- func (r *SysRole) BeforeUpdate() {
- user := base.GetCurUser()
- if user != nil {
- r.UpdateBy = user.Name
- }
- if user.ComponyId > 0 {
- r.CompanyId = user.ComponyId
- }
- }
- func (r *SysRole) BeforeInsert() {
- user := base.GetCurUser()
- if user != nil {
- r.CreateBy = user.Name
- r.UpdateBy = user.Name
- }
- if user != nil && user.ComponyId > 0 {
- r.CompanyId = user.ComponyId
- }
- }
- func (r *SysRole) Model() interface{} {
- return r
- }
|