# -*- coding: utf-8 -*-

from django.db import models
from django.utils.translation import ugettext_lazy as _
from django_models_ext import BaseModelMixin, upload_file_url, upload_path
from shortuuidfield import ShortUUIDField


class MchInfoEncryptLogInfo(BaseModelMixin):
    plaintext = models.CharField(_(u'plaintext'), max_length=64, blank=True, null=True, help_text=u'待加密字符串', db_index=True, unique=True)

    alg = models.CharField(_(u'alg'), max_length=16, blank=True, null=True, help_text=u'加密算法')
    ciphertext = models.CharField(_(u'ciphertext'), max_length=64, blank=True, null=True, help_text=u'加密字符串')

    brand_pk = models.IntegerField(_(u'brand_pk'), default=0, help_text=u'品牌PK', db_index=True)
    model_pk = models.IntegerField(_(u'model_pk'), default=0, help_text=u'型号PK', db_index=True)
    distributor_pk = models.IntegerField(_(u'distributor_pk'), default=0, help_text=u'经销商PK', db_index=True)

    sn = models.CharField(_(u'sn'), max_length=32, blank=True, null=True, help_text=u'序列号', db_index=True)

    operator_id = models.CharField(_(u'operator_id'), max_length=32, blank=True, null=True, help_text=u'操作员唯一标识', db_index=True)

    class Meta:
        verbose_name = _(u'mchinfoencryptloginfo')
        verbose_name_plural = _(u'mchinfoencryptloginfo')

    def __unicode__(self):
        return unicode(self.pk)


class MchLogInfo(BaseModelMixin):
    log_id = ShortUUIDField(_(u'log_id'), max_length=32, help_text=u'日志唯一标识', db_index=True)
    log_file = models.FileField(_(u'log_file'), upload_to=upload_path, blank=True, null=True, help_text=u'日志文件')

    operator_id = models.CharField(_(u'operator_id'), max_length=32, blank=True, null=True, help_text=u'操作员唯一标识', db_index=True)

    app_version = models.IntegerField(_(u'app_version'), default=0, help_text=u'APP 版本号', db_index=True)

    class Meta:
        verbose_name = _(u'mchloginfo')
        verbose_name_plural = _(u'mchloginfo')

    def __unicode__(self):
        return unicode(self.pk)
