templates.API.tpl Maven / Gradle / Ivy
<#if service.javaPackage?has_content>
<#assign package = service.javaPackage>
<#else>
<#assign package = service.packageName>
#if>
package ${package?c_lower_case};
<#if protocol == "GRPC">
import com.google.protobuf.Descriptors.FileDescriptor;
#if>
import com.tencent.trpc.core.rpc.RpcContext;
import com.tencent.trpc.core.rpc.anno.TRpcMethod;
import com.tencent.trpc.core.rpc.anno.TRpcService;
<#list service.messageTypes as name, msgType>
<#if msgType.javaPackage?has_content>
<#assign msgPackage = msgType.javaPackage>
<#else>
<#assign msgPackage = msgType.packageName>
#if>
<#if msgType.multipleClasses>
<#assign msgClass = msgType.name?cap_first>
<#elseif msgType.javaOuterClass?has_content>
<#assign msgClass = msgType.javaOuterClass + '.' + msgType.name?cap_first>
<#else>
<#assign msgClass = msgType.fallbackClassname + '.' + msgType.name?cap_first>
#if>
import ${msgPackage?c_lower_case}.${msgClass};
#list>
/**
* Generated by trpc-java-codegen
*/
@TRpcService(name = "${service.packageName}.${service.name}")
public interface ${service.interfaceNamePrefix}API {
<#if protocol == "GRPC">
<#if !service.multipleClasses && service.javaOuterClass?has_content>
<#assign serviceClass = service.javaOuterClass>
<#else>
<#assign serviceClass = service.fallbackClassname>
#if>
/**
* 用于获取pb文件描述信息
*
* @return pb文件描述信息
*/
static FileDescriptor getDescriptor() {
return ${serviceClass}.getDescriptor();
}
#if>
<#list service.methods as method>
/**
* ${method.name}
*
* @param context context
* @param request request
* @return {@link ${method.outputType.name}}
*/
@TRpcMethod(name = "${method.name}"<#if method.alias?has_content>, alias = {"${method.alias}"}#if>)
${method.outputType.name} ${method.name[0]?c_lower_case + method.name[1..]}(RpcContext context, ${method.inputType.name} request);
#list>
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy