Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoQuote committed Feb 26, 2025
1 parent 5edd64a commit da69d20
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
48 changes: 36 additions & 12 deletions sql/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ class ResourceGroup(models.Model):
ding_webhook = models.CharField("钉钉webhook地址", max_length=255, blank=True)
feishu_webhook = models.CharField("飞书webhook地址", max_length=255, blank=True)
qywx_webhook = models.CharField("企业微信webhook地址", max_length=255, blank=True)
is_deleted = models.IntegerField("是否删除", choices=((0, "否"), (1, "是")), default=0)
is_deleted = models.IntegerField(
"是否删除", choices=((0, "否"), (1, "是")), default=0
)
create_time = models.DateTimeField(auto_now_add=True)
sys_time = models.DateTimeField(auto_now=True)

Expand All @@ -66,7 +68,9 @@ class Users(AbstractUser):
wx_user_id = models.CharField("企业微信UserID", max_length=64, blank=True)
feishu_open_id = models.CharField("飞书OpenID", max_length=64, blank=True)
failed_login_count = models.IntegerField("失败计数", default=0)
last_login_failed_at = models.DateTimeField("上次失败登录时间", blank=True, null=True)
last_login_failed_at = models.DateTimeField(
"上次失败登录时间", blank=True, null=True
)
resource_group = models.ManyToManyField(
ResourceGroup, verbose_name="资源组", blank=True
)
Expand Down Expand Up @@ -245,7 +249,9 @@ class Instance(models.Model, PasswordMixin):
resource_group = models.ManyToManyField(
ResourceGroup, verbose_name="资源组", blank=True
)
instance_tag = models.ManyToManyField(InstanceTag, verbose_name="实例标签", blank=True)
instance_tag = models.ManyToManyField(
InstanceTag, verbose_name="实例标签", blank=True
)
tunnel = models.ForeignKey(
Tunnel,
verbose_name="连接隧道",
Expand Down Expand Up @@ -341,7 +347,9 @@ class SqlWorkflow(models.Model, WorkflowAuditMixin):
run_date_end = models.DateTimeField("可执行结束时间", null=True, blank=True)
create_time = models.DateTimeField("创建时间", auto_now_add=True)
finish_time = models.DateTimeField("结束时间", null=True, blank=True)
is_manual = models.IntegerField("是否原生执行", choices=((0, "否"), (1, "是")), default=0)
is_manual = models.IntegerField(
"是否原生执行", choices=((0, "否"), (1, "是")), default=0
)

def __str__(self):
return self.workflow_name
Expand Down Expand Up @@ -385,7 +393,9 @@ class WorkflowAudit(models.Model):
workflow_id = models.BigIntegerField("关联业务id")
workflow_type = models.IntegerField("申请类型", choices=WorkflowType.choices)
workflow_title = models.CharField("申请标题", max_length=50)
workflow_remark = models.CharField("申请备注", default="", max_length=140, blank=True)
workflow_remark = models.CharField(
"申请备注", default="", max_length=140, blank=True
)
audit_auth_groups = models.CharField("审批权限组列表", max_length=255)
current_audit = models.CharField("当前审批权限组", max_length=20)
next_audit = models.CharField("下级审批权限组", max_length=20)
Expand Down Expand Up @@ -472,7 +482,9 @@ class WorkflowLog(models.Model):

id = models.AutoField(primary_key=True)
audit_id = models.IntegerField("工单审批id", db_index=True)
operation_type = models.SmallIntegerField("操作类型", choices=WorkflowAction.choices)
operation_type = models.SmallIntegerField(
"操作类型", choices=WorkflowAction.choices
)
# operation_type_desc 字段实际无意义
operation_type_desc = models.CharField("操作类型描述", max_length=10)
operation_info = models.CharField("操作信息", max_length=1000)
Expand Down Expand Up @@ -642,12 +654,16 @@ class DataMaskingColumns(models.Model):
choices=rule_type_choices,
help_text="三段式通用脱敏规则:根据字段长度自动分成三份,中间段脱敏。",
)
active = models.BooleanField("激活状态", choices=((False, "未激活"), (True, "激活")))
active = models.BooleanField(
"激活状态", choices=((False, "未激活"), (True, "激活"))
)
instance = models.ForeignKey(Instance, on_delete=models.CASCADE)
table_schema = models.CharField("字段所在库名", max_length=64)
table_name = models.CharField("字段所在表名", max_length=64)
column_name = models.CharField("字段名", max_length=64)
column_comment = models.CharField("字段描述", max_length=1024, default="", blank=True)
column_comment = models.CharField(
"字段描述", max_length=1024, default="", blank=True
)
create_time = models.DateTimeField(auto_now_add=True)
sys_time = models.DateTimeField(auto_now=True)

Expand Down Expand Up @@ -686,8 +702,12 @@ class InstanceAccount(models.Model):

instance = models.ForeignKey(Instance, on_delete=models.CASCADE)
user = fields.EncryptedCharField(verbose_name="账号", max_length=128)
host = models.CharField(verbose_name="主机", max_length=64) # mysql数据库存储主机信息
db_name = models.CharField(verbose_name="数据库名称", max_length=128) # mongo数据库存储数据库名称
host = models.CharField(
verbose_name="主机", max_length=64
) # mysql数据库存储主机信息
db_name = models.CharField(
verbose_name="数据库名称", max_length=128
) # mongo数据库存储数据库名称
password = fields.EncryptedCharField(
verbose_name="密码", max_length=128, default="", blank=True
)
Expand All @@ -710,7 +730,9 @@ class InstanceDatabase(models.Model):
instance = models.ForeignKey(Instance, on_delete=models.CASCADE)
db_name = models.CharField("数据库名", max_length=128)
owner = models.CharField("负责人", max_length=50, default="", blank=True)
owner_display = models.CharField("负责人中文名", max_length=50, default="", blank=True)
owner_display = models.CharField(
"负责人中文名", max_length=50, default="", blank=True
)
remark = models.CharField("备注", max_length=255, default="", blank=True)
sys_time = models.DateTimeField("系统修改时间", auto_now=True)

Expand Down Expand Up @@ -803,7 +825,9 @@ class ArchiveConfig(models.Model, WorkflowAuditMixin):
)
state = models.BooleanField("是否启用归档", default=True)
user_name = models.CharField("申请人", max_length=30, blank=True, default="")
user_display = models.CharField("申请人中文名", max_length=50, blank=True, default="")
user_display = models.CharField(
"申请人中文名", max_length=50, blank=True, default=""
)
create_time = models.DateTimeField("创建时间", auto_now_add=True)
last_archive_time = models.DateTimeField("最近归档时间", blank=True, null=True)
sys_time = models.DateTimeField("系统时间修改", auto_now=True)
Expand Down
1 change: 1 addition & 0 deletions sql/plugins/password.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
包括名字, 类型, 等等. 通过这些信息, 插件可以获取数据库的用户名和密码
"""

import time
import requests

Expand Down

0 comments on commit da69d20

Please sign in to comment.