---
title: "4.1.7、标准RPC开放说明"
docId: "277176331404312576"
source: "https://weapp.eteams.cn/build/techdoc/wdoc/index.html#/public/repository/9c2e5f92-03b4-4207-9b22-a0c1dd79ac56/doc/277176331404312576"
---
> 原文档地址：[https://weapp.eteams.cn/build/techdoc/wdoc/index.html#/online/731994729612181505/doc/805812950950813697](https://weapp.eteams.cn/build/techdoc/wdoc/index.html#/online/731994729612181505/doc/805812950950813697)

# 模块通用接口

## 1、模块通用RPC

> 表单简化RPC接口，引入weaver-common-form-api包即可调用RPC接口，主要用于向ESB这种场景，如：本身没有对接表单但是需要获取其他模块的表单数据，以避免引入weaver-common-form-extend包

- FormDataRest 表单数据RPC
- FormFieldRest 表单字段RPC
- FormLayoutRest 表单布局RPC
- FormRest 表单RPC

### 开放表单RPC

> 模块开放示例，以业务表单为例(module为formdatareport)：
> 
> 注意继承的impl的包路径，需要是formapi.impl下，非def包下

```java

import com.weaver.common.form.api.rest.data.FormDataRest;
import com.weaver.common.form.formapi.impl.rest.FormDataRestImpl;
import org.springframework.stereotype.Service;

@Service("formdatareport_FormDataRest")
public class ReportFormDataRestImpl extends FormDataRestImpl implements FormDataRest {

}

//--------------------分割---------------------------------------------

import com.weaver.common.form.api.rest.field.FormFieldRest;
import com.weaver.common.form.formapi.impl.rest.FormFieldRestImpl;
import org.springframework.stereotype.Service;

@Service("formdatareport_FormFieldRest")
public class ReportFormFieldRest extends FormFieldRestImpl implements FormFieldRest {

}

//--------------------分割---------------------------------------------

import com.weaver.common.form.api.rest.layout.FormLayoutRest;
import com.weaver.common.form.formapi.impl.rest.FormLayoutRestImpl;
import org.springframework.stereotype.Service;

@Service("formdatareport_FormLayoutRest")
public class ReportFormLayoutRest extends FormLayoutRestImpl implements FormLayoutRest {

}

//--------------------分割---------------------------------------------

import com.weaver.common.form.api.rest.form.FormRest;
import com.weaver.common.form.formapi.impl.rest.FormRestImpl;
import org.springframework.stereotype.Service;

@Service("formdatareport_FormRest")
public class ReportFormRest extends FormRestImpl implements FormRest {

}

```

> *-dubbo.xml的配置示例，以业务表单为例(module为formdatareport):

```markdown
    <dubbo:service interface="com.weaver.common.form.api.rest.data.FormDataRest" ref="formdatareport_FormDataRest"
                   group="formdatareport"/>
    <dubbo:service interface="com.weaver.common.form.api.rest.field.FormFieldRest" ref="formdatareport_FormFieldRest"
                   group="formdatareport"/>
    <dubbo:service interface="com.weaver.common.form.api.rest.layout.FormLayoutRest" ref="formdatareport_FormLayoutRest"
                   group="formdatareport"/>
    <dubbo:service interface="com.weaver.common.form.api.rest.form.FormRest" ref="formdatareport_FormRest"
                   group="formdatareport"/> 

```

# ~~2、本地调用（接口注册)_废弃~~

> 相关设计模式：Spring织入、代理

1、伪接口使用AOP切入，会有触发两次AOP的情况

### 使用方式

> 使用@FormBizScan修饰，启动时会生成实现的代理, 接口需继承FormBizService

```java
@FormBizScan
public interface FdEffectRangeService extends FormBizService{

}

```

> 注入示例

```java
@RestController
@RequestMapping(value = {"/api/{module}/fd/effect/range","/api/{module}/{type}/fd/effect/range"})
@WeaPermission(publicPermission = true)
public class FdEffectRangeController extends FormBaseController {

    @Autowired
    private FdEffectRangeService fdEffectRangeService;

    @RequestMapping("/getWeaFormLayout")
    public WeaResult<WeaForm> getWeaFormLayout(@RequestBody FdEffectDto param){
        WeaForm weaForm = fdEffectRangeService.getWeaFormLayout(param, getCurrentUser());
        return WeaResult.success(weaForm);
    }
}


```

### 对接方式

```java
@Service
public interface WorkflowFdEffectRangeService implements FdEffectRangeService{
    // 逻辑省略
}

```

### 使用约定

> 1、约定复写的接口，第一个参数必有FormBeanParam，且必有module参数
> 
> 2、业务模块复写接口的@Service的value要按照约定填写，module+接口名称，如下：
> 
> 正例：【"formdatareportFdLinkageEventService"，"workflowFdLinkageEventService"】
> 
> 反例：【"formdatareport_FdLinkageEventService"，"formdatareportFormBizService"】
> 
> 3、默认实现需要为serviceName+Impl
> 
> 正例: FdEffectRangeService -> 【"FdEffectRangeServiceImpl"】
> 
> 反例: FdEffectRangeService -> 【"CommonFdEffectRangeServiceImpl"】
