wmts_edit.py 4.4 KB
# coding=utf-8
#author:        4N
#createtime:    2021/7/19
#email:         nheweijun@sina.com

from app.util.component.ApiTemplate import ApiTemplate
import uuid
from .models import WMTS
from app.models import Service,db

import datetime
class Api(ApiTemplate):

    api_name = "修改WMTS服务"

    def process(self):



        # 返回结果
        res = {}

        try:
            guid = self.para.get("guid")
            service = Service.query.filter_by(guid=guid)
            this_time = datetime.datetime.now()


            service_update = {"update_time":this_time}
            wmts_update = {}
            for key in self.para.keys():
                if key in ["name","title","state","description","overview","catalog_guid"]:
                    service_update[key] = self.para.get(key)
                if key in ["name","wmts_type","vendor","crs","datasource","description",
                           "layer_name","layer_alias","layer_title","layer_style","layer_format",
                           "layer_extent","layer_description","scheme_guid"]:
                    wmts_update[key] = self.para.get(key)


            wmts = WMTS.query.filter_by(guid=Service.query.filter_by(guid=guid).one_or_none().service_guid)
            if service_update:
                service.update(service_update)
            if wmts_update:
                wmts.update(wmts_update)

            db.session.commit()

            res["result"] = True
        except Exception as e:
            raise e

        return res

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

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

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

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

            # WMTS参数
            {"name": "overview",
             "in": "formData",
             "type": "string",
             "description": "[WMTS]缩略图"},
            {"name": "wmts_type",
             "in": "formData",
             "type": "string",
             "description": "[WMTS]wmts_type"},
            {"name": "vendor",
             "in": "formData",
             "type": "string",
             "description": "[WMTS]厂商"},
            {"name": "crs",
             "in": "formData",
             "type": "string",
             "description": "[WMTS]坐标系"},
            {"name": "datasource",
             "in": "formData",
             "type": "string",
             "description": "[WMTS]数据路径"},
            {"name": "layer_name",
             "in": "formData",
             "type": "string",
             "description": "[WMTS]图层名"},
            {"name": "layer_alias",
             "in": "formData",
             "type": "string",
             "description": "[WMTS]图层别名"},
            {"name": "layer_title",
             "in": "formData",
             "type": "string",
             "description": "[WMTS]图层标题"},
            {"name": "layer_style",
             "in": "formData",
             "type": "string",
             "description": "[WMTS,WMS]图层样式"},
            {"name": "layer_format",
             "in": "formData",
             "type": "string",
             "description": "[WMTS]图层format"},
            {"name": "layer_extent",
             "in": "formData",
             "type": "string",
             "description": "[WMTS]图层范围"},
            {"name": "layer_description",
             "in": "formData",
             "type": "string",
             "description": "[WMTS]图层描述"},


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