class Trade(_.Model): __tablename__ = 'trade' trade_id = _.Column(_.Integer, primary_key=True) # 交易编号 trade_datetime = _.Column(_.String(10), nullable=False) # 交易日期 trade_time = _.Column(_.String(10), nullable=False) # 交易时间 trade_stock_id = _.Column(_.String(10), nullable=False) # 股票代码 trade_stock_name = _.Column(_.String(10), nullable=False) # 股票名称 trade_type = _.Column(_.Integer, nullable=False) # 1买入,2卖出 # 交易类型 trade_amount = _.Column(_.Integer, nullable=False) # 交易手数 trade_price = _.Column(_.String(10), nullable=False) # 交易价格 trade_brokerage = _.Column(_.String(10), nullable=False) # 手续费 trade_totalvalue = _.Column(_.String(20), nullable=False) # 交易总费用 def __init__(self, trade_datetime, trade_time, trade_stock_id, trade_stock_name, trade_type, trade_amount, trade_price, trade_brokerage, trade_totalvalue): self.trade_datetime = trade_datetime self.trade_time = trade_time self.trade_stock_id = trade_stock_id self.trade_stock_name = trade_stock_name self.trade_type = trade_type self.trade_amount = trade_amount self.trade_price = trade_price self.trade_brokerage = trade_brokerage self.trade_totalvalue = trade_totalvalue def tolist(self): return [ self.trade_datetime, self.trade_time, self.trade_stock_id, self.trade_stock_name, self.trade_type, self.trade_amount, self.trade_price, self.trade_brokerage, self.trade_totalvalue ]
class Settings(gdb.Model): __tablename__ = 'settings' settings_id = gdb.Column(gdb.Integer, primary_key=True) settings_key = gdb.Column(gdb.String(50)) settings_value = gdb.Column(gdb.String(1000)) def __init__(self, settings_key, settings_value): self.settings_key = settings_key self.settings_value = settings_value def todict(self): return { "settings_id": self.settings_id, "settings_key": self.settings_key, "settings_value": self.settings_value }
class ProblemSet(gdb.Model): __tablename__ = 'problemset' problemset_id = gdb.Column(gdb.Integer, primary_key=True) problemset_title = gdb.Column(gdb.String(100)) problemset_desp = gdb.Column(gdb.String(300)) problemset_count = gdb.Column(gdb.Integer) problemset_token = gdb.Column(gdb.String(260)) problemset_answercount = gdb.Column(gdb.Integer) problemset_timeperproblem = gdb.Column(gdb.Integer) def __init__(self, problemset_title, problemset_desp, problemset_count, problemset_token, problemset_answercount, problemset_timeperproblem): self.problemset_title = problemset_title self.problemset_desp = problemset_desp self.problemset_count = problemset_count self.problemset_token = problemset_token self.problemset_answercount = problemset_answercount self.problemset_timeperproblem = problemset_timeperproblem def todict(self): return {"problemset_id": self.problemset_id, "problemset_title": self.problemset_title, "problemset_desp": self.problemset_desp, "problemset_count": self.problemset_count, "problemset_token": self.problemset_token, "problemset_answercount": self.problemset_answercount, "problemset_timeperproblem": self.problemset_timeperproblem}
class NoteBook(gdb.Model): __tablename__ = 'notebook' notebook_id = gdb.Column(gdb.Integer, primary_key=True) user_id = gdb.Column(gdb.Integer) problemset_id = gdb.Column(gdb.Integer) problem_id = gdb.Column(gdb.Integer) def __init__(self, user_id, problemset_id, problem_id): self.user_id = user_id self.problemset_id = problemset_id self.problem_id = problem_id def todict(self): return { "notebook_id": self.notebook_id, "user_id": self.user_id, "problemset_id": self.problemset_id, "problem_id": self.problem_id }
class Admin(gdb.Model): __tablename__ = 'admin' admin_id = gdb.Column(gdb.Integer, primary_key=True) admin_username = gdb.Column(gdb.String(30)) admin_password = gdb.Column(gdb.String(260)) admin_token = gdb.Column(gdb.String(260)) admin_ip = gdb.Column(gdb.String(30)) admin_logintime = gdb.Column(gdb.String(30)) def __init__(self, admin_username, admin_password, admin_token, admin_ip, admin_logintime): self.admin_username = admin_username self.admin_password = admin_password self.admin_token = admin_token self.admin_ip = admin_ip self.admin_logintime = admin_logintime def todict(self): return { "admin_id": self.admin_id, "admin_username": self.admin_username, "admin_password": self.admin_password, "admin_token": self.admin_token, "admin_ip": self.admin_ip, "admin_logintime": self.admin_logintime }
class User(gdb.Model): __tablename__ = 'user' user_id = gdb.Column(gdb.Integer, primary_key=True) user_username = gdb.Column(gdb.String(30)) user_password = gdb.Column(gdb.String(260)) user_token = gdb.Column(gdb.String(260)) user_ip = gdb.Column(gdb.String(30)) user_logintime = gdb.Column(gdb.String(30)) user_problemsetid = gdb.Column(gdb.Integer) user_problemstream = gdb.Column(gdb.String(500)) user_problemseat = gdb.Column(gdb.Integer) user_dotimestamp = gdb.Column(gdb.String(100)) def __init__(self, user_username, user_password, user_token, user_ip, user_logintime, user_problemsetid, user_problemstream, user_problemseat, user_dotimestamp): self.user_username = user_username self.user_password = user_password self.user_token = user_token self.user_ip = user_ip self.user_logintime = user_logintime self.user_problemsetid = user_problemsetid self.user_problemstream = user_problemstream self.user_problemseat = user_problemseat self.user_dotimestamp = user_dotimestamp def todict(self): return { "user_id": self.user_id, "user_username": self.user_username, "user_password": self.user_password, "user_token": self.user_token, "user_ip": self.user_ip, "user_logintime": self.user_logintime, "user_problemsetid": self.user_problemsetid, "user_problemstream": self.user_problemstream, "user_problemseat": self.user_problemseat, "user_dotimestamp": self.user_dotimestamp }
class Score(gdb.Model): __tablename__ = 'score' score_id = gdb.Column(gdb.Integer, primary_key=True) user_id = gdb.Column(gdb.Integer) problemset_id = gdb.Column(gdb.Integer) score_right = gdb.Column(gdb.Integer) score_wrong = gdb.Column(gdb.Integer) score_timestart = gdb.Column(gdb.Integer) score_timeend = gdb.Column(gdb.Integer) score_problemcount = gdb.Column(gdb.Integer) problemset_timeperproblem = gdb.Column(gdb.Integer) def __init__(self, user_id, problemset_id, score_right, score_wrong, score_timestart, score_timeend, score_problemcount, problemset_timeperproblem): self.user_id = user_id self.problemset_id = problemset_id self.score_right = score_right self.score_wrong = score_wrong self.score_timestart = score_timestart self.score_timeend = score_timeend self.score_problemcount = score_problemcount self.problemset_timeperproblem = problemset_timeperproblem def todict(self): return { "score_id": self.score_id, "user_id": self.user_id, "problemset_id": self.problemset_id, "score_right": self.score_right, "score_wrong": self.score_wrong, "score_timestart": self.score_timestart, "score_timeend": self.score_timeend, "score_problemcount": self.score_problemcount, "problemset_timeperproblem": self.problemset_timeperproblem }
class Problem(gdb.Model): __tablename__ = 'problem' problem_id = gdb.Column(gdb.Integer, primary_key=True) problemset_id = gdb.Column(gdb.Integer) problem_desp = gdb.Column(gdb.String(1000)) problem_picpath = gdb.Column(gdb.String(300)) problem_choiceA = gdb.Column(gdb.String(200)) problem_choiceB = gdb.Column(gdb.String(200)) problem_choiceC = gdb.Column(gdb.String(200)) problem_choiceD = gdb.Column(gdb.String(200)) problem_answer = gdb.Column(gdb.String(10)) def __init__(self, problemset_id, problem_desp, problem_picpath, problem_choiceA, problem_choiceB, problem_choiceC, problem_choiceD, problem_answer): self.problemset_id = problemset_id self.problem_desp = problem_desp self.problem_picpath = problem_picpath self.problem_choiceA = problem_choiceA self.problem_choiceB = problem_choiceB self.problem_choiceC = problem_choiceC self.problem_choiceD = problem_choiceD self.problem_answer = problem_answer def todict(self): return { "problem_id": self.problem_id, "problemset_id": self.problemset_id, "problem_desp": self.problem_desp, "problem_picpath": self.problem_picpath, "problem_choiceA": self.problem_choiceA, "problem_choiceB": self.problem_choiceB, "problem_choiceC": self.problem_choiceC, "problem_choiceD": self.problem_choiceD, "problem_answer": self.problem_answer }