文档服务地址:http://47.92.0.57:3000/ 周报索引地址:http://47.92.0.57:3000/s/NruNXRYmV

Commit 7d640c7b by 李景熙

在文件数据库中添加大小size属性

parent 67617317
...@@ -18,6 +18,7 @@ class Data(Model): ...@@ -18,6 +18,7 @@ class Data(Model):
data_id = AutoField(primary_key=True, unique=True) data_id = AutoField(primary_key=True, unique=True)
slice_id = IntegerField(null=False) slice_id = IntegerField(null=False)
name = CharField(null=False, max_length=30) name = CharField(null=False, max_length=30)
size = IntegerField(null=False)
url = CharField(null=False, unique=True) url = CharField(null=False, unique=True)
class Meta: class Meta:
...@@ -25,10 +26,10 @@ class Data(Model): ...@@ -25,10 +26,10 @@ class Data(Model):
# 向数据库中添加原始数据 # 向数据库中添加原始数据
def create_data(slice_id, name, url): def create_data(slice_id, name, size, url):
try: try:
Slice.add_file(slice_id) Slice.add_file(slice_id)
data = Data(slice_id=slice_id, name=name, url=url) data = Data(slice_id=slice_id, name=name, size=size, url=url)
data.save() data.save()
except Exception: except Exception:
return Result(0, "create failed", {}) return Result(0, "create failed", {})
...@@ -57,7 +58,9 @@ def find_data_by_slice(slice_id): ...@@ -57,7 +58,9 @@ def find_data_by_slice(slice_id):
list.append( list.append(
{ {
'id': find[index].data_id, 'id': find[index].data_id,
'name': find[index].name 'name': find[index].name,
'size': find[index].size,
'state': 0
} }
) )
index += 1 index += 1
......
...@@ -119,4 +119,5 @@ if __name__ == '__main__': ...@@ -119,4 +119,5 @@ if __name__ == '__main__':
# create_text_slice(1,1) # create_text_slice(1,1)
# create_pic_slice(1, "标注坐标(30,100)") # create_pic_slice(1, "标注坐标(30,100)")
# create_layer_slice(1, "。。。。。。") # create_layer_slice(1, "。。。。。。")
Slice.drop_table()
Slice.create_table() Slice.create_table()
...@@ -145,4 +145,5 @@ def add_slice(task_id): ...@@ -145,4 +145,5 @@ def add_slice(task_id):
if __name__ == '__main__': if __name__ == '__main__':
# delete_task(10) # delete_task(10)
Task.drop_table()
Task.create_table() Task.create_table()
...@@ -46,6 +46,7 @@ def create_task(): ...@@ -46,6 +46,7 @@ def create_task():
j = 0 j = 0
while j < len(data['task']['domains'][i]['fileName']): while j < len(data['task']['domains'][i]['fileName']):
Data.create_data(s.data, data['task']['domains'][i]['fileName'][j]['name'], Data.create_data(s.data, data['task']['domains'][i]['fileName'][j]['name'],
data['task']['domains'][i]['fileName'][j]['size'],
data['task']['domains'][i]['fileName'][j]['url']) data['task']['domains'][i]['fileName'][j]['url'])
j += 1 j += 1
i += 1 i += 1
...@@ -55,6 +56,7 @@ def create_task(): ...@@ -55,6 +56,7 @@ def create_task():
j = 0 j = 0
while j < len(data['task']['pictureDomains'][i]['fileName']): while j < len(data['task']['pictureDomains'][i]['fileName']):
Data.create_data(s.data, data['task']['pictureDomains'][i]['fileName'][j]['name'], Data.create_data(s.data, data['task']['pictureDomains'][i]['fileName'][j]['name'],
data['task']['pictureDomains'][i]['fileName'][j]['size'],
data['task']['pictureDomains'][i]['fileName'][j]['url']) data['task']['pictureDomains'][i]['fileName'][j]['url'])
j += 1 j += 1
i += 1 i += 1
...@@ -64,6 +66,7 @@ def create_task(): ...@@ -64,6 +66,7 @@ def create_task():
j = 0 j = 0
while j < len(data['task']['layerDomains'][i]['fileName']): while j < len(data['task']['layerDomains'][i]['fileName']):
Data.create_data(s.data, data['task']['layerDomains'][i]['fileName'][j]['name'], Data.create_data(s.data, data['task']['layerDomains'][i]['fileName'][j]['name'],
data['task']['layerDomains'][i]['fileName'][j]['size'],
data['task']['layerDomains'][i]['fileName'][j]['url']) data['task']['layerDomains'][i]['fileName'][j]['url'])
j += 1 j += 1
i += 1 i += 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment