You've already forked opc-backend
开发了多角色登录与鉴权接口:实现了普通用户、企业和管理员的登录分流,并支持Token验证。
开发了权限控制接口:实现了通过数据库分配菜单权限节点,控制接口访问安全。 开发了实名认证中心:实现了个人身份证信息与企业营业执照的提交与审核接口。 开发了任务与协作大厅核心业务:实现了任务的发布、接单、状态流转以及专家邀约接口。 配置了全局环境变量与数据库引擎:集成了 PostgreSQL 数据库、Redis 缓存与 MinIO 对象存储。
This commit is contained in:
132
system/models.py
Normal file
132
system/models.py
Normal file
@@ -0,0 +1,132 @@
|
||||
import uuid
|
||||
from django.db import models
|
||||
|
||||
class NotificationType(models.TextChoices):
|
||||
SYSTEM = 'SYSTEM', '系统通知'
|
||||
CERTIFICATION = 'CERTIFICATION', '认证通知'
|
||||
TASK = 'TASK', '任务通知'
|
||||
RESERVATION = 'RESERVATION', '预约通知'
|
||||
|
||||
class SmsScene(models.TextChoices):
|
||||
REGISTER = 'REGISTER', '注册'
|
||||
LOGIN = 'LOGIN', '登录'
|
||||
RESET_PASSWORD = 'RESET_PASSWORD', '重置密码'
|
||||
|
||||
class AudienceChoices(models.TextChoices):
|
||||
ALL = 'ALL', '全平台'
|
||||
USER = 'USER', '用户端'
|
||||
ENTERPRISE = 'ENTERPRISE', '企业端'
|
||||
|
||||
class Announcement(models.Model):
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
title = models.CharField(max_length=256)
|
||||
content = models.TextField()
|
||||
cover_url = models.CharField(max_length=512, null=True, blank=True)
|
||||
publisher = models.ForeignKey('users.User', on_delete=models.CASCADE, related_name='published_announcements')
|
||||
target_audience = models.CharField(max_length=16, choices=AudienceChoices.choices, default=AudienceChoices.ALL, help_text='公告受众')
|
||||
is_published = models.BooleanField(default=False)
|
||||
published_at = models.DateTimeField(null=True, blank=True)
|
||||
is_deleted = models.BooleanField(default=False)
|
||||
is_recommended = models.BooleanField(default=False, help_text='推荐/置顶')
|
||||
recommend_priority = models.IntegerField(default=0, help_text='推荐优先级, 越大越靠前')
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
db_table = 'announcements'
|
||||
ordering = ['-is_recommended', '-recommend_priority', '-created_at']
|
||||
|
||||
class ModelToken(models.Model):
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
user = models.ForeignKey('users.User', on_delete=models.CASCADE, related_name='model_tokens')
|
||||
model_id = models.CharField(max_length=128)
|
||||
model_name = models.CharField(max_length=256, null=True, blank=True)
|
||||
token_value = models.TextField()
|
||||
expires_at = models.DateTimeField(null=True, blank=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
db_table = 'model_tokens'
|
||||
|
||||
class SmsVerification(models.Model):
|
||||
phone = models.CharField(max_length=20)
|
||||
scene = models.CharField(max_length=32, choices=SmsScene.choices)
|
||||
code = models.CharField(max_length=8)
|
||||
is_used = models.BooleanField(default=False)
|
||||
expired_at = models.DateTimeField()
|
||||
used_at = models.DateTimeField(null=True, blank=True)
|
||||
ip = models.GenericIPAddressField(null=True, blank=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
db_table = 'sms_verifications'
|
||||
|
||||
class AuditLog(models.Model):
|
||||
user = models.ForeignKey('users.User', on_delete=models.SET_NULL, null=True, blank=True, related_name='audit_logs')
|
||||
action = models.CharField(max_length=128)
|
||||
resource = models.CharField(max_length=128, null=True, blank=True)
|
||||
resource_id = models.CharField(max_length=128, null=True, blank=True)
|
||||
detail = models.JSONField(default=dict)
|
||||
ip = models.GenericIPAddressField(null=True, blank=True)
|
||||
user_agent = models.TextField(null=True, blank=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
db_table = 'audit_logs'
|
||||
|
||||
class Notification(models.Model):
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
user = models.ForeignKey('users.User', on_delete=models.CASCADE, related_name='notifications')
|
||||
type = models.CharField(max_length=32, choices=NotificationType.choices)
|
||||
title = models.CharField(max_length=256)
|
||||
content = models.TextField()
|
||||
related_id = models.CharField(max_length=128, null=True, blank=True)
|
||||
is_read = models.BooleanField(default=False)
|
||||
is_deleted = models.BooleanField(default=False)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
db_table = 'notifications'
|
||||
|
||||
class SystemConfig(models.Model):
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
config_key = models.CharField(max_length=128, unique=True)
|
||||
config_value = models.JSONField()
|
||||
description = models.TextField(null=True, blank=True)
|
||||
updated_by = models.ForeignKey('users.User', on_delete=models.SET_NULL, null=True, blank=True, related_name='updated_configs')
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
db_table = 'system_configs'
|
||||
|
||||
class AiModel(models.Model):
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
name = models.CharField(max_length=128)
|
||||
provider = models.CharField(max_length=128)
|
||||
description = models.TextField(null=True, blank=True)
|
||||
icon = models.CharField(max_length=64, null=True, blank=True)
|
||||
price_per_token = models.DecimalField(max_digits=10, decimal_places=6, default=0)
|
||||
is_active = models.BooleanField(default=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
db_table = 'ai_models'
|
||||
|
||||
|
||||
class Skill(models.Model):
|
||||
"""Admin-managed skill/expertise domain tags used across the platform."""
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
name = models.CharField(max_length=64, unique=True)
|
||||
category = models.CharField(max_length=64, null=True, blank=True, help_text='分类: 技术/设计/内容/数据 等')
|
||||
sort_order = models.IntegerField(default=0, help_text='排序权重, 越小越靠前')
|
||||
is_active = models.BooleanField(default=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
db_table = 'skills'
|
||||
ordering = ['sort_order', 'name']
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
Reference in New Issue
Block a user