from sqlalchemy import Column, Integer, String, Text, DateTime, Index
from core.storage.db import Base
from sqlalchemy_serializer import SerializerMixin

from libs import functions


class Account(Base, SerializerMixin):
    """账户表"""
    __tablename__ = "account"

    id = Column(Integer, primary_key=True, index=True)
    name = Column(String(255), index=True, comment="账户名称")
    unique_tag = Column(String(100), unique=True, comment="唯一标记")
    beneficiary = Column(String(100), comment="受益人")
    remark = Column(String(255), comment="描述")
    uuid = Column(String(60), default=functions.uuid(), comment="uuid")
    config_key = Column(String(150), comment="配置key,和api接口约定好的标识")
    income = Column(Text, comment="入账")
    output = Column(Text, comment="出账")
    operator = Column(String(255), comment="操作员（每笔转账都要记录一下）")
    operator_id = Column(Integer, comment="操作员id（可能设计到改了名字，记id比较好）")
    create_time = Column(DateTime, comment="创建时间")

    __table_args__ = {'comment': '财务系统-账号管理'}
