You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.6 KiB
39 lines
1.6 KiB
from tortoise import fields, models
|
|
from tortoise.indexes import Index
|
|
|
|
|
|
class Log(models.Model):
|
|
id = fields.UUIDField(pk=True)
|
|
kind = fields.CharField(max_length=100, description='类型')
|
|
user_id = fields.UUIDField(null=True)
|
|
users = fields.CharField(null=True, max_length=255)
|
|
comment = fields.TextField(null=True)
|
|
cabinet_id = fields.UUIDField(null=True, description='终端ID')
|
|
|
|
created_at = fields.DatetimeField(auto_now_add=True)
|
|
updated_at = fields.DatetimeField(auto_now=True)
|
|
|
|
class Meta:
|
|
table = 'logs'
|
|
table_description = '日志表'
|
|
|
|
@classmethod
|
|
async def write(cls, kind: str, kwarg):
|
|
await Log.create(kind=kind, **kwarg)
|
|
|
|
|
|
# class EnvironmentLogs(models.Model):
|
|
# id = fields.UUIDField(pk=True)
|
|
# cabinet = fields.ForeignKeyField('rms.Cabinet', to_field='id', related_name='cabinet')
|
|
# temperature_type = fields.SmallIntField(description='0:无控温1:整机控温2:左右空控温')
|
|
# left_temperature = fields.DecimalField(max_digits=10, decimal_places=1,null=True, description='值')
|
|
# right_temperature = fields.DecimalField(max_digits=10,null=True, decimal_places=1, description='值')
|
|
# voc = fields.DecimalField(max_digits=10, decimal_places=1,null=True, description='值')
|
|
# humidity = fields.DecimalField(max_digits=10, decimal_places=1,null=True, description='值')
|
|
# created_at = fields.DatetimeField(auto_now_add=True)
|
|
# updated_at = fields.DatetimeField(auto_now=True)
|
|
|
|
# class Meta:
|
|
# table = 'environment_logs'
|
|
# table_description = '环境日志表'
|