接口:
![13265172-c65ba7152fbd8752.png](https://i-blog.csdnimg.cn/blog_migrate/157c3cb938c67646ba618b6ee79278c7.webp?x-image-process=image/format,png)
image.png
public interface IOra20796StudentRestService extends IBaseService<Ora20796Student>, ProxySelf<IOra20796StudentService> {
public ResponseData intgAction(IRequest requestContext, Ora20796Student dto) throws Exception;
}
实现接口:
package wht.ora20796.service.impl;
import com.hand.hap.core.IRequest;
import com.hand.hap.intergration.dto.HapInterfaceHeader;
import com.hand.hap.intergration.service.IHapApiService;
import com.hand.hap.intergration.service.IHapInterfaceHeaderService;
import com.hand.hap.intergration.service.impl.HapRestApiServiceImpl;
import com.hand.hap.system.dto.ResponseData;
import com.hand.hap.system.service.impl.BaseServiceImpl;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import wht.ora20796.dto.Ora20796Student;
import wht.ora20796.service.IOra20796StudentRestService;
import wht.ora20796.service.IOra20796StudentService;
import javax.annotation.Resource;
public class Ora20796RestApiServiceImpl extends BaseServiceImpl<Ora20796Student> implements IOra20796StudentRestService {
@Autowired
private IHapInterfaceHeaderService headerService;
@Resource(name = "restBean")
private IHapApiService restService;
@Override
public ResponseData intgAction(IRequest requestContext, Ora20796Student dto) throws Exception {
ResponseData responseData = new ResponseData();
JSONObject Response_Json;
JSONObject jsonObj;
try {
jsonObj = JSONObject.fromObject(dto);
System.out.println("返回报文:" + jsonObj.toString());
//RestApiTest1--系统代码,REST--接口代码
HapInterfaceHeader hapInterfaceHeader = this.headerService
.getHeaderAndLine("RestApiTest1", "REST");
Response_Json = this.restService.invoke(hapInterfaceHeader, jsonObj);
if (Response_Json != null) {
System.out.println("返回报文:" + Response_Json.toString());
responseData.setMessage(Response_Json.toString());
}
} catch (Exception e) {
throw e;
}
return responseData;
}
}