service_register.py 6.6 KB
# coding=utf-8
#author:        4N
#createtime:    2021/9/14
#email:         nheweijun@sina.com

from app.util.component.ApiTemplate import ApiTemplate
from .models import Service
class Api(ApiTemplate):
    api_name = "注册服务"
    def process(self):
        res = {}
        try:

            service = Service.query.filter_by(name=self.para.get("name")).one_or_none()
            if service:
                raise Exception("服务已存在!")
            if self.para.get("type").__eq__("影像服务"):
                from app.modules.service.image.image_service_register import Api as RealApi
            elif self.para.get("type").__eq__("地图服务"):
                from app.modules.service.map_service.map_service_register import Api as RealApi
            elif self.para.get("type").__eq__("切片服务"):
                from app.modules.service.tile_service.tile_service_register import Api as RealApi
            else:
                return res
            api = RealApi()
            api.para = self.para
            res = api.process()
        except Exception as e:
            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": "image_guids",
             "in": "formData",
             "type": "string",
             "description": "[影像服务]影像guids,以英文逗号相隔"},
            {"name": "scheme_guid",
             "in": "formData",
             "type": "string",
             "description": "[切片服务,影像服务]切片方案"},

            {"name": "scheme_guid",
             "in": "formData",
             "type": "string",
             "description": "[切片服务,影像服务]切片方案"},

            {"name": "functions",
             "in": "formData",
             "type": "string",
             "description": "[影像服务]functions",
             "enum": ["WMS","WMTS"]},

            # 切片参数
            {"name": "overview",
             "in": "formData",
             "type": "string",
             "description": "[切片服务]缩略图"},
            {"name": "tile_type",
             "in": "formData",
             "type": "string",
             "description": "[切片服务]tile_type",
             "enum":["WMTS","TMS"]},
            {"name": "vendor",
             "in": "formData",
             "type": "string",
             "description": "[切片服务]厂商"},
            {"name": "crs",
             "in": "formData",
             "type": "string",
             "description": "[切片服务]坐标系"},
            {"name": "datasource",
             "in": "formData",
             "type": "string",
             "description": "[切片服务]数据路径"},
            {"name": "layer_name",
             "in": "formData",
             "type": "string",
             "description": "[切片服务]图层名"},
            {"name": "layer_alias",
             "in": "formData",
             "type": "string",
             "description": "[切片服务]图层别名"},
            {"name": "layer_title",
             "in": "formData",
             "type": "string",
             "description": "[切片服务]图层标题"},
            {"name": "layer_style",
             "in": "formData",
             "type": "string",
             "description": "[切片服务,地图服务]图层样式"},
            {"name": "layer_format",
             "in": "formData",
             "type": "string",
             "description": "[切片服务]图层format"},
            {"name": "layer_extent",
             "in": "formData",
             "type": "string",
             "description": "[切片服务]图层范围"},
            {"name": "layer_description",
             "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"},

        ],
        "responses": {
            200: {
                "schema": {
                    "properties": {
                    }
                }
            }
        }
    }