forked from whusnoopy/renrenBackup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
137 lines (109 loc) · 3.54 KB
/
models.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# coding: utf8
from peewee import SqliteDatabase, Model, BooleanField, IntegerField, DateTimeField, CharField
from playhouse.shortcuts import model_to_dict
from config import config
database = SqliteDatabase(config.DATABASE)
class BaseModel(Model):
class Meta:
database = database
@classmethod
def create_or_update(cls, data):
ex_data = cls.get_or_none(**data)
if ex_data:
ex_data = model_to_dict(ex_data)
ex_data.update(data)
else:
ex_data = data
cls.insert(**ex_data).on_conflict_replace().execute()
return cls.get_or_none(**ex_data)
class FetchedUser(BaseModel):
uid = IntegerField(unique=True, primary_key=True)
name = CharField()
headPic = CharField()
status = IntegerField()
gossip = IntegerField()
album = IntegerField()
photo = IntegerField()
blog = IntegerField()
class User(BaseModel):
uid = IntegerField(unique=True, primary_key=True)
name = CharField()
headPic = CharField()
class Comment(BaseModel):
id = IntegerField(unique=True, primary_key=True)
t = DateTimeField(index=True)
entry_id = IntegerField(index=True)
entry_type = CharField(index=True)
authorId = IntegerField()
authorName = CharField()
content = CharField()
class Like(BaseModel):
entry_id = IntegerField(index=True)
entry_type = CharField()
uid = IntegerField()
class Meta:
indexes = (
(('entry_id', 'uid'), True),
)
class Status(BaseModel):
id = IntegerField(unique=True, primary_key=True)
uid = IntegerField(index=True)
t = DateTimeField(index=True)
content = CharField(default="")
like = IntegerField(default=0)
repeat = IntegerField(default=0)
comment = IntegerField(default=0)
rootContent = CharField(default="")
rootUid = IntegerField(default=0)
rootUname = CharField(default="")
location = CharField(default="")
locationUrl = CharField(default="")
class Gossip(BaseModel):
id = IntegerField(unique=True, primary_key=True)
uid = IntegerField(index=True)
t = DateTimeField(index=True)
guestId = IntegerField(index=True)
guestName = CharField()
headPic = CharField()
attachSnap = CharField()
attachPic = CharField()
whisper = BooleanField()
wap = BooleanField()
gift = CharField()
content = CharField()
class Blog(BaseModel):
id = IntegerField(unique=True, primary_key=True)
uid = IntegerField(index=True)
t = DateTimeField(index=True)
category = CharField()
title = CharField()
summary = CharField()
content = CharField()
comment = IntegerField()
share = IntegerField()
like = IntegerField()
read = IntegerField()
class Album(BaseModel):
id = IntegerField(unique=True, primary_key=True)
uid = IntegerField(index=True)
name = CharField()
desc = CharField()
cover = CharField()
count = IntegerField()
comment = IntegerField()
share = IntegerField()
like = IntegerField()
class Photo(BaseModel):
id = IntegerField(unique=True, primary_key=True)
uid = IntegerField(index=True)
album_id = IntegerField(index=True)
pos = IntegerField(index=True)
prev = IntegerField()
next = IntegerField()
t = DateTimeField()
title = CharField()
src = CharField()
comment = IntegerField()
share = IntegerField()
like = IntegerField()
view = IntegerField()