123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- from django.contrib.auth.base_user import AbstractBaseUser
- from django.contrib.auth.models import PermissionsMixin, AbstractUser
- from django.db import models
- # Create your models here.
- class Permission(models.Model):
- id = models.CharField(max_length=128, primary_key=True, unique=True, verbose_name='权限ID',
- default="TestLaboratory_V1_Permission_1")
- name = models.CharField(max_length=25, verbose_name='权限名')
- url = models.URLField(max_length=125, null=True, blank=True, verbose_name='URL')
- # get, post, put, delete
- method = models.CharField(max_length=20, null=True, verbose_name='方法')
- create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
- update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
- delete = models.BooleanField(default=False)
- def __str__(self):
- return self.name
- class Meta:
- verbose_name = '权限'
- verbose_name_plural = verbose_name
- db_table = 'permission'
- class Role(models.Model):
- id = models.CharField(max_length=128, primary_key=True, unique=True, verbose_name='角色ID',
- default='TestLaboratory_V1_Role_1')
- name = models.CharField(max_length=25, unique=True, verbose_name='角色名')
- permissions = models.ManyToManyField(Permission, blank=True, verbose_name='权限信息')
- create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
- update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
- delete = models.BooleanField(default=False)
- def __str__(self):
- return self.name
- class Meta:
- verbose_name = '角色'
- verbose_name_plural = verbose_name
- db_table = 'role'
- class User(models.Model):
- id = models.CharField(max_length=128, unique=True, primary_key=True, verbose_name='用户编号',
- default='TestLaboratory_V1_User_1')
- username = models.CharField(max_length=30, unique=True, verbose_name='用户名')
- name = models.CharField(max_length=20, verbose_name='姓名')
- password = models.CharField(max_length=60, default='123456', verbose_name='密码')
- tel = models.CharField(max_length=20, verbose_name='联系方式')
- identify = models.IntegerField(verbose_name='身份信息')
- roles = models.ManyToManyField(Role, blank=True, verbose_name='角色信息')
- # group = models.CharField(max_length=128, default='默认分组', verbose_name='分组')
- create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
- update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
- is_login = models.BooleanField(default=False)
- delete = models.BooleanField(default=False)
- def __str__(self):
- return self.username
- class Meta:
- verbose_name = '用户'
- verbose_name_plural = verbose_name
- db_table = 'user'
|