<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>${appdoc.appName}接口说明文档</title>
    <link href="/api/bootstrap.min.css" rel="stylesheet">
    <!--<link href="https://cdn.bootcss.com/highlight.js/9.12.0/styles/default.min.css" rel="stylesheet">-->
    <link href="https://cdn.staticfile.org/prettify/r298/prettify.min.css" rel="stylesheet">
    <script src="/api/jquery.min.js"></script>
    <script src="/api/bootstrap.min.js"></script>
    <!--<script src="https://cdn.bootcss.com/highlight.js/9.12.0/highlight.min.js"></script>-->
    <script src="https://cdn.staticfile.org/prettify/r298/prettify.min.js"></script>
    <style type="text/css">
        body {
            padding-top: 50px;
        }

        .sub-header {
            padding-bottom: 10px;
            border-bottom: 1px solid #eee;
        }

        /*
         * Top navigation
         * Hide default border to remove 1px line.
         */
        .navbar-fixed-top {
            border: 0;
        }

        /*
         * Sidebar
         */

        /* Hide for mobile, show later */
        .sidebar {
            display: none;
        }

        @media (min-width: 768px) {
            .sidebar {
                position: fixed;
                top: 51px;
                bottom: 0;
                left: 0;
                z-index: 1000;
                display: block;
                padding: 20px;
                overflow-x: hidden;
                overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
                background-color: #f5f5f5;
                border-right: 1px solid #eee;
            }
        }

        /* Sidebar navigation */
        .nav-sidebar {
            margin-right: 5px; /* 20px padding + 1px border */
            margin-bottom: 20px;
            margin-left: 5px;
            margin-top: 5px;
        }

        .nav-sidebar > li > a {
            padding-right: 20px;
            padding-left: 20px;
        }

        .nav-sidebar > .active > a,
        .nav-sidebar > .active > a:hover,
        .nav-sidebar > .active > a:focus {
            color: #fff;
            background-color: #428bca;
        }

        /*
         * Main content
         */

        .main {
            padding: 20px;
        }

        @media (min-width: 768px) {
            .main {
                padding-right: 40px;
                padding-left: 40px;
            }
        }

        .main .page-header {
            margin-top: 0;
        }

        /*
         * Placeholder dashboard ideas
         */

        .placeholders {
            margin-bottom: 30px;
            text-align: center;
        }

        .placeholders h4 {
            margin-bottom: 0;
        }

        .placeholder {
            margin-bottom: 20px;
        }

        .placeholder img {
            display: inline-block;
            border-radius: 50%;
        }

        .linenums li {
            list-style-type: decimal !important;
        }
    </style>

    <!--<script>hljs.initHighlightingOnLoad();</script>-->
</head>
<body onload="prettyPrint()">
<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">${appdoc.appName}接口说明文档</a>
        </div>
    </div>
