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

Commit f43bf59a by 李景熙

添加后端发布任务时数据库中文件相关信息的修改

parent a0a1bc40
from peewee import *
from Dao.model import mysql
from Dao import Slice
class Result:
......@@ -16,6 +17,7 @@ class Result:
class Data(Model):
data_id = AutoField(primary_key=True, unique=True)
slice_id = IntegerField(null=False)
name = CharField(null=False, max_length=30)
url = CharField(null=False, unique=True)
class Meta:
......@@ -23,9 +25,10 @@ class Data(Model):
# 向数据库中添加原始数据
def create_data(slice_id, url):
def create_data(slice_id, name, url):
try:
data = Data(slice_id=slice_id, url=url)
Slice.add_file(slice_id)
data = Data(slice_id=slice_id, name=name, url=url)
data.save()
except Exception:
return Result(0, "create failed", {})
......@@ -44,4 +47,5 @@ def find_data(id):
if __name__ == '__main__':
Data.drop_table()
Data.create_table()
......@@ -103,6 +103,18 @@ def find_slice_by_task(task_id):
return Result(1, "find success", list)
# 添加文件
def add_file(slice_id):
try:
s = Slice.get(Slice.slice_id == slice_id)
except:
return False
else:
s.document_number += 1
s.save()
return True
if __name__ == '__main__':
# create_text_slice(1,1)
# create_pic_slice(1, "标注坐标(30,100)")
......
import json
from flask import Blueprint
from flask import request
from Dao import Task, Slice
from Dao import Task, Slice, Data
task = Blueprint("task", __name__, url_prefix="/api/task")
......@@ -42,16 +42,30 @@ def create_task():
i = 0
print(data)
while i < len(data['task']['domains']):
# 创建分片具体内容还有问题,待修复
Slice.create_text_slice(tid, data['task']['domains'][i]['piecesOptions'])
s = Slice.create_text_slice(tid, data['task']['domains'][i]['piecesOptions'])
j = 0
while j < len(data['task']['domains'][i]['fileName']):
Data.create_data(s.data, data['task']['domains'][i]['fileName'][j]['name'],
data['task']['domains'][i]['fileName'][j]['url'])
j += 1
i += 1
i = 0
while i < len(data['task']['pictureDomains']):
Slice.create_pic_slice(tid, data['task']['pictureDomains'][i]['textarea'])
s = Slice.create_pic_slice(tid, data['task']['pictureDomains'][i]['textarea'])
j = 0
while j < len(data['task']['pictureDomains'][i]['fileName']):
Data.create_data(s.data, data['task']['pictureDomains'][i]['fileName'][j]['name'],
data['task']['pictureDomains'][i]['fileName'][j]['url'])
j += 1
i += 1
i = 0
while i < len(data['task']['layerDomains']):
Slice.create_layer_slice(tid, data['task']['layerDomains'][i]['textarea'])
s = Slice.create_layer_slice(tid, data['task']['layerDomains'][i]['textarea'])
j = 0
while j < len(data['task']['layerDomains'][i]['fileName']):
Data.create_data(s.data, data['task']['layerDomains'][i]['fileName'][j]['name'],
data['task']['layerDomains'][i]['fileName'][j]['url'])
j += 1
i += 1
res = {
'code': ret.code,
......
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