# 模型
from datetime import datetime

from sqlalchemy.dialects.mysql import LONGTEXT

from .exts import db


# 模型
class User(db.Model):
    # 表名
    __tablename__ = "tb_user"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    role = db.Column(db.Integer, autoincrement=True)
    username = db.Column(db.String(80), unique=True, nullable=False)
    password = db.Column(db.String(128), nullable=False)


class JobPosition(db.Model):
    __tablename__ = 'tb_companies'
    id = db.Column(db.BigInteger, primary_key=True, autoincrement=True, comment='主键ID')
    company_name = db.Column(db.String(50))
    industry = db.Column(db.String(200))
    registered_capital = db.Column(db.String(200))
    establishment_date = db.Column(db.String(200))
    registration_addres = db.Column(db.String(200))
    def to_dict(self):
        """将模型转换为字典"""
        return {
            'id': self.id,
            'companyName': self.company_name,
            'industry': self.industry,
            'registeredCapital': self.registered_capital,
            'establishmentDate': self.establishment_date,
            'registrationAddres': self.registration_addres,
        }


class Config(db.Model):
    # 表名
    __tablename__ = "tb_sysconfig"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)  # 主键
    name = db.Column(db.String(50), nullable=False)
    key = db.Column(db.String(50), unique=True, nullable=False)  # 配置键
    value = db.Column(db.String(255), nullable=False)  # 配置值
    description = db.Column(db.String(255))  # 描述