</nav>
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
            <%
            var panelModuleHeadId;
            var panelModuleHeadIndex = 0;
            var panelModuleCollapseId;
            var panelModuleCollapseIndex = 0;
            var moduleList = appdoc.moduleList;
            var moduleLeftIndex = 0;
            for (appmodule in moduleList) {
            panelModuleHeadId = "panelModuleHead" + panelModuleHeadIndex;
            panelModuleCollapseId = "panelModuleCollapse" + panelModuleHeadIndex;
            %>
            <div class="panel-group" role="tablist">
                <div class="panel panel-default">
                    <div class="panel-heading" role="tab" id="${panelModuleHeadId}">
                        <h4 class="panel-title">
                            <a class="" role="button" data-toggle="collapse" href="#${panelModuleCollapseId}"
                               aria-expanded="false" aria-controls="${panelModuleCollapseId}">
                                ${appmodule.moduleName}
                                <span class="badge">${appmodule.methodList.~size}</span>
                            </a>
                        </h4>
                    </div>
                    <div id="${panelModuleCollapseId}" class="panel-collapse collapse in" role="tabpanel"
                         aria-labelledby="${panelModuleHeadId}" aria-expanded="false" style="">
                        <ul class="nav nav-sidebar">
                            <%
                            var methodList = appmodule.methodList;
                            var methodLeftIndex = 0;
                            for (appmethod in methodList) {
                            %>
                            <li><a href="#" moduleindex="${moduleLeftIndex}" methodindex="${methodLeftIndex}"
                                   onclick="viewMethodDetail(this)">${appmethod.methodName}</a></li>
                            <%
                            methodLeftIndex++;
                            }
                            %>
                        </ul>
                    </div>
                </div>
            </div>
            <%
            moduleLeftIndex++;
            panelModuleHeadIndex++;
            panelModuleHeadIndex++;
            }
            %>


        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <h1 class="page-header">函数说明</h1>
            <%
            var moduleIndex = 0;
            //var moduleList = appdoc.moduleList;
            for (appmodule in moduleList) {
            var methodList = appmodule.methodList;
            var methodIndex = 0;
            for (appmethod in methodList) {
            var moduleMethodPanelGroupId = "viewModuleMethodPanel-" + moduleIndex + "-" + methodIndex;
            %>
            <div class="panel panel-default" id="${moduleMethodPanelGroupId}" style="display: none;">
                <div class="panel-heading">
                    <h4 class="panel-title">
                        ${appmethod.methodName} <% if (appmethod.callFlag == 1) { %> (Call InvokeCallParams方法) <% } %>
                    </h4>
                </div>
                <div class="panel-body">
                    <p><h4><span class="label label-primary">接口地址：${appmethod.url}</span></h4></p>
                    <p><h4><span class="label label-success">调用方法：${appmethod.supportMethods}</span></h4></p>
                    <p><h4><span class="label label-info">接口返回：${appmethod.result}</span></h4></p>
                    <p><h4><span class="label label-warning">是否鉴权：${appmethod.auth}</span></h4></p>
                    <p><h4><span class="label label-default">参数<span
                        class="badge">${appmethod.paramList.~size}</span></span></h4></p>
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th>参数名称</th>
                                <th>参数描述</th>
                                <th>参数类型</th>
                                <th>来源</th>
                                <th>是否必须</th>
                            </tr>
                            </thead>
                            <tbody>
                            <%
                            for (methodParam in appmethod.paramList) {
                            %>
                            <tr>
                                <td>${methodParam.paramName}</td>
                                <td>${methodParam.paramComment}</td>
                                <td>${methodParam.paramType}</td>
                                <td>${methodParam.paramSrc}</td>
                                <td>${methodParam.paramRequired}</td>
                            </tr>
                            <%
                            }
                            %>


                            </tbody>
                        </table>
                    </div>

                    <p><h4><span class="label label-success">参数params的json说明</span></h4></p>
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th>参数名称</th>
                                <th>参数描述</th>
                                <th>参数类型</th>
                                <th>来源</th>
                                <th>是否必须</th>
                            </tr>
                            </thead>
                            <tbody>
                            <%
                            for (callParam in appmethod.callParamList) {
                            %>
                            <tr>
                                <td>${callParam.paramName}</td>
                                <td>${callParam.paramComment}</td>
                                <td>${callParam.paramType}</td>
                                <td>${callParam.paramSrc}</td>
                                <td>${callParam.paramRequired}</td>
                            </tr>
                            <%
                            }
                            %>


                            </tbody>
                        </table>
                    </div>


                    <p><h4><span class="label label-default">示例代码【apis表示nginx的反向代理路径，按配置替换；如果函数返回的直接字符串，请修改datatype为String、Script、XML等】</span></h4></p>
                    <!--<div class="table-responsive">-->
                                <pre class="prettyprint linenums">
<%
    for (demo in appmethod.demoJquery) {
    %>
${demo}
    <%
    }
    %>
                                   </pre>
                    <p><h4><span class="label label-default">类型<span
                        class="badge">${appmethod.classList.~size}</span></span></h4></p>
                    <%
                    for (methodClass in appmethod.classList) {
                    %>
                    <p><h4><span class="label label-danger">${methodClass.className}<% if (methodClass.result) { %><b>[返回对象]</b><% } %><b>[蓝色表示此接口需要的属性]</b></span></h4></p>
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th>属性名称</th>
                                <th>属性描述</th>
                                <th>服务接口</th>
                            </tr>
                            </thead>
                            <tbody>
                            <%
                            for (field in methodClass.classField) {
                            %>
                            <tr>
                                <%
                                if (field.fieldCurrent == 1) {
                                %>
                                <td class="text-primary">
                                    <b>${field.fieldName}</b>
                                    <% } else { %>
                                <td>
                                    ${field.fieldName}
                                    <% } %>
                                </td>
                                <td>
                                    ${field.fieldComment}
                                </td>
                                <td>
                                    <%
                                    for (place in field.fieldPlace) {
                                    %>
                                    ${place}
                                    <br>
                                    <%
                                    }
                                    %>
                                </td>
                            </tr>
                            <%
                            }
                            %>


                            </tbody>
                        </table>
                    </div>
                    <%
                    }
                    %>
                </div>
            </div>
            <%
            methodIndex++;
            }
            moduleIndex++;
            }
            %>
        </div>
    </div>
</div>

<script>
    function viewMethodDetail(e) {
        var moduleIndex = $(e).attr("moduleindex");
        var methodIndex = $(e).attr("methodindex");
        var methodDoc = "viewModuleMethodPanel-" + moduleIndex + "-" + methodIndex;
        var $methodPanel = $("#" + methodDoc);
        $methodPanel.siblings(".panel").hide();
        $methodPanel.show();
    }
</script>
</body>
</html>
