#!/usr/bin/env python
# -*- coding: utf_8 -*-

import uuid
from datetime import datetime
from pony.orm import PrimaryKey, Required, Optional, Set, LongStr, Json
from app import config
from . import fullStackDB

db = fullStackDB.db

class Netdisc(db.Entity):
    _table_ = "{}".format(config['TABLE_PREFIX']) + "netdisc"
    id = PrimaryKey(int, auto=True)
    uuid = Required(uuid.UUID, unique=True, default=uuid.uuid1, index=True)
    name = Required(str, max_len=200) # 文件名
    size = Required(int, default=0) # 文件大小
    file_type = Required(str) # 文件类型
    is_dir = Required(bool, default=False)  # 是否是目录
    parent_dir = Required(str, default='/') # 上级目录
    real_path = Required(str) # 真实路径
    create_at = Required(datetime, default=datetime.now)
    create_by = Required("User", reverse='netdisc_creator') # NetDisc与User一对一关系
    update_at = Required(datetime, default=datetime.now)
    update_by = Required("User", reverse='netdisc_updater') # NetDisc与User一对一关系
    delete_at = Optional(datetime)
    delete_by = Optional("User", reverse='netdisc_deleter') # NetDisc与User一对一关系
    is_delete = Required(bool, default=False)
    sort = Optional(int, size=32, default=0)
    remarks = Optional(str, max_len=255, default="", nullable=True)