57 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
| from django.db import models
 | |
| from apps.system.models import Post, User
 | |
| from apps.utils.models import CommonADModel, CommonBModel
 | |
| # Create your models here.
 | |
| 
 | |
| 
 | |
| class Area(CommonBModel):
 | |
|     """
 | |
|     地图区域
 | |
|     """
 | |
|     AREA_LEVEL_1 = 10
 | |
|     AREA_LEVEL_2 = 20
 | |
|     AREA_LEVEL_3 = 30
 | |
|     AREA_LEVEL_4 = 40
 | |
|     AREA_LEVEL_CHOICES = (
 | |
|         (AREA_LEVEL_1, '办公'),
 | |
|         (AREA_LEVEL_2, '生产一般'),
 | |
|         (AREA_LEVEL_3, '生产重点'),
 | |
|         (AREA_LEVEL_4, '四级')
 | |
|     )
 | |
|     AREA_TYPE_FIX = 10
 | |
|     AREA_TYPE_TEMP = 20
 | |
|     AREA_TYPE_CHOICES = (
 | |
|         (10, '固定'),
 | |
|         (20, '临时')
 | |
|     )
 | |
|     name = models.CharField('名称', max_length=20)
 | |
|     type = models.PositiveSmallIntegerField('区域类型', default=10, choices=AREA_TYPE_CHOICES)
 | |
|     level = models.PositiveSmallIntegerField('区域等级')
 | |
|     number = models.CharField('编号', max_length=20, null=True, blank=True)
 | |
|     visitor_yes = models.BooleanField('准许访客人员', default=False)
 | |
|     remployee_yes = models.BooleanField('准许相关方人员', default=False)
 | |
|     employee_yes = models.BooleanField('准许全部员工', default=True)
 | |
|     posts_access = models.ManyToManyField(Post, through='am.access')
 | |
|     third_info = models.JSONField('三方信息', default=dict,
 | |
|                                   null=False, blank=True)
 | |
| 
 | |
|     def __str__(self) -> str:
 | |
|         return self.name
 | |
| 
 | |
| 
 | |
| class Access(CommonADModel):
 | |
|     """
 | |
|     岗位准入权限
 | |
|     """
 | |
|     ACCESS_IN_YES = 10
 | |
|     ACCESS_IN_NO = 20
 | |
|     ACCESS_CHOICE = (
 | |
|         (ACCESS_IN_YES, '准入'),
 | |
|         (ACCESS_IN_NO, '禁入')
 | |
|     )
 | |
|     type = models.PositiveSmallIntegerField('准入类型', choices=ACCESS_CHOICE)
 | |
|     area = models.ForeignKey(Area, verbose_name='关联区域',
 | |
|                              on_delete=models.CASCADE)
 | |
|     post = models.ForeignKey(Post, verbose_name='关联岗位',
 | |
|                              on_delete=models.CASCADE)
 |