package system import ( "context" "hongze/fms_api/global" "time" ) // 角色和菜单关联表 type SysRoleMenu struct { RoleMenuId int64 `gorm:"primaryKey;column:role_menu_id" json:"_"` //序号 RoleId int64 `gorm:"column:role_id" json:"role_id"` //角色ID MenuId int64 `gorm:"column:menu_id" json:"menu_id"` //菜单ID CreateTime time.Time `gorm:"autoCreateTime;column:create_time" json:"create_time"` //创建时间 ModifyTime time.Time `gorm:"autoUpdateTime:milli;column:modify_time" json:"modify_time"` //最后更新时间 } // TableName get sql table name.获取数据库表名 func (rm *SysRoleMenu) TableName() string { return "sys_role_menu" } // 批量新增 func (rm *SysRoleMenu) AddMulti(list []*SysRoleMenu) (err error) { err = global.DEFAULT_MYSQL.CreateInBatches(list, len(list)).Error return } // 删除 func (rm *SysRoleMenu) DeleteByCondition(condition string, pars []interface{}) (err error) { err = global.DEFAULT_MYSQL.Where(condition, pars...).Delete(rm).Error return } func (rm *SysRoleMenu) GetMenuListByCondition(condition string, pars []interface{}) (results []*SysRoleMenu, err error) { err = global.DEFAULT_MYSQL.WithContext(context.TODO()).Model(rm). Table("sys_role_menu as rm "). Select("rm.*"). Joins("Inner JOIN sys_menu r ON rm.menu_id = r.menu_id"). Where(condition, pars...).Find(&results).Error return }