1. 程式人生 > 實用技巧 >工單系統表的設計

工單系統表的設計

工單系統表的設計

  1. apps/user.py/model.py

    1. from django.contrib.auth.models import AbstractUser
      from django.db import models
      
      
      # Create your models here.
      
      # 使用者表
      
      class User(AbstractUser):
          mobile = models.CharField('手機號', max_length=32, null=True)
          email = models.CharField('電子郵箱', max_length=50, null=True)
      
          class Meta:
              db_table = '使用者表'
      
      
      # 中文角色名稱
      class Role(models.Model):
          zh_name = models.CharField('中文角色名稱', max_length=32)
          name = models.CharField('角色名稱', max_length=32)
          description = models.TextField('描述')
      
          class Meta:
              db_table = '角色名稱表'
      
      
      # 使用者角色表   關係關聯表
      class UserRole(models.Model):
          user = models.ForeignKey(User, on_delete=models.CASCADE)
          roles = models.ForeignKey(Role, on_delete=models.CASCADE)
      
          class Meta:
              db_table = '使用者角色表'
      
  2. apps/workflow.py/model.py

    1. from django.db import models
      
      # Create your models here.
      
      # 工單分類
      from user.models import User
      
      
      # 工單模板
      class FlowConf(models.Model):
          name = models.CharField('工作流名稱', max_length=32)
          customfield = models.TextField('自定義欄位')
          description = models.TextField('描述', )
      
          class Meta:
              db_table = '工單模板'
      
      
      # 工單分類
      # class FlowType(models.Model):
      #     name = models.CharField('工作流名稱', max_length=50)
      #     description = models.TextField('描述', )
      #     flowconf = models.ForeignKey(FlowConf, on_delete=models.CASCADE)
      
      
      # 配置審批流
      class NewFlowUserRoleActionConf(models.Model):
          flowconf = models.ForeignKey(FlowConf, on_delete=models.CASCADE)
          sequence = models.IntegerField('審批序號', )
          approvetype = models.CharField('審批型別', max_length=32, choices=(('1', 'user'), ('2', 'role')))
          approve_type_id = models.CharField('審批id', max_length=32)
      
          class Meta:
              db_table = '配置審批流'
      
      # 自動化工單配置
      # class AutoActionConf(models.Model):
      #     flowconf = models.ManyToManyField(FlowConf)
      #     scriptpath = models.CharField('執行指令碼路徑', max_length=50)
      #     url = models.CharField('自動化呼叫路徑', max_length=200)
      #     method = models.CharField('呼叫自動化介面', max_length=32)
      #     timeout = models.CharField('自動化執行超時時間', max_length=32)
      
      
  3. apps/workeorderpy/model.py

    1. from django.contrib.auth.models import AbstractUser
      from django.db import models
      
      
      # Create your models here.
      
      # 使用者表
      
      class User(AbstractUser):
          mobile = models.CharField('手機號', max_length=32, null=True)
          email = models.CharField('電子郵箱', max_length=50, null=True)
      
          class Meta:
              db_table = '使用者表'
      
      
      # 中文角色名稱
      class Role(models.Model):
          zh_name = models.CharField('中文角色名稱', max_length=32)
          name = models.CharField('角色名稱', max_length=32)
          description = models.TextField('描述')
      
          class Meta:
              db_table = '角色名稱表'
      
      
      # 使用者角色表   關係關聯表
      class UserRole(models.Model):
          user = models.ForeignKey(User, on_delete=models.CASCADE)
          roles = models.ForeignKey(Role, on_delete=models.CASCADE)
      
          class Meta:
              db_table = '使用者角色表'