正在显示
20 个修改的文件
包含
95 行增加
和
61 行删除
| @@ -28,7 +28,7 @@ class Api(ApiTemplate): | @@ -28,7 +28,7 @@ class Api(ApiTemplate): | ||
| 28 | service = Service.query.filter_by(guid=guid) | 28 | service = Service.query.filter_by(guid=guid) |
| 29 | this_time = datetime.datetime.now() | 29 | this_time = datetime.datetime.now() |
| 30 | image_guids = self.para.get("image_guids") | 30 | image_guids = self.para.get("image_guids") |
| 31 | - function_types = self.para.get("function_types") | 31 | + functions = self.para.get("functions") |
| 32 | 32 | ||
| 33 | service_update = {} | 33 | service_update = {} |
| 34 | image_update = {} | 34 | image_update = {} |
| @@ -42,15 +42,16 @@ class Api(ApiTemplate): | @@ -42,15 +42,16 @@ class Api(ApiTemplate): | ||
| 42 | image_service = ImageService.query.filter_by(service_guid=guid) | 42 | image_service = ImageService.query.filter_by(service_guid=guid) |
| 43 | 43 | ||
| 44 | # 修改功能 | 44 | # 修改功能 |
| 45 | - if function_types: | ||
| 46 | - new_types = function_types.split(",") | 45 | + if functions: |
| 46 | + new_types = functions.split(",") | ||
| 47 | old_functions = ServiceFunction.query.filter_by(service_guid=guid).all() | 47 | old_functions = ServiceFunction.query.filter_by(service_guid=guid).all() |
| 48 | for function in old_functions: | 48 | for function in old_functions: |
| 49 | if function.type not in new_types: | 49 | if function.type not in new_types: |
| 50 | db.session.delete(function) | 50 | db.session.delete(function) |
| 51 | for new_type in new_types: | 51 | for new_type in new_types: |
| 52 | if new_type not in [fun.type for fun in old_functions]: | 52 | if new_type not in [fun.type for fun in old_functions]: |
| 53 | - service_function = ServiceFunction(guid=uuid.uuid1().__str__()) | 53 | + service_function = ServiceFunction(guid=uuid.uuid1().__str__(),type=new_type, |
| 54 | + service_guid=guid) | ||
| 54 | db.session.add(service_function) | 55 | db.session.add(service_function) |
| 55 | 56 | ||
| 56 | #修改影像 | 57 | #修改影像 |
| @@ -74,7 +75,7 @@ class Api(ApiTemplate): | @@ -74,7 +75,7 @@ class Api(ApiTemplate): | ||
| 74 | 75 | ||
| 75 | image_update["extent"] = json.dumps(image_service_exetent) | 76 | image_update["extent"] = json.dumps(image_service_exetent) |
| 76 | 77 | ||
| 77 | - if service_update or image_update or function_types: | 78 | + if service_update or image_update or functions: |
| 78 | service_update["update_time"] = this_time | 79 | service_update["update_time"] = this_time |
| 79 | if image_guids: | 80 | if image_guids: |
| 80 | register_api = RegisterApi() | 81 | register_api = RegisterApi() |
| @@ -125,7 +126,7 @@ class Api(ApiTemplate): | @@ -125,7 +126,7 @@ class Api(ApiTemplate): | ||
| 125 | "type": "string", | 126 | "type": "string", |
| 126 | "description": "[地图服务,切片服务,影像服务]"}, | 127 | "description": "[地图服务,切片服务,影像服务]"}, |
| 127 | 128 | ||
| 128 | - {"name": "function_types", | 129 | + {"name": "functions", |
| 129 | "in": "formData", | 130 | "in": "formData", |
| 130 | "type": "string", | 131 | "type": "string", |
| 131 | "description": "[地图服务,切片服务,影像服务]以逗号相隔,可选WMTS,WMS"}, | 132 | "description": "[地图服务,切片服务,影像服务]以逗号相隔,可选WMTS,WMS"}, |
| @@ -34,7 +34,7 @@ class Api(ApiTemplate): | @@ -34,7 +34,7 @@ class Api(ApiTemplate): | ||
| 34 | try: | 34 | try: |
| 35 | guids = self.para.get("guids").split(",") | 35 | guids = self.para.get("guids").split(",") |
| 36 | name = self.para.get("name") | 36 | name = self.para.get("name") |
| 37 | - function_types = self.para.get("function_types") | 37 | + functions = self.para.get("functions") |
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | image_service_guid = uuid.uuid1().__str__() | 40 | image_service_guid = uuid.uuid1().__str__() |
| @@ -82,7 +82,7 @@ class Api(ApiTemplate): | @@ -82,7 +82,7 @@ class Api(ApiTemplate): | ||
| 82 | 82 | ||
| 83 | 83 | ||
| 84 | 84 | ||
| 85 | - for type in function_types.split(","): | 85 | + for type in functions.split(","): |
| 86 | service_function = ServiceFunction(guid=service_function_guid, | 86 | service_function = ServiceFunction(guid=service_function_guid, |
| 87 | service_guid=service_guid, | 87 | service_guid=service_guid, |
| 88 | type=type) | 88 | type=type) |
| @@ -98,7 +98,7 @@ class Api(ApiTemplate): | @@ -98,7 +98,7 @@ class Api(ApiTemplate): | ||
| 98 | configure.deploy_ip_host,overview_file) | 98 | configure.deploy_ip_host,overview_file) |
| 99 | 99 | ||
| 100 | db.session.commit() | 100 | db.session.commit() |
| 101 | - res["data"] = image_service_guid | 101 | + res["data"] = service_guid |
| 102 | res["result"] = True | 102 | res["result"] = True |
| 103 | except Exception as e: | 103 | except Exception as e: |
| 104 | db.session.rollback() | 104 | db.session.rollback() |
| @@ -108,7 +108,7 @@ class Api(ApiTemplate): | @@ -108,7 +108,7 @@ class Api(ApiTemplate): | ||
| 108 | 108 | ||
| 109 | def get_overview(self,service,image_service): | 109 | def get_overview(self,service,image_service): |
| 110 | 110 | ||
| 111 | - api = RealApi("") | 111 | + api = RealApi(service.name) |
| 112 | 112 | ||
| 113 | 113 | ||
| 114 | query_extent = json.loads(image_service.extent) | 114 | query_extent = json.loads(image_service.extent) |
| @@ -171,7 +171,7 @@ class Api(ApiTemplate): | @@ -171,7 +171,7 @@ class Api(ApiTemplate): | ||
| 171 | "in": "formData", | 171 | "in": "formData", |
| 172 | "type": "string", | 172 | "type": "string", |
| 173 | "description": "[影像服务]切片方案"}, | 173 | "description": "[影像服务]切片方案"}, |
| 174 | - {"name": "function_types", | 174 | + {"name": "functions", |
| 175 | "in": "formData", | 175 | "in": "formData", |
| 176 | "type": "string", | 176 | "type": "string", |
| 177 | "description": "[影像服务]功能类型,以逗号相隔,可选WMTS,WMS"}, | 177 | "description": "[影像服务]功能类型,以逗号相隔,可选WMTS,WMS"}, |
| @@ -53,8 +53,7 @@ class Cache: | @@ -53,8 +53,7 @@ class Cache: | ||
| 53 | if type.__eq__("guid"): | 53 | if type.__eq__("guid"): |
| 54 | image_service: ImageService = ImageService.query.filter_by(guid=guid_or_name).one_or_none() | 54 | image_service: ImageService = ImageService.query.filter_by(guid=guid_or_name).one_or_none() |
| 55 | else: | 55 | else: |
| 56 | - service = Service.query.filter_by(name=guid_or_name).one_or_none() | ||
| 57 | - image_service: ImageService = ImageService.query.filter_by(guid=service.service_guid).one_or_none() | 56 | + image_service: ImageService = ImageService.query.filter_by(name=guid_or_name).one_or_none() |
| 58 | images = image_service.images.all() | 57 | images = image_service.images.all() |
| 59 | 58 | ||
| 60 | if image_service.scheme_guid: | 59 | if image_service.scheme_guid: |
| @@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
| 6 | 6 | ||
| 7 | from app.util.component.ApiTemplate import ApiTemplate | 7 | from app.util.component.ApiTemplate import ApiTemplate |
| 8 | import uuid | 8 | import uuid |
| 9 | -from ..models import Service,MapService,db | 9 | +from ..models import Service,MapService,db,ServiceFunction |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | import datetime | 12 | import datetime |
| @@ -21,6 +21,7 @@ class Api(ApiTemplate): | @@ -21,6 +21,7 @@ class Api(ApiTemplate): | ||
| 21 | 21 | ||
| 22 | try: | 22 | try: |
| 23 | guid = self.para.get("guid") | 23 | guid = self.para.get("guid") |
| 24 | + functions = self.para.get("functions") | ||
| 24 | service = Service.query.filter_by(guid=guid) | 25 | service = Service.query.filter_by(guid=guid) |
| 25 | this_time = datetime.datetime.now() | 26 | this_time = datetime.datetime.now() |
| 26 | 27 | ||
| @@ -35,6 +36,19 @@ class Api(ApiTemplate): | @@ -35,6 +36,19 @@ class Api(ApiTemplate): | ||
| 35 | map_service_update[key] = self.para.get(key) | 36 | map_service_update[key] = self.para.get(key) |
| 36 | 37 | ||
| 37 | 38 | ||
| 39 | + # 修改功能 | ||
| 40 | + if functions: | ||
| 41 | + new_types = functions.split(",") | ||
| 42 | + old_functions = ServiceFunction.query.filter_by(service_guid=guid).all() | ||
| 43 | + for function in old_functions: | ||
| 44 | + if function.type not in new_types: | ||
| 45 | + db.session.delete(function) | ||
| 46 | + for new_type in new_types: | ||
| 47 | + if new_type not in [fun.type for fun in old_functions]: | ||
| 48 | + service_function = ServiceFunction(guid=uuid.uuid1().__str__(),type=new_type, | ||
| 49 | + service_guid=guid) | ||
| 50 | + db.session.add(service_function) | ||
| 51 | + | ||
| 38 | map_service = MapService.query.filter_by(service_guid=guid) | 52 | map_service = MapService.query.filter_by(service_guid=guid) |
| 39 | 53 | ||
| 40 | if service_update: | 54 | if service_update: |
| @@ -182,6 +182,7 @@ class TileService(db.Model): | @@ -182,6 +182,7 @@ class TileService(db.Model): | ||
| 182 | #基本信息 | 182 | #基本信息 |
| 183 | name = Column(String,unique = True) | 183 | name = Column(String,unique = True) |
| 184 | 184 | ||
| 185 | + tile_type = Column(String(256)) | ||
| 185 | #厂家 | 186 | #厂家 |
| 186 | vendor = Column(String(256)) | 187 | vendor = Column(String(256)) |
| 187 | create_time = Column(DateTime) | 188 | create_time = Column(DateTime) |
11.9 KB
11.9 KB
| @@ -46,133 +46,138 @@ class Api(ApiTemplate): | @@ -46,133 +46,138 @@ class Api(ApiTemplate): | ||
| 46 | {"name": "guid", | 46 | {"name": "guid", |
| 47 | "in": "formData", | 47 | "in": "formData", |
| 48 | "type": "string", | 48 | "type": "string", |
| 49 | - "description": "[WMS,WMTS,影像WMS,影像WMTS,guid]"}, | 49 | + "description": "[服务guid]"}, |
| 50 | 50 | ||
| 51 | {"name": "type", | 51 | {"name": "type", |
| 52 | "in": "formData", | 52 | "in": "formData", |
| 53 | "type": "string", | 53 | "type": "string", |
| 54 | - "enum": ["WMS/WFS", "WMTS", "TMS", "ImageWMS", "ImageWMTS"], | ||
| 55 | - "description": "[WMS,WMTS,影像WMS,影像WMTS]"}, | 54 | + "enum": ["地图服务","切片服务","影像服务"], |
| 55 | + "description": "[地图服务,切片服务,影像服务]"}, | ||
| 56 | 56 | ||
| 57 | {"name": "name", | 57 | {"name": "name", |
| 58 | "in": "formData", | 58 | "in": "formData", |
| 59 | "type": "string", | 59 | "type": "string", |
| 60 | - "description": "[WMS,WMTS,影像WMS,影像WMTS]"}, | 60 | + "description": "[地图服务,切片服务,影像服务]"}, |
| 61 | {"name": "title", | 61 | {"name": "title", |
| 62 | "in": "formData", | 62 | "in": "formData", |
| 63 | "type": "string", | 63 | "type": "string", |
| 64 | - "description": "[WMS,WMTS,影像WMS,影像WMTS]"}, | 64 | + "description": "[地图服务,切片服务,影像服务]"}, |
| 65 | {"name": "description", | 65 | {"name": "description", |
| 66 | "in": "formData", | 66 | "in": "formData", |
| 67 | "type": "string", | 67 | "type": "string", |
| 68 | - "description": "[WMS,WMTS,影像WMS,影像WMTS]"}, | 68 | + "description": "[地图服务,切片服务,影像服务]"}, |
| 69 | 69 | ||
| 70 | {"name": "catalog_guid", | 70 | {"name": "catalog_guid", |
| 71 | "in": "formData", | 71 | "in": "formData", |
| 72 | "type": "string", | 72 | "type": "string", |
| 73 | - "description": "[WMS,WMTS,影像WMS,影像WMTS]"}, | 73 | + "description": "[地图服务,切片服务,影像服务]"}, |
| 74 | + | ||
| 75 | + {"name": "functions", | ||
| 76 | + "in": "formData", | ||
| 77 | + "type": "string", | ||
| 78 | + "description": "[地图服务,影像服务]以逗号相隔,可选WMTS,WMS"}, | ||
| 74 | 79 | ||
| 75 | # 影像参数 | 80 | # 影像参数 |
| 76 | {"name": "image_guids", | 81 | {"name": "image_guids", |
| 77 | "in": "formData", | 82 | "in": "formData", |
| 78 | "type": "string", | 83 | "type": "string", |
| 79 | - "description": "[影像WMS,影像WMTS]影像guids,以英文逗号相隔"}, | 84 | + "description": "[影像服务]影像guids,以英文逗号相隔"}, |
| 80 | {"name": "scheme_guid", | 85 | {"name": "scheme_guid", |
| 81 | "in": "formData", | 86 | "in": "formData", |
| 82 | "type": "string", | 87 | "type": "string", |
| 83 | - "description": "[WMTS,影像WMTS]切片方案"}, | 88 | + "description": "[切片服务,影像服务]切片方案"}, |
| 84 | 89 | ||
| 85 | - # WMTS参数 | 90 | + # 切片参数 |
| 86 | {"name": "overview", | 91 | {"name": "overview", |
| 87 | "in": "formData", | 92 | "in": "formData", |
| 88 | "type": "string", | 93 | "type": "string", |
| 89 | - "description": "[WMTS]缩略图"}, | ||
| 90 | - {"name": "wmts_type", | 94 | + "description": "[切片服务]缩略图"}, |
| 95 | + {"name": "tile_type", | ||
| 91 | "in": "formData", | 96 | "in": "formData", |
| 92 | "type": "string", | 97 | "type": "string", |
| 93 | - "description": "[WMTS]wmts_type"}, | 98 | + "description": "[切片服务]tile_type"}, |
| 94 | {"name": "vendor", | 99 | {"name": "vendor", |
| 95 | "in": "formData", | 100 | "in": "formData", |
| 96 | "type": "string", | 101 | "type": "string", |
| 97 | - "description": "[WMTS]厂商"}, | 102 | + "description": "[切片服务]厂商"}, |
| 98 | {"name": "crs", | 103 | {"name": "crs", |
| 99 | "in": "formData", | 104 | "in": "formData", |
| 100 | "type": "string", | 105 | "type": "string", |
| 101 | - "description": "[WMTS]坐标系"}, | 106 | + "description": "[切片服务]坐标系"}, |
| 102 | {"name": "datasource", | 107 | {"name": "datasource", |
| 103 | "in": "formData", | 108 | "in": "formData", |
| 104 | "type": "string", | 109 | "type": "string", |
| 105 | - "description": "[WMTS]数据路径"}, | 110 | + "description": "[切片服务]数据路径"}, |
| 106 | {"name": "layer_name", | 111 | {"name": "layer_name", |
| 107 | "in": "formData", | 112 | "in": "formData", |
| 108 | "type": "string", | 113 | "type": "string", |
| 109 | - "description": "[WMTS]图层名"}, | 114 | + "description": "[切片服务]图层名"}, |
| 110 | {"name": "layer_alias", | 115 | {"name": "layer_alias", |
| 111 | "in": "formData", | 116 | "in": "formData", |
| 112 | "type": "string", | 117 | "type": "string", |
| 113 | - "description": "[WMTS]图层别名"}, | 118 | + "description": "[切片服务]图层别名"}, |
| 114 | {"name": "layer_title", | 119 | {"name": "layer_title", |
| 115 | "in": "formData", | 120 | "in": "formData", |
| 116 | "type": "string", | 121 | "type": "string", |
| 117 | - "description": "[WMTS]图层标题"}, | 122 | + "description": "[切片服务]图层标题"}, |
| 118 | {"name": "layer_style", | 123 | {"name": "layer_style", |
| 119 | "in": "formData", | 124 | "in": "formData", |
| 120 | "type": "string", | 125 | "type": "string", |
| 121 | - "description": "[WMTS,WMS]图层样式"}, | 126 | + "description": "[地图服务,切片服务]图层样式"}, |
| 122 | {"name": "layer_format", | 127 | {"name": "layer_format", |
| 123 | "in": "formData", | 128 | "in": "formData", |
| 124 | "type": "string", | 129 | "type": "string", |
| 125 | - "description": "[WMTS]图层format"}, | 130 | + "description": "[切片服务]图层format"}, |
| 126 | {"name": "layer_extent", | 131 | {"name": "layer_extent", |
| 127 | "in": "formData", | 132 | "in": "formData", |
| 128 | "type": "string", | 133 | "type": "string", |
| 129 | - "description": "[WMTS]图层范围"}, | 134 | + "description": "[切片服务]图层范围"}, |
| 130 | {"name": "layer_description", | 135 | {"name": "layer_description", |
| 131 | "in": "formData", | 136 | "in": "formData", |
| 132 | "type": "string", | 137 | "type": "string", |
| 133 | - "description": "[WMTS]图层描述"}, | 138 | + "description": "[切片服务]图层描述"}, |
| 134 | 139 | ||
| 135 | # WMS参数 | 140 | # WMS参数 |
| 136 | {"name": "status", | 141 | {"name": "status", |
| 137 | "in": "formData", | 142 | "in": "formData", |
| 138 | "type": "string", | 143 | "type": "string", |
| 139 | - "description": "[WMS]status"}, | 144 | + "description": "[地图服务]status"}, |
| 140 | {"name": "username", | 145 | {"name": "username", |
| 141 | "in": "formData", | 146 | "in": "formData", |
| 142 | "type": "string", | 147 | "type": "string", |
| 143 | - "description": "[WMS]username"}, | 148 | + "description": "[地图服务]username"}, |
| 144 | {"name": "readonly", | 149 | {"name": "readonly", |
| 145 | "in": "formData", | 150 | "in": "formData", |
| 146 | "type": "string", | 151 | "type": "string", |
| 147 | - "description": "[WMS]readonly"}, | 152 | + "description": "[地图服务]readonly"}, |
| 148 | {"name": "sid", | 153 | {"name": "sid", |
| 149 | "in": "formData", | 154 | "in": "formData", |
| 150 | "type": "string", | 155 | "type": "string", |
| 151 | - "description": "[WMS]sid"}, | 156 | + "description": "[地图服务]sid"}, |
| 152 | {"name": "stype", | 157 | {"name": "stype", |
| 153 | "in": "formData", | 158 | "in": "formData", |
| 154 | "type": "string", | 159 | "type": "string", |
| 155 | - "description": "[WMS]stype"}, | 160 | + "description": "[地图服务]stype"}, |
| 156 | {"name": "ssupply", | 161 | {"name": "ssupply", |
| 157 | "in": "formData", | 162 | "in": "formData", |
| 158 | "type": "string", | 163 | "type": "string", |
| 159 | - "description": "[WMS]ssupply"}, | 164 | + "description": "[地图服务]ssupply"}, |
| 160 | {"name": "sctime", | 165 | {"name": "sctime", |
| 161 | "in": "formData", | 166 | "in": "formData", |
| 162 | "type": "string", | 167 | "type": "string", |
| 163 | - "description": "[WMS]sctime"}, | 168 | + "description": "[地图服务]sctime"}, |
| 164 | {"name": "company", | 169 | {"name": "company", |
| 165 | "in": "formData", | 170 | "in": "formData", |
| 166 | "type": "string", | 171 | "type": "string", |
| 167 | - "description": "[WMS]company"}, | 172 | + "description": "[地图服务]company"}, |
| 168 | {"name": "abstract", | 173 | {"name": "abstract", |
| 169 | "in": "formData", | 174 | "in": "formData", |
| 170 | "type": "string", | 175 | "type": "string", |
| 171 | - "description": "[WMS]abstract"}, | 176 | + "description": "[地图服务]abstract"}, |
| 172 | {"name": "thumbnail", | 177 | {"name": "thumbnail", |
| 173 | "in": "formData", | 178 | "in": "formData", |
| 174 | "type": "string", | 179 | "type": "string", |
| 175 | - "description": "[WMS]thumbnail"}, | 180 | + "description": "[地图服务]thumbnail"}, |
| 176 | ], | 181 | ], |
| 177 | "responses": { | 182 | "responses": { |
| 178 | 200: { | 183 | 200: { |
| @@ -20,29 +20,24 @@ class Api(ApiTemplate): | @@ -20,29 +20,24 @@ class Api(ApiTemplate): | ||
| 20 | res["data"] = {} | 20 | res["data"] = {} |
| 21 | 21 | ||
| 22 | if service.type.__eq__("影像服务"): | 22 | if service.type.__eq__("影像服务"): |
| 23 | - from app.modules.service.models import ImageService | ||
| 24 | - speci_service = ImageService.query.filter_by(guid=service.service_guid).one_or_none() | 23 | + speci_service = service.relate_image_service.one_or_none() |
| 25 | relate_images = speci_service.images.all() | 24 | relate_images = speci_service.images.all() |
| 26 | res["data"]["speci_service"] = ModelVisitor.object_to_json(speci_service) | 25 | res["data"]["speci_service"] = ModelVisitor.object_to_json(speci_service) |
| 27 | - | ||
| 28 | res["data"]["speci_service"]["images"] = [{"name":im["name"],"guid":im["guid"]} for im in ModelVisitor.objects_to_jsonarray(relate_images)] | 26 | res["data"]["speci_service"]["images"] = [{"name":im["name"],"guid":im["guid"]} for im in ModelVisitor.objects_to_jsonarray(relate_images)] |
| 29 | res["data"]["speci_service"]["images"] = sorted(res["data"]["speci_service"]["images"], key=lambda x: x["name"]) | 27 | res["data"]["speci_service"]["images"] = sorted(res["data"]["speci_service"]["images"], key=lambda x: x["name"]) |
| 30 | 28 | ||
| 31 | elif service.type.__eq__("切片服务"): | 29 | elif service.type.__eq__("切片服务"): |
| 32 | - from app.modules.service.models import MapService | ||
| 33 | - speci_service = MapService.query.filter_by(guid=service.service_guid).one_or_none() | ||
| 34 | - | 30 | + speci_service = service.relate_map_service.one_or_none() |
| 35 | res["data"]["speci_service"] = ModelVisitor.object_to_json(speci_service) | 31 | res["data"]["speci_service"] = ModelVisitor.object_to_json(speci_service) |
| 36 | - | ||
| 37 | elif service.type.__eq__("地图服务"): | 32 | elif service.type.__eq__("地图服务"): |
| 38 | - from app.modules.service.models import TileService | ||
| 39 | - speci_service = TileService.query.filter_by(guid=service.service_guid).one_or_none() | 33 | + speci_service = service.relate_tile_service.one_or_none() |
| 40 | res["data"]["speci_service"] = ModelVisitor.object_to_json(speci_service) | 34 | res["data"]["speci_service"] = ModelVisitor.object_to_json(speci_service) |
| 41 | else: | 35 | else: |
| 42 | res["data"] = {} | 36 | res["data"] = {} |
| 43 | 37 | ||
| 38 | + functions = ModelVisitor.objects_to_jsonarray(service.relate_service_functions.all()) | ||
| 44 | res["data"]["service"] = ModelVisitor.object_to_json(service) | 39 | res["data"]["service"] = ModelVisitor.object_to_json(service) |
| 45 | - | 40 | + res["data"]["service"]["functions"] = functions |
| 46 | except Exception as e: | 41 | except Exception as e: |
| 47 | raise e | 42 | raise e |
| 48 | return res | 43 | return res |
| @@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
| 6 | 6 | ||
| 7 | from app.util.component.ApiTemplate import ApiTemplate | 7 | from app.util.component.ApiTemplate import ApiTemplate |
| 8 | from app.util.component.ModelVisitor import ModelVisitor | 8 | from app.util.component.ModelVisitor import ModelVisitor |
| 9 | -from .models import Service | 9 | +from .models import Service,ServiceFunction |
| 10 | from sqlalchemy import or_ | 10 | from sqlalchemy import or_ |
| 11 | 11 | ||
| 12 | 12 | ||
| @@ -48,6 +48,11 @@ class Api(ApiTemplate): | @@ -48,6 +48,11 @@ class Api(ApiTemplate): | ||
| 48 | res["data"]["count"] = services.count() | 48 | res["data"]["count"] = services.count() |
| 49 | services = services.limit(page_size).offset(page_index * page_size).all() | 49 | services = services.limit(page_size).offset(page_index * page_size).all() |
| 50 | res["data"]["list"] = ModelVisitor.objects_to_jsonarray(services) | 50 | res["data"]["list"] = ModelVisitor.objects_to_jsonarray(services) |
| 51 | + | ||
| 52 | + for service_json in res["data"]["list"]: | ||
| 53 | + service_json["functions"] = sorted(ModelVisitor.objects_to_jsonarray(ServiceFunction.query.filter_by(service_guid=service_json["guid"]).all()), | ||
| 54 | + key=lambda x:x["type"]) | ||
| 55 | + | ||
| 51 | res["result"] = True | 56 | res["result"] = True |
| 52 | 57 | ||
| 53 | 58 |
| @@ -68,10 +68,10 @@ class Api(ApiTemplate): | @@ -68,10 +68,10 @@ class Api(ApiTemplate): | ||
| 68 | "in": "formData", | 68 | "in": "formData", |
| 69 | "type": "string", | 69 | "type": "string", |
| 70 | "description": "[切片服务,影像服务]切片方案"}, | 70 | "description": "[切片服务,影像服务]切片方案"}, |
| 71 | - {"name": "function_types", | 71 | + {"name": "functions", |
| 72 | "in": "formData", | 72 | "in": "formData", |
| 73 | "type": "string", | 73 | "type": "string", |
| 74 | - "description": "[影像服务]function_types", | 74 | + "description": "[影像服务]functions", |
| 75 | "enum": ["WMS","WMTS"]}, | 75 | "enum": ["WMS","WMTS"]}, |
| 76 | 76 | ||
| 77 | # 切片参数 | 77 | # 切片参数 |
| @@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
| 5 | 5 | ||
| 6 | from app.util.component.ApiTemplate import ApiTemplate | 6 | from app.util.component.ApiTemplate import ApiTemplate |
| 7 | import uuid | 7 | import uuid |
| 8 | -from ..models import TileService,Service,db | 8 | +from ..models import TileService,Service,db,ServiceFunction |
| 9 | 9 | ||
| 10 | 10 | ||
| 11 | import datetime | 11 | import datetime |
| @@ -37,6 +37,20 @@ class Api(ApiTemplate): | @@ -37,6 +37,20 @@ class Api(ApiTemplate): | ||
| 37 | tile_update[key] = self.para.get(key) | 37 | tile_update[key] = self.para.get(key) |
| 38 | 38 | ||
| 39 | tile_service = TileService.query.filter_by(service_guid=guid) | 39 | tile_service = TileService.query.filter_by(service_guid=guid) |
| 40 | + | ||
| 41 | + tile_type = self.para.get("tile_type") | ||
| 42 | + | ||
| 43 | + # 修改功能 | ||
| 44 | + if tile_type: | ||
| 45 | + old_functions = ServiceFunction.query.filter_by(service_guid=guid).all() | ||
| 46 | + for function in old_functions: | ||
| 47 | + if not function.type.__eq__(tile_type): | ||
| 48 | + db.session.delete(function) | ||
| 49 | + | ||
| 50 | + if tile_type not in [fun.type for fun in old_functions]: | ||
| 51 | + service_function = ServiceFunction(guid=uuid.uuid1().__str__(),type=tile_type,service_guid=guid) | ||
| 52 | + db.session.add(service_function) | ||
| 53 | + | ||
| 40 | if service_update: | 54 | if service_update: |
| 41 | service.update(service_update) | 55 | service.update(service_update) |
| 42 | if tile_update: | 56 | if tile_update: |
请
注册
或
登录
后发表评论