1.接口关系
2. 代码实例
1. 顶层接口(定义两层)
--第一层
public interface IOpenApiInterface<S extends OpenApiRequest, D extends OpenApiResponse, U extends OpenApiUserVO> {
@PostMapping({"/execute"})
RestResponse<D> execute(@RequestBody OpenApiPackage<S, U> var1) throws SystemException;
}
-- 第二层
public interface IFccApiInterface<S extends FccApiRequest, D extends FccApiResponse> extends IOpenApiInterface<S, D, FccApiUserVO> {
}
2.业务抽象接口(具体的接口方法,入参,出参)
@RestController
@RequestMapping({"/fccapi/test"})
public interface FccxxService extends IFccApiInterface<FccHotelOrderCheckSmlrtyRequest,FccHotelOrderCheckSmlrtyResponse> {
}
3.实现类
@RestController
public class FccxxServiceImpl implements FccxxService{
@Override
public RestResponse<FccHotelOrderCheckSmlrtyResponse> execute(@RequestBody OpenApiPackage<FccHotelOrderCheckSmlrtyRequest,FccApiUserVO> openApiPackage) throws SystemException {
RestResponse<FccHotelOrderCheckSmlrtyResponse> response=new RestResponse<FccHotelOrderCheckSmlrtyResponse>();
return response;
}
}
3. 代码设计,要从以下几个方面着手 ? ? ? ?清晰表达 ? ? ? ?分离关注点 ? ? ? ?统一抽象 ? ? ? ?消除重复
|