12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- from django.contrib.auth.models import User, Group
- from django.db.models import Model
- from mptt.fields import TreeForeignKey
- from mptt.models import MPTTModel
- from django.db import models
- class Menu(MPTTModel):
- name = models.CharField(max_length=100)
- config = models.TextField()
- create_at = models.DateTimeField(auto_now_add=True)
- create_by = models.ForeignKey(User, blank=True, null=True, on_delete=models.CASCADE)
- parent = TreeForeignKey('self', blank=True, null=True, on_delete=models.CASCADE)
- code = models.CharField(max_length=100)
- class Meta:
- app_label = 'basic'
- db_table = 'basic_menu'
- verbose_name = '报表菜单'
- verbose_name_plural = '报表菜单列表'
- class RouterMenu(MPTTModel):
- """
- 前端路由备份,用作中间表做权限
- """
- name = models.CharField(max_length=50)
- path = models.CharField(max_length=50)
- url = models.CharField(max_length=50)
- parent = TreeForeignKey('self', blank=True, null=True, on_delete=models.CASCADE)
- class Meta:
- verbose_name = '前端菜单'
- verbose_name_plural = '前端菜单列表'
- class GroupRouterMenu(Model):
- """
- 前端菜单的权限与角色绑定
- """
- group = models.ForeignKey(Group, blank=True, null=True, on_delete=models.CASCADE)
- menu = models.ForeignKey(RouterMenu, blank=True, null=True, on_delete=models.CASCADE)
- class Meta:
- verbose_name = '前端菜单与角色的中间表'
- verbose_name_plural = '前端菜单和角色的中间表列表'
|