map_service_register.py
6.1 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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# coding=utf-8
#author: 4N
#createtime: 2021/9/17
#email: nheweijun@sina.com
from app.util.component.ApiTemplate import ApiTemplate
import uuid
from ..models import Service,db,MapService,ServiceFunction
import datetime
import configure
class Api(ApiTemplate):
api_name = "注册MapService服务"
def process(self):
# 返回结果
res = {}
try:
this_time = datetime.datetime.now()
service_guid = uuid.uuid1().__str__()
map_service_guid = uuid.uuid1().__str__()
service_function_guid = uuid.uuid1().__str__()
# 逻辑是,先调用引擎接口,引擎说可以,才做持久化
# 并获得服务缩略图
service = Service(
guid = service_guid,
name = self.para.get("name"),
title = self.para.get("title"),
state = int(self.para.get("state")) if self.para.get("state") else None,
create_time = this_time,
update_time = this_time,
description = self.para.get("description"),
#node = Column(Integer),
node = 1 ,
overview = "xxxx",
type = self.para.get("type"),
catalog_guid = self.para.get("catalog_guid")
)
map_service = MapService(
guid = map_service_guid,
name = self.para.get("name"),
status = self.para.get("status"),
description=self.para.get("description"),
username = self.para.get("username"),
readonly = self.para.get("readonly"),
updatetime = this_time,
sid = int(self.para.get("sid")),
stype = self.para.get("stype"),
ssupply = self.para.get("ssupply"),
sctime = self.para.get("sctime"),
company = self.para.get("company"),
abstract = self.para.get("abstract"),
thumbnail = self.para.get("thumbnail"),
layer_style = self.para.get("layer_style"),
service_guid = service_guid
)
service_function = ServiceFunction(guid=service_function_guid,type="WMS",
service_guid=service_guid)
db.session.add(service)
db.session.add(map_service)
db.session.add(service_function)
db.session.commit()
# 调用MapService服务的注册服务接口
try:
pass
#对,逻辑是,先调用引擎接口,引擎说可以,才做持久化
except Exception as e:
db.session.delete(service)
db.session.delete(map_service)
db.session.delete(service_function)
db.session.commit()
raise e
res["data"] = service_guid
res["result"] = True
except Exception as e:
db.session.rollback()
raise e
return res
api_doc = {
"tags": ["地图服务接口"],
"parameters": [
{"name": "name",
"in": "formData",
"type": "string",
"required": "true",
"description": "[地图服务,切片服务,影像服务]"},
{"name": "title",
"in": "formData",
"type": "string",
"description": "[地图服务,切片服务,影像服务]"},
{"name": "description",
"in": "formData",
"type": "string",
"description": "[地图服务,切片服务,影像服务]"},
{"name": "type",
"in": "formData",
"type": "string",
"enum": ["地图服务", "切片服务", "影像服务"],
"required": "true",
"description": "[地图服务,切片服务,影像服务]"},
{"name": "catalog_guid",
"in": "formData",
"type": "string",
"description": "[地图服务,切片服务,影像服务]"},
{"name": "status",
"in": "formData",
"type": "string",
"description": "[地图服务]status"},
{"name": "username",
"in": "formData",
"type": "string",
"description": "[地图服务]username"},
{"name": "readonly",
"in": "formData",
"type": "string",
"description": "[地图服务]readonly"},
{"name": "sid",
"in": "formData",
"type": "string",
"description": "[地图服务]sid"},
{"name": "stype",
"in": "formData",
"type": "string",
"description": "[地图服务]stype"},
{"name": "ssupply",
"in": "formData",
"type": "string",
"description": "[地图服务]ssupply"},
{"name": "sctime",
"in": "formData",
"type": "string",
"description": "[地图服务]sctime"},
{"name": "company",
"in": "formData",
"type": "string",
"description": "[地图服务]company"},
{"name": "abstract",
"in": "formData",
"type": "string",
"description": "[地图服务]abstract"},
{"name": "thumbnail",
"in": "formData",
"type": "string",
"description": "[地图服务]thumbnail"},
{"name": "layer_style",
"in": "formData",
"type": "string",
"description": "[地图服务,切片服务]layer_style"},
],
"responses": {
200: {
"schema": {
"properties": {
}
}
}
}
}