forked from xcloudlive/flask-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.py
83 lines (68 loc) · 3.09 KB
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# -- coding:UTF-8 --
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import os
from flask_cors import CORS
app = Flask(__name__, static_folder='static',)
# Cross Origin Resource Sharing
CORS(app, expose_headers=["x-suggested-filename"])
app.config['SECRET_KEY'] = 'thisissecret'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
basedir = os.path.abspath(os.path.dirname(__file__))
# print('base path is {}'.format(basedir))
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + \
os.path.join(basedir, 'bbwq.sqlite')
db = SQLAlchemy(app)
# 系统用户
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
public_id = db.Column(db.String(50), unique=True)
name = db.Column(db.String(50)) # 登陆用的用户名
password = db.Column(db.String(20)) # 密码
mobile = db.Column(db.String(20)) # 手机号码
email = db.Column(db.String(50)) # 电子邮件地址
rank = db.Column(db.Integer) # 级别:-25K ~ 9D
lefttimes = db.Column(db.Integer) # 用户使用对局室的剩余时间
isadmin = db.Column(db.Boolean) # 系统管理员
avatar = db.Column(db.String(200)) # 用户头像照片
create_date = db.Column(db.DateTime)
win = db.Column(db.Integer) # 胜利局数
fail = db.Column(db.Integer) # 失败局数
background = db.Column(db.String(50)) # 棋盘背景色
"""游戏对局室
Returns:
[type] -- [description]
"""
class Game(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50)) # 名称
user_id = db.Column(db.Integer) # 创建人
total_time = db.Column(db.Integer) # 对局时长,单位为秒
comment = db.Column(db.String(50)) # 备注
blackone_id = db.Column(db.String(50)) # 黑选手1
blacktwo_id = db.Column(db.String(50)) # 黑选手2
whiteone_id = db.Column(db.String(50)) # 白选手1
whitetwo_id = db.Column(db.String(50)) # 白选手2
create_date = db.Column(db.DateTime) # 创建时间
start_time = db.Column(db.DateTime) # 预定时间
public = db.Column(db.Boolean) # 是否公开
password = db.Column(db.String(50)) # 如果不公开,设置密码
status = db.Column(db.String(50)) # 对局状态:未开始,进行中,已结束
"""棋谱信息
Returns:
[type] -- [description]
"""
class Kifu(db.Model):
id = db.Column(db.Integer, primary_key=True)
create_date = db.Column(db.DateTime)
user_id = db.Column(db.Integer)
kifu_data = db.Column(db.String(1500))
black_info = db.Column(db.String(50))
white_info = db.Column(db.String(50))
result = db.Column(db.String(50))
is_share = db.Column(db.Boolean, default=False)
is_analyse = db.Column(db.Boolean, default=False) # 是否ai分析完毕
analyse_data = db.Column(db.String(2500)) # ai 分析的棋谱结果
comment = db.Column(db.String(2500)) # 备注信息
drops_data = db.Column(db.String(500)) # 统计最高掉胜率的五步棋
moves = db.Column(db.Integer) # 棋谱的手数