image_info.py
1.7 KB
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
# coding=utf-8
#author: 4N
#createtime: 2021/7/19
#email: nheweijun@sina.com
from app.util.component.ApiTemplate import ApiTemplate
from app.util.component.ModelVisitor import ModelVisitor
from app.modules.service.image.models import Image,ImageTag
from sqlalchemy import or_,and_
from app.util.component.FileProcess import FileProcess
class Api(ApiTemplate):
api_name = "影像数据Info"
def process(self):
# 返回结果
res = {}
try:
guid = self.para.get("guid")
image = Image.query.filter_by(guid=guid).one_or_none()
if not image:
raise Exception("数据不存在!")
tags:ImageTag = image.image_tags
# tag_names = [tag.name for tag in tags]
res["data"] = ModelVisitor.object_to_json(image)
#格式化数据
res["data"]["size"] = FileProcess.get_text_size(res["data"]["size"])
res["data"]["cell_x_size"] = round(res["data"]["cell_x_size"],3)
res["data"]["cell_y_size"] = round(res["data"]["cell_y_size"], 3)
res["data"]["image_tags"] = ModelVisitor.objects_to_jsonarray(tags)
res["result"] = True
except Exception as e:
raise e
return res
api_doc = {
"tags": ["影像接口"],
"parameters": [
{"name": "guid",
"in": "formData",
"type": "string"},
],
"responses": {
200: {
"schema": {
"properties": {
}
}
}
}
}