from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, TIMESTAMP, text

from ....common.sqlSession import to_dict

Base = declarative_base()
Base.to_dict = to_dict


class CreateDetail(Base):
    __tablename__ = 'create_data_detail'
    create_data_detail_id = Column(String(120), primary_key=True, comment='基础信息的id')
    team_name = Column(String(100), unique=True, comment='组名（项目名）')
    file_name = Column(String(100), unique=True, comment='文件夹名称')
    module_name = Column(String(100), unique=True, comment='模块名称')
    class_name = Column(String(120), unique=True, comment='类名称')
    method_name = Column(String(120), unique=True, comment='方法名称')
    method_function_detail = Column(String(5000), unique=True, comment='方法简单说明')
    method_detail = Column(String(5000), unique=True, comment='方法描述')
    creator = Column(String(100), unique=True, comment='责任人')
    status = Column(Integer, unique=True, comment='状态:0：未审核；1：创建失败')
    del_flag = Column(Integer, unique=True, comment='0：未删除；1：已删除')
    created_time = Column(TIMESTAMP, server_default=text('CURRENT_TIMESTAMP'), comment='创建时间')
    modified_time = Column(TIMESTAMP, server_default=text('CURRENT_TIMESTAMP'),
                           server_onupdate=text('CURRENT_TIMESTAMP'), comment='更新时间')

    def __repr__(self):
        return '<create_data_detail_id %r>' % self.create_data_detail_id
