Files
jyls_django/User/models.py
2026-01-30 15:22:07 +08:00

91 lines
5.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from django.db import models
from business.models import role
# Create your models here.
class Department(models.Model):
username = models.CharField(max_length=100) # 部门名称
is_deleted = models.BooleanField(default=False) # 软删除标记
class Team(models.Model):
"""团队模型"""
TEAM_TYPE_CHOICES = [
('personal', '个人团队'),
('team', '团队'),
]
name = models.CharField(max_length=100) # 团队名称
team_type = models.CharField(max_length=20, choices=TEAM_TYPE_CHOICES, default='team') # 团队类型:个人团队/团队
description = models.TextField(null=True, blank=True) # 团队描述
approvers = models.ManyToManyField('User', related_name='approver_teams', blank=True) # 审核人(多对多,团队类型时需要)
is_deleted = models.BooleanField(default=False) # 软删除标记
class Meta:
db_table = 'team'
verbose_name = '团队'
verbose_name_plural = '团队'
class User(models.Model):
role = models.ManyToManyField(role)
department =models.ManyToManyField(Department) # 归属部门
username = models.CharField(max_length=100) # 姓名移除unique=True允许软删除后重新注册同名用户
account = models.CharField(max_length=100) # 账号
password = models.CharField(max_length=100) # 密码
ethnicity = models.CharField(max_length=100) # 名族
card = models.CharField(max_length=100) # 身份证
mobilePhone = models.CharField(max_length=100) # 手机号
position = models.CharField(max_length=100) # 岗位
team = models.CharField(max_length=100) # 所属团队
Dateofjoining = models.DateField() # 入职时间
Confirmationtime = models.DateField(null=True, blank=True, default=None) # 转正时间
Practicingcertificatetime = models.DateField(null=True, blank=True, default=None) # 执业证时间
Dateofdeparture = models.DateField(null=True, blank=True, default=None) # 离职时间
AcademicResume = models.TextField() # 学业简历
academic = models.TextField() # 学历
contract = models.TextField() # 合同
ApplicationForm = models.TextField() # 入职申请表
salary = models.CharField(max_length=100,null=True, blank=True, default=None) # 工资
state = models.CharField(max_length=100) # 状态
token = models.TextField()
is_deleted = models.BooleanField(default=False) # 软删除标记
class Approval(models.Model):
title = models.CharField(max_length=100)
content = models.TextField() # 内容
times = models.DateField() # 提交时间
completeTiem = models.DateField(null=True, blank=True, default=None) # 完成时间
personincharge = models.CharField(max_length=100) # 负责人/审批部门
# 统一规则:
# - 纯数字字符串(如 "1", "2"= 部门ID该部门下所有人员都能看到审批
# - 非纯数字字符串(如 "张三"= 审批员用户名(只有该审批员能看到审批)
state = models.CharField(max_length=100) # 状态
type = models.CharField(max_length=100) # 类别
user_id = models.CharField(max_length=100) # 事件id
applicant = models.CharField(max_length=100, null=True, blank=True) # 申请人(提交人,用于投标登记、立项等)
rejection_reason = models.TextField(null=True, blank=True) # 不通过原因(审核不通过时填写)
is_deleted = models.BooleanField(default=False) # 软删除标记
class OperationLog(models.Model):
"""操作日志模型 - 记录高风险操作"""
operator = models.CharField(max_length=100) # 操作人用户名
operator_id = models.IntegerField(null=True, blank=True) # 操作人ID
operation_type = models.CharField(max_length=50) # 操作类型DELETE, CREATE, UPDATE, APPROVE等
module = models.CharField(max_length=50) # 模块User, Business, Finance等
action = models.CharField(max_length=200) # 操作描述:删除用户、创建立项等
target_type = models.CharField(max_length=100) # 目标类型User, ProjectRegistration等
target_id = models.CharField(max_length=100, null=True, blank=True) # 目标ID
target_name = models.CharField(max_length=200, null=True, blank=True) # 目标名称(如用户名、项目名等)
old_data = models.TextField(null=True, blank=True) # 操作前的数据JSON格式
new_data = models.TextField(null=True, blank=True) # 操作后的数据JSON格式
ip_address = models.CharField(max_length=50, null=True, blank=True) # IP地址
user_agent = models.CharField(max_length=500, null=True, blank=True) # 用户代理
request_path = models.CharField(max_length=500, null=True, blank=True) # 请求路径
remark = models.TextField(null=True, blank=True) # 备注
create_time = models.DateTimeField(auto_now_add=True) # 操作时间
class Meta:
db_table = 'operation_log'
ordering = ['-create_time']
verbose_name = '操作日志'
verbose_name_plural = '操作日志'