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

templates.API.tpl Maven / Gradle / Ivy

<#if service.javaPackage?has_content>
  <#assign package = service.javaPackage>
<#else>
  <#assign package = service.packageName>

package ${package?c_lower_case};

<#if protocol == "GRPC">
import com.google.protobuf.Descriptors.FileDescriptor;

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 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>
  
import ${msgPackage?c_lower_case}.${msgClass};


/**
 * 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>
  

    /**
     * 用于获取pb文件描述信息
     *
     * @return pb文件描述信息
     */
    static FileDescriptor getDescriptor() {
        return ${serviceClass}.getDescriptor();
    }

<#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}"})
    ${method.outputType.name} ${method.name[0]?c_lower_case + method.name[1..]}(RpcContext context, ${method.inputType.name} request);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy