role_menu.go 667 B

123456789101112131415161718192021222324252627282930
  1. package models
  2. type RoleMenu struct {
  3. Id int64 `xorm:"id"`
  4. PastureId int64 `xorm:"pastureid"`
  5. RoleId int64 `xorm:"role_id"`
  6. MenuId int64 `xorm:"menu_id"`
  7. DeletedOn int64 `xorm:"deleted_on"`
  8. SeeButton int32 `xorm:"seebutton"`
  9. EditButton int32 `xorm:"editbutton"`
  10. }
  11. func (r *RoleMenu) TableName() string {
  12. return "role_menu"
  13. }
  14. func NewRoleMenu(pastureId, roleId int64, menuList []*Menu) []*RoleMenu {
  15. res := make([]*RoleMenu, len(menuList))
  16. for i, v := range menuList {
  17. res[i] = &RoleMenu{
  18. PastureId: pastureId,
  19. RoleId: roleId,
  20. MenuId: v.Id,
  21. DeletedOn: 0,
  22. SeeButton: 1,
  23. EditButton: 1,
  24. }
  25. }
  26. return res
  27. }