OA项目-表结构
############### 新建APP并配置 ###############
INSTALLED_APPS = [
...
'apps.users.apps.UsersConfig',
'apps.rbac.apps.RbacConfig',
'apps.system.apps.SystemConfig',
'apps.adm.apps.AdmConfig',
'apps.personal.apps.PersonalConfig', ]
############### 表结构-users ###############
from datetime import datetime from django.db import models
from django.contrib.auth.models import AbstractUser from rbac.models import Role class UserProfile(AbstractUser):
"""
用户: makemigration提示错误:sers.UserProfile.user_permissions: (fields.E304),
需要在settings中指定自定义认证模型:AUTH_USER_MODEL = 'users.UserProfile'
"""
name = models.CharField(max_length=20, default="", verbose_name="姓名")
birthday = models.DateField(null=True, blank=True, verbose_name="出生日期")
gender = models.CharField(max_length=10, choices=(("male", "男"), ("famale", "女")), default="male",
verbose_name="性别")
mobile = models.CharField(max_length=11, default="", verbose_name="电话")
email = models.EmailField(max_length=100, verbose_name="邮箱")
image = models.ImageField(upload_to="image/%Y/%m", default="image/default.jpg", max_length=100, null=True,
blank=True)
department = models.ForeignKey("Structure", null=True, blank=True, verbose_name="部门")
post = models.CharField(max_length=50, null=True, blank=True, verbose_name="职位")
superior = models.ForeignKey("self", null=True, blank=True, verbose_name="上级主管")
roles = models.ManyToManyField("rbac.Role", verbose_name="角色", blank=True)
joined_date = models.DateField(null=True, blank=True, verbose_name="入职日期") class Meta:
verbose_name = "用户信息"
verbose_name_plural = verbose_name
ordering = ['id'] def __str__(self):
return self.name class Structure(models.Model):
"""
组织架构
"""
type_choices = (("firm", "公司"), ("department", "部门"))
title = models.CharField(max_length=60, verbose_name="名称")
type = models.CharField(max_length=20, choices=type_choices, default="department", verbose_name="类型")
parent = models.ForeignKey("self", null=True, blank=True, verbose_name="父类架构") class Meta:
verbose_name = "组织架构"
verbose_name_plural = verbose_name def __str__(self):
return self.title
############### 表结构-system ###############
from django.db import models # Create your models here. class SystemSetup(models.Model):
loginTitle = models.CharField(max_length=20, null=True, blank=True, verbose_name='登录标题')
mainTitle = models.CharField(max_length=20, null=True, blank=True, verbose_name='系统标题')
headTitle = models.CharField(max_length=20, null=True, blank=True, verbose_name='浏览器标题')
copyright = models.CharField(max_length=100, null=True, blank=True, verbose_name='底部版权信息')
url = models.CharField(max_length=50, null=True, blank=True, verbose_name='系统URL地址') def __str__(self):
return self.loginTitle class Meta:
verbose_name = "系统设置"
verbose_name_plural = verbose_name @classmethod
def getSystemSetupLastData(self):
return dict(system_setup=SystemSetup.objects.last()) class EmailSetup(models.Model):
emailHost = models.CharField(max_length=30, verbose_name='SMTP服务器')
emailPort = models.IntegerField(verbose_name='SMTP端口')
emailUser = models.EmailField(max_length=100, verbose_name='邮箱帐号')
emailPassword = models.CharField(max_length=30, verbose_name='邮箱密码') def __str__(self):
return self.emailHost class Meta:
verbose_name = '发件邮箱设置'
verbose_name_plural = verbose_name @classmethod
def getEmailSetupLastData(self):
return EmailSetup.objects.last()
############### 表结构-rbac ###############
from django.db import models class Menu(models.Model):
"""
菜单
"""
title = models.CharField(max_length=32, unique=True, verbose_name="菜单名")
parent = models.ForeignKey("self", null=True, blank=True, verbose_name="父菜单")
is_top = models.BooleanField(default=False, verbose_name="首页显示")
icon = models.CharField(max_length=50, null=True, blank=True, verbose_name="图标")
code = models.CharField(max_length=50, null=True, blank=True, verbose_name="编码")
url = models.CharField(max_length=128, unique=True, null=True, blank=True) def __str__(self):
title_list = [self.title]
p = self.parent
while p:
title_list.insert(0, p.title)
p = p.parent
return '-'.join(title_list) class Meta:
verbose_name = "菜单"
verbose_name_plural = verbose_name @classmethod
def getMenuByRequestUrl(self, url):
ret = dict(menu=Menu.objects.get(url=url))
return ret class Role(models.Model):
"""
角色:绑定权限
"""
title = models.CharField(max_length=32)
permissions = models.ManyToManyField("menu", blank=True) def __str__(self):
return self.title class Meta:
verbose_name = "角色"
verbose_name_plural = verbose_name
############### 表结构-personal ###############
from django.db import models from django.contrib.auth import get_user_model from adm.models import Customer User = get_user_model() class WorkOrder(models.Model):
type_choices = (('', '初次安装'), ('', '售后现场'), ('', '远程支持'), ('', '售前支持'))
status_choices = (('', '工单已退回'), ('', '新建-保存'), ('', '提交-等待审批'), ('', '已审批-等待执行'), ('', '已执行-等待确认'), ('', '工单已完成'))
number = models.CharField(max_length=10, verbose_name='工单号')
title = models.CharField(max_length=50, verbose_name='标题')
type = models.CharField(max_length=10, choices=type_choices, default='', verbose_name='工单类型')
status = models.CharField(max_length=10, choices=status_choices, default='', verbose_name='工单状态')
do_time = models.DateTimeField(default='', verbose_name='安排时间')
add_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
content = models.CharField(max_length=300, verbose_name='工单内容')
file_content = models.FileField(upload_to='file/%Y/%m', blank=True, null=True, verbose_name='项目资料')
customer = models.ForeignKey(Customer, verbose_name='客户信息')
proposer = models.ForeignKey(User, related_name='proposer', blank=True, null=True, on_delete=models.SET_NULL, verbose_name='申请人')
approver = models.ForeignKey(User, related_name='approver', blank=True, null=True, on_delete=models.SET_NULL, verbose_name='审批人')
receiver = models.ForeignKey(User, related_name='receiver', blank=True, null=True, on_delete=models.SET_NULL, verbose_name='接单人') class Meta:
verbose_name = '工单信息'
verbose_name_plural = verbose_name def __str__(self):
return self.title class WorkOrderRecord(models.Model):
type_choices = (('', '退回'), ('', "派发"), ('', "执行"), ('', "确认"))
name = models.ForeignKey(User, verbose_name=u"记录人")
work_order = models.ForeignKey(WorkOrder, verbose_name=u"工单信息")
record_type = models.CharField(max_length=10, choices=type_choices, verbose_name=u"记录类型")
content = models.CharField(max_length=500, verbose_name=u"记录内容", default="")
file_content = models.FileField(upload_to='file/%Y/%m', blank=True, null=True, verbose_name='实施文档')
add_time = models.DateTimeField(auto_now_add=True, verbose_name=u"记录时间") class Meta:
verbose_name = u"执行记录"
verbose_name_plural = verbose_name def __str__(self):
return self.record_type
############### 表结构-adm ###############
from django.db import models
from django.contrib.auth import get_user_model User = get_user_model() class Supplier(models.Model):
"""
分销商管理
"""
company = models.CharField(max_length=30, verbose_name="公司名称")
address = models.CharField(max_length=100, verbose_name="地址")
linkname = models.CharField(max_length=20, verbose_name="联系人")
phone = models.CharField(max_length=20, verbose_name="联系电话")
status = models.BooleanField(default=True, verbose_name="状态")
belongs_to = models.ForeignKey(User, blank=True, null=True, on_delete=models.SET_NULL, verbose_name="责任人")
desc = models.TextField(blank=True, null=True, verbose_name="备注")
add_time = models.DateTimeField(auto_now_add=True, verbose_name="添加时间") class Meta:
verbose_name = "分销商管理"
verbose_name_plural = verbose_name def __str__(self):
return self.company class Customer(models.Model):
"""
客户信息
"""
unit = models.CharField(max_length=50, verbose_name="客户单位")
address = models.CharField(max_length=100, verbose_name="地址")
name = models.CharField(max_length=20, verbose_name="联系人")
phone = models.CharField(max_length=30, verbose_name="联系电话")
belongs_to = models.ForeignKey(User, blank=True, null=True , on_delete=models.SET_NULL, verbose_name="责任人")
status = models.BooleanField(default=True, verbose_name="状态")
desc = models.TextField(blank=True, null=True, verbose_name="备注")
add_time = models.DateTimeField(auto_now_add=True, verbose_name="添加时间") class Meta:
verbose_name = "客户管理"
verbose_name_plural = verbose_name def __str__(self):
return self.unit class AssetType(models.Model):
"""
资产类型
"""
name = models.CharField(max_length=30, verbose_name="类型名称", help_text="类型名称")
desc = models.TextField(blank=True, null=True, verbose_name="备注") class Meta:
verbose_name = "资产类型" def __str__(self):
return self.name class Asset(models.Model):
asset_status = (
("", "闲置"),
("", "在用"),
("", "维修"),
("", "报废"),
("", "售出")
)
warehouse_choices = (
("", "南京"),
("", "苏州"),
)
assetNum = models.CharField(max_length=128, default="", verbose_name="资产编号")
assetType = models.ForeignKey(AssetType, blank=True, null=True, on_delete=models.SET_NULL, verbose_name="资产类型")
brand = models.CharField(max_length=20, blank=True, null=True, verbose_name="品牌")
model = models.CharField(max_length=30, default="", verbose_name="型号")
warehouse = models.CharField(choices=warehouse_choices, default="", max_length=20, verbose_name="仓库")
price = models.IntegerField(blank=True, null=True, verbose_name="价格")
buyDate = models.DateField(verbose_name="购买日期")
warrantyDate = models.DateField(verbose_name="到保日期")
status = models.CharField(choices=asset_status, max_length=20, default="", verbose_name="资产状态")
customer = models.CharField(max_length=80, default="", blank=True, null=True, verbose_name="客户信息")
owner = models.ForeignKey(User, blank=True, null=True, on_delete=models.SET_NULL, verbose_name="使用人")
operator = models.CharField(max_length=20, default="", verbose_name="入库人")
add_time = models.DateTimeField(auto_now_add=True, verbose_name="添加时间")
desc = models.TextField(default="", blank=True, null=True, verbose_name="备注信息") class Meta:
verbose_name = "资产管理"
verbose_name_plural = verbose_name def __str__(self):
return self.assetNum class AssetFile(models.Model):
asset = models.ForeignKey(Asset, blank=True, null=True, on_delete=models.SET_NULL, verbose_name="资产")
upload_user = models.CharField(max_length=20, verbose_name="上传人")
file_content = models.ImageField(upload_to="asset_file/%Y/%m", null=True, blank=True, verbose_name="资产文件")
add_time = models.DateTimeField(auto_now_add=True, verbose_name="上传时间") class AssetLog(models.Model):
asset = models.ForeignKey(Asset, verbose_name="资产")
operator = models.CharField(max_length=20, verbose_name="操作人")
desc = models.TextField(default="", verbose_name="备注")
add_time = models.DateTimeField(auto_now_add=True, verbose_name="添加时间") class Mate:
verbose_name = "变更记录"
verbose_name_plural = verbose_name def __str__(self):
return self.asset class ServiceInfo(models.Model):
content = models.TextField(verbose_name="记录内容")
writer = models.ForeignKey(User, blank=True, null=True, on_delete=models.SET_NULL, verbose_name="记录人")
is_reminding = models.BooleanField(default=False, verbose_name="邮件消息提醒")
add_time = models.DateTimeField(auto_now_add=True, verbose_name="添加时间") class Mate:
verbose_name = "服务记录"
verbose_name_plural = verbose_name def __str__(self):
return self.content class EquipmentType(models.Model):
"""
设备类型
"""
name = models.CharField(max_length=30, verbose_name="类型名称", help_text="类型名称")
desc = models.TextField(blank=True, null=True, verbose_name="备注") class Meta:
verbose_name = "设备类型"
verbose_name_plural = verbose_name
ordering = ['id'] def __str__(self):
return self.name class Equipment(models.Model):
number = models.CharField(max_length=30, default="", verbose_name="设备编号")
equipment_type = models.ForeignKey(EquipmentType, blank=True, null=True, on_delete=models.SET_NULL, verbose_name="设备类型")
equipment_model = models.CharField(max_length=50, default="", verbose_name="设备型号")
buy_date = models.DateField(verbose_name="购买日期")
warranty_date = models.DateField(verbose_name="质保日期")
accounting = models.BooleanField(default=False, verbose_name="费用核算状态")
config_desc = models.TextField(blank=True, null=True, verbose_name="配置说明")
customer = models.ForeignKey(Customer, blank=True, null=True, on_delete=models.SET_NULL, verbose_name="客户信息")
supplier = models.ForeignKey(Supplier, blank=True, null=True, on_delete=models.SET_NULL, verbose_name="分销商")
service_info = models.ManyToManyField(ServiceInfo, blank=True, verbose_name="服务记录") class Meta:
verbose_name = "设备管理"
verbose_name_plural = verbose_name def __str__(self):
return self.number
############### 数据库迁移 ###############
数据库迁移:
生成迁移 python manage.py makemigrations
执行迁移 python manage.py migrate
############### auth配置 ###############
AUTH_USER_MODEL = 'users.UserProfile'
############### 表结构 ###############
OA项目-表结构的更多相关文章
- 为什么要用hibernate 与基于数据库表结构的项目开发
最近开始学习hibernate,其实并不知道要学习什么,有什么用.后来问了一下同事,他就说快捷方便简单,很多事情不用自己做他会帮你做好,但是我觉得不应该是这样的,于是我就去搜了一下,就搜到了一篇帖子, ...
- 基于SSH2的OA项目1.0_20161206_需求分析与框架搭建
1. SSH项目 OA项目,办公自动化,将公司的数据,文档,流程实现在系统中的管理. 降低人员交流过程中的成本.提高办公的效率. 2 .系统管理 主要实现系统权限的管理,不同的用户登陆后看到菜单项不一 ...
- 菜鸟学SSH(十二)——Hibernate与Spring配合生成表结构
前几天向大家介绍了一种用工具类生成数据表的方法,只是之前的方法须要使用一个跟项目关系不大的工具类.不免让人认为有些多余,所以呢.今天再向大家介绍一种方法.即Hibernate与Spring配合生成表结 ...
- 微调数据库表结构,30 分钟搞定 WordPress 数据库查询缓慢问题
同事的美女图片站,基于 WordPress 搭建的,因为数据越来越多,变得慢,我从 PHP slow log 里面看出是 WordPress 有些查询总是很慢,即使已经安装了页面缓存插件,但是由于页面 ...
- oa项目面试准备
熟悉项目在ssm框架下的编程流程,了解mysql html spring springmvc mybatis技术.了解过springboot编程. 在上个寒假跟着培训机构用springboot框架编写 ...
- SqlServer表结构查询
一.前言 近两天项目升级数据迁移,将老版本(sqlserver)的数据迁移到新版本(mysql)数据库,需要整理一个Excel表格出来,映射两个库之间的表格字段,示例如下: Mysql数据库查询表结构 ...
- 【Java EE 学习 67 上】【OA项目练习】【JBPM工作流的使用】
OA项目中有极大可能性使用到JBPM框架解决流程控制问题,比如请假流程.报销流程等等. JBPM:JBoss Business Process Management,翻译过来就是业务流程管理.实际上就 ...
- 【Normal Form】数据库表结构设计所遵从的范式
参考的优秀文章 数据库(第一范式,第二范式,第三范式) 数据库设计是件严肃.关键的事儿,一毕业,加入一个大型的行业项目,那儿的前辈资深工程师,就给我灌输数据库如何关键.神圣.深不可测的观念,所以,我一 ...
- Laravel项目目录结构说明
Laravel项目目录结构说明: |- vendor 目录包含你的 Composer 依赖模块及laravel框架. |- bootstrap 目录包含几个框架启动跟自动加载配置的文件. |- app ...
随机推荐
- VUE中的MVVM模式
1.传统MVP模式:业务逻辑相关的控制层 M:模型层,ajax请求 V:dom层,视图 P:控制器.js代码之类的 2.MVVM MVVM模式主要操作数据层,代码减少量是MVP的30%甚至70%
- 69.ORM查询条件:isnull和regex的使用
首先查看数据库中的article表的数据: 定义模型的文件models.py中的示例代码如下: from django.db import models class Category(models.M ...
- mysql查询用if控制显示列
1: select *,if(sex=1,”男”,”女”) as sex from user2: select CASE sex WHEN 1 THEN ‘男’ ELSE ‘女’ END as sex ...
- JNI传递修改自定义Java Class数组数据
声明:迁移自本人CSDN博客https://blog.csdn.net/u013365635 结合前面讲的2篇关于JNI的文章,这里直接把代码贴上,主要是要知道如果传递自定义Class Array的时 ...
- 把Android studio的日志导入目标文件中
最好是在Android studio的命令行工具中进行命令操作. adb logcat -v time > /Users/z/log.txt adb logcat -v time > /U ...
- HDU 2094产生冠军(set思维题)
Problem Description 有一群人,打乒乓球比赛,两两捉对撕杀,每两个人之间最多打一场比赛.球赛的规则如下:如果A打败了B,B又打败了C,而A与C之间没有进行过比赛,那么就认定,A一定能 ...
- Python—使用列表构造队列数据结构
队列的概念 只允许在一端插入数据操作,在另一端进行删除数据操作的特殊线性表:进行插入操作的一端称为队尾(入队列),进行删除操作的一端称为队头(出队列):队列具有先进先出(FIFO)的特性. # _*_ ...
- 销售de经典语录
[销售的境界] 1.顾客要的不是便宜,而是感觉上占了便宜: 2.不要与顾客争论价格,要与顾客讨论价值: 3.没有不对的客户,只有不够好的服务: 4.卖什么不重要,重要的是怎么卖: 5.没有最好的产品, ...
- 利用salt-stack 对多台分布式应用进行简单部署jar包项目:
/appsystems/JQM-SERVER/shell/stopServer.sh: ----用脚本停止应用 cmd. ...
- 4. react 基础 - 编写 todoList 功能
编写 TodoList 功能 react 入口 js #src/index.js import React from 'react'; import ReactDOM from 'react-dom' ...