import hashlib
import os

from . import ModelMixin
from . import db
from utils import timestamp
from utils import log
from utils import sh1hexdigest 


class MessageCopy(db.Model, ModelMixin):
    __tablename__ = 'messageCopys'
    Cid = db.Column(db.Integer, primary_key=True)   # 转发编号
    # Ccontent = db.Column(db.String(150))         # 转发内容
    # Cdatetime = db.Column(db.Integer)           # 转发时间

    # 外键
    # u_id = db.Column(db.Integer, db.ForeignKey('users.Uid'))     # 用户编号
    m_follow_id = db.Column(db.Integer, db.ForeignKey('messages.Mid'))   # 消息编号
    m_fans_id = db.Column(db.Integer, db.ForeignKey('messages.Mid'))   # 消息编号

    # 定义一个关系
    # 自动关联 不用手动查询就有数据
    # user = db.relationship('User', backref='messageCopy',  foreign_keys='MessageCopy.u_id')
    m_follow = db.relationship('Message', backref='messagCopyFollow',  foreign_keys='MessageCopy.m_follow_id')
    m_fans = db.relationship('Message', backref='messagCopyFans',  foreign_keys='MessageCopy.m_fans_id')
    

    def __init__(self):
        super(MessageCopy, self).__init__()
        # self.Ccontent = form.get('content', '')
        # self.Cdatetime = timestamp()
