All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.loli.service.html.ServiceHtml.kt Maven / Gradle / Ivy

package org.loli.service.html

import org.loli.base.RpcCall
import org.loli.html.CssUtil
import org.loli.html.HtmlUtil
import org.loli.json.RpcJsonPropNames
import org.loli.service.RpcConf
import org.loli.util.RpcAnnotationUtil

/**
 * 服务的html信息
 */
internal object ServiceHtml {
    /**
     * 根据服务名称,得到html信息
     * @param serviceName 服务名
     * @param conf 配置
     * @return html信息
     */
    fun getHtml(serviceName: String, conf: RpcConf): String {
        if(serviceName != conf.service){
            return "服务名不匹配,要求$serviceName,实际${conf.service}"
        }

        val buf = StringBuilder()
        buf.append(
            """
            
            ${CssUtil.CSS_TABLE}
            $serviceName 服务信息
            
                """.trimIndent()
        )

        appendServiceHtml(buf, serviceName, conf.description, conf.version)

        buf.append(
            """
            

""".trimIndent() ) // 服务列表 val services = RpcCall.getAllClass() for ((className, clsDef) in services) { buf.append( """ """.trimIndent() ) } buf.append("
类名 描述 定义
$className ${HtmlUtil.escape(RpcAnnotationUtil.getDesc(clsDef))} ${clsDef.qualifiedName}
") return buf.toString() } /** * 添加服务对应的html */ fun appendServiceHtml(buf: StringBuilder, serviceName: String, description: String, version: Int){ buf.append( """
服务名 描述 版本
$serviceName ${HtmlUtil.escape(description)} $version

""".trimIndent() ) } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy