image_edit.py
2.4 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# coding=utf-8
#author: 4N
#createtime: 2021/9/8
#email: nheweijun@sina.com
from app.util.component.ApiTemplate import ApiTemplate
from app.modules.service.image.models import Image,db,ImageTag
import datetime
class Api(ApiTemplate):
api_name = "修改影像数据"
def process(self):
# 返回结果
res = {}
try:
para = self.para
guid = self.para.get("guid")
tag_guids = self.para.get("tag_guids")
image = Image.query.filter_by(guid=guid)
this_time = datetime.datetime.now()
del para["guid"]
if para.get("tag_guids"):
del para["tag_guids"]
if para or tag_guids:
para["update_time"] = this_time
image.update(para)
if tag_guids:
tags = ImageTag.query.filter(ImageTag.guid.in_(tag_guids.split(","))).all()
img = Image.query.filter_by(guid=guid).one_or_none()
img.image_tags = tags
db.session.commit()
res["result"] = True
except Exception as e:
raise e
return res
api_doc = {
"tags": ["影像接口"],
"parameters": [
{"name": "guid",
"in": "formData",
"type": "string"},
{"name": "alias",
"in": "formData",
"type": "string"},
{"name": "collect_time",
"in": "formData",
"type": "string","description":"成像时间字符串"},
{"name": "region",
"in": "formData",
"type": "string", "description": "所属区域"},
{"name": "satellite",
"in": "formData",
"type": "string", "description": "卫星类型"},
{"name": "crs",
"in": "formData",
"type": "string", "description": "空间参考"},
{"name": "band_view",
"in": "formData",
"type": "string", "description": "波段设计[1,1,1]"},
{"name": "tag_guids",
"in": "formData",
"type": "string", "description": "tags"},
],
"responses": {
200: {
"schema": {
"properties": {
}
}
}
}
}