sys_role.go 566 B

1234567891011121314151617181920212223242526272829303132333435
  1. package model
  2. import (
  3. model2 "Medical_OAuth/common/model"
  4. coreModel "gogs.baozhida.cn/zoie/OAuth-core/model"
  5. "errors"
  6. "gorm.io/gorm"
  7. )
  8. type SysRole struct {
  9. model2.Model
  10. coreModel.Role
  11. model2.ControlBy
  12. model2.ModelTime
  13. }
  14. func (SysRole) TableName() string {
  15. return "sys_role"
  16. }
  17. func (e *SysRole) Generate() model2.ActiveRecord {
  18. o := *e
  19. return &o
  20. }
  21. func (e *SysRole) GetId() interface{} {
  22. return e.Id
  23. }
  24. func (e *SysRole) BeforeDelete(_ *gorm.DB) (err error) {
  25. if e.RoleKey == "admin" {
  26. return errors.New("禁止删除系统角色")
  27. }
  28. return
  29. }