
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(
"""
$className
${HtmlUtil.escape(RpcAnnotationUtil.getDesc(clsDef))}
${clsDef.qualifiedName}
""".trimIndent()
)
}
buf.append("