wms_register.py 5.3 KB
# 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 WMS
from app.models import Service,db
import datetime
import configure
class Api(ApiTemplate):

    api_name = "注册WMTS服务"

    def process(self):
        # 返回结果
        res = {}

        try:

            this_time = datetime.datetime.now()
            service_guid = uuid.uuid1().__str__()
            wms_service_guid = uuid.uuid1().__str__()


            #调用wms服务发布接口

            service = Service(
                guid = service_guid,
                name = self.para.get("name"),
                alias = self.para.get("alias"),
                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"),
                service_guid = wms_service_guid,
                catalog_guid = self.para.get("catalog_guid")
            )

            wms = WMS(
                guid = wms_service_guid,
                service = 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
            )


            db.session.add(service)
            db.session.add(wms)
            db.session.commit()
            res["data"] = service_guid
            res["result"] = True
        except Exception as e:
            db.session.rollback()
            raise e
        return res

    api_doc = {
        "tags": ["WMTS接口"],
        "parameters": [

            {"name": "name",
             "in": "formData",
             "type": "string",
             "required": "true",
             "description": "[WMS,WMTS,影像WMS,影像WMTS]"},
            {"name": "alias",
             "in": "formData",
             "type": "string",
             "description": "[WMS,WMTS,影像WMS,影像WMTS]"},
            {"name": "description",
             "in": "formData",
             "type": "string",
             "description": "[WMS,WMTS,影像WMS,影像WMTS]"},
            {"name": "type",
             "in": "formData",
             "type": "string",
             "enum": ["WMS", "WMTS", "影像WMS", "影像WMTS"],
             "required": "true",
             "description": "[WMS,WMTS,影像WMS,影像WMTS]"},
            {"name": "catalog_guid",
             "in": "formData",
             "type": "string",
             "description": "[WMS,WMTS,影像WMS,影像WMTS]"},

            {"name": "catalog_guid",
             "in": "formData",
             "type": "string",
             "description": "[WMS,WMTS,影像WMS,影像WMTS]"},

            {"name": "status",
             "in": "formData",
             "type": "string",
             "description": "[WMS]status"},
            {"name": "username",
             "in": "formData",
             "type": "string",
             "description": "[WMS]username"},
            {"name": "readonly",
             "in": "formData",
             "type": "string",
             "description": "[WMS]readonly"},
            {"name": "sid",
             "in": "formData",
             "type": "string",
             "description": "[WMS]sid"},
            {"name": "stype",
             "in": "formData",
             "type": "string",
             "description": "[WMS]stype"},
            {"name": "ssupply",
             "in": "formData",
             "type": "string",
             "description": "[WMS]ssupply"},
            {"name": "sctime",
             "in": "formData",
             "type": "string",
             "description": "[WMS]sctime"},
            {"name": "company",
             "in": "formData",
             "type": "string",
             "description": "[WMS]company"},
            {"name": "abstract",
             "in": "formData",
             "type": "string",
             "description": "[WMS]abstract"},
            {"name": "thumbnail",
             "in": "formData",
             "type": "string",
             "description": "[WMS]thumbnail"},
            {"name": "layer_style",
             "in": "formData",
             "type": "string",
             "description": "[WMS,WMTS]layer_style"},

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