from django.db import models

# Create your models here.
from utils.models import BaseModel


class House(BaseModel):
    '''房屋信息'''
    user = models.ForeignKey('users.User', on_delete=models.CASCADE, verbose_name='房屋用户')
    area = models.ForeignKey('address.Area', on_delete=models.SET_NULL, null=True, verbose_name='房屋地区')
    title = models.CharField(max_length=64, null=False, verbose_name='房屋标题')
    price = models.IntegerField(default=0, verbose_name='房屋单价')  # 单价分
    address = models.CharField(max_length=512, default='', verbose_name='房屋地址')
    room_count = models.SmallIntegerField(default=1, verbose_name='房间数目')
    acreage = models.IntegerField(default=0, verbose_name='房屋面积')
    unit = models.CharField(max_length=32, default='', verbose_name='房屋单元')  # 如几室几厅
    capacity = models.SmallIntegerField(default=1, verbose_name='房屋容纳')  # 房屋容纳的人数
    beds = models.CharField(max_length=64, default='', verbose_name='房屋床铺配置')
    deposit = models.IntegerField(default=0, verbose_name='房屋押金')
    min_days = models.SmallIntegerField(default=1, verbose_name='最少入住天数')
    max_days = models.SmallIntegerField(default=0, verbose_name='最大入住天数')  # 0表示不限制
    order_count = models.IntegerField(default=0, verbose_name='预计该房屋的订单数')
    index_image_url = models.CharField(max_length=500, default='', verbose_name='房屋主图片的路径')
    facilities = models.ManyToManyField('Facility')#配套设施

    class Meta:
        db_table = 'ih_house_info'
        verbose_name = '房屋信息'
        verbose_name_plural = verbose_name


class Facility(models.Model):
    '''房屋设施信息'''
    name = models.CharField(max_length=32, verbose_name='设施名称')

    class Meta:
        db_table = 'ih_facility_info'
        verbose_name = '设施信息'
        verbose_name_plural = verbose_name


class HouseImage(BaseModel):
    '''房屋图片'''
    house = models.ForeignKey(House, verbose_name='房屋信息', on_delete=models.CASCADE)
    url = models.CharField(max_length=256, null=False, verbose_name='房屋图片地址')

    class Meta:
        db_table = 'ih_house_image'
        verbose_name = '房屋图片'
        verbose_name_plural = verbose_name

[((152, 230), 'django.db.models.ForeignKey', 'models.ForeignKey', (['"""users.User"""'], {'on_delete': 'models.CASCADE', 'verbose_name': '"""房屋用户"""'}), "('users.User', on_delete=models.CASCADE, verbose_name='房屋用户')\n", (169, 230), False, 'from django.db import models\n'), ((243, 339), 'django.db.models.ForeignKey', 'models.ForeignKey', (['"""address.Area"""'], {'on_delete': 'models.SET_NULL', 'null': '(True)', 'verbose_name': '"""房屋地区"""'}), "('address.Area', on_delete=models.SET_NULL, null=True,\n    verbose_name='房屋地区')\n", (260, 339), False, 'from django.db import models\n'), ((349, 413), 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(64)', 'null': '(False)', 'verbose_name': '"""房屋标题"""'}), "(max_length=64, null=False, verbose_name='房屋标题')\n", (365, 413), False, 'from django.db import models\n'), ((427, 478), 'django.db.models.IntegerField', 'models.IntegerField', ([], {'default': '(0)', 'verbose_name': '"""房屋单价"""'}), "(default=0, verbose_name='房屋单价')\n", (446, 478), False, 'from django.db import models\n'), ((501, 566), 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(512)', 'default': '""""""', 'verbose_name': '"""房屋地址"""'}), "(max_length=512, default='', verbose_name='房屋地址')\n", (517, 566), False, 'from django.db import models\n'), ((585, 641), 'django.db.models.SmallIntegerField', 'models.SmallIntegerField', ([], {'default': '(1)', 'verbose_name': '"""房间数目"""'}), "(default=1, verbose_name='房间数目')\n", (609, 641), False, 'from django.db import models\n'), ((657, 708), 'django.db.models.IntegerField', 'models.IntegerField', ([], {'default': '(0)', 'verbose_name': '"""房屋面积"""'}), "(default=0, verbose_name='房屋面积')\n", (676, 708), False, 'from django.db import models\n'), ((721, 785), 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(32)', 'default': '""""""', 'verbose_name': '"""房屋单元"""'}), "(max_length=32, default='', verbose_name='房屋单元')\n", (737, 785), False, 'from django.db import models\n'), ((811, 867), 'django.db.models.SmallIntegerField', 'models.SmallIntegerField', ([], {'default': '(1)', 'verbose_name': '"""房屋容纳"""'}), "(default=1, verbose_name='房屋容纳')\n", (835, 867), False, 'from django.db import models\n'), ((891, 957), 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(64)', 'default': '""""""', 'verbose_name': '"""房屋床铺配置"""'}), "(max_length=64, default='', verbose_name='房屋床铺配置')\n", (907, 957), False, 'from django.db import models\n'), ((973, 1024), 'django.db.models.IntegerField', 'models.IntegerField', ([], {'default': '(0)', 'verbose_name': '"""房屋押金"""'}), "(default=0, verbose_name='房屋押金')\n", (992, 1024), False, 'from django.db import models\n'), ((1041, 1099), 'django.db.models.SmallIntegerField', 'models.SmallIntegerField', ([], {'default': '(1)', 'verbose_name': '"""最少入住天数"""'}), "(default=1, verbose_name='最少入住天数')\n", (1065, 1099), False, 'from django.db import models\n'), ((1116, 1174), 'django.db.models.SmallIntegerField', 'models.SmallIntegerField', ([], {'default': '(0)', 'verbose_name': '"""最大入住天数"""'}), "(default=0, verbose_name='最大入住天数')\n", (1140, 1174), False, 'from django.db import models\n'), ((1204, 1260), 'django.db.models.IntegerField', 'models.IntegerField', ([], {'default': '(0)', 'verbose_name': '"""预计该房屋的订单数"""'}), "(default=0, verbose_name='预计该房屋的订单数')\n", (1223, 1260), False, 'from django.db import models\n'), ((1284, 1353), 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(500)', 'default': '""""""', 'verbose_name': '"""房屋主图片的路径"""'}), "(max_length=500, default='', verbose_name='房屋主图片的路径')\n", (1300, 1353), False, 'from django.db import models\n'), ((1372, 1406), 'django.db.models.ManyToManyField', 'models.ManyToManyField', (['"""Facility"""'], {}), "('Facility')\n", (1394, 1406), False, 'from django.db import models\n'), ((1607, 1659), 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(32)', 'verbose_name': '"""设施名称"""'}), "(max_length=32, verbose_name='设施名称')\n", (1623, 1659), False, 'from django.db import models\n'), ((1856, 1927), 'django.db.models.ForeignKey', 'models.ForeignKey', (['House'], {'verbose_name': '"""房屋信息"""', 'on_delete': 'models.CASCADE'}), "(House, verbose_name='房屋信息', on_delete=models.CASCADE)\n", (1873, 1927), False, 'from django.db import models\n'), ((1939, 2006), 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(256)', 'null': '(False)', 'verbose_name': '"""房屋图片地址"""'}), "(max_length=256, null=False, verbose_name='房屋图片地址')\n", (1955, 2006), False, 'from django.db import models\n')]