clientTemplate.vm 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. package com.miniframe.generate.comm.$tools.toLower($!map.get("apater"));
  2. import com.miniframe.spring.httpclient.MFHttpRespInfo;
  3. import org.slf4j.Logger;
  4. import org.slf4j.LoggerFactory;
  5. import java.util.LinkedHashMap;
  6. import java.util.Map;
  7. import com.miniframe.core.Transmitter;
  8. import com.miniframe.core.ext.UtilTools;
  9. #set($packAge1="com.miniframe.generate.comm."+$!map.get("code")+".D_"+$tools.toUpper($!map.get("交易编码")))
  10. #set($packAge2="com.miniframe.generate.comm."+$!map.get("code")+".D_"+$tools.toUpper($!map.get("head")))
  11. import $packAge1;
  12. import $packAge2;
  13. #set($packAgeBaseModel="com.miniframe.generate.business."+$!map.get("code")+".model."+$tools.toUpper($!map.get("交易编码"))+"BaseModel;")
  14. import $packAgeBaseModel
  15. public class $tools.toUpper($!map.get("交易编码"))Client {
  16. #set($log=$tools.toUpper($!map.get("交易编码"))+"Client.class")
  17. private static final Logger logger = LoggerFactory.getLogger($log);
  18. private MFHttpRespInfo respInfo;
  19. public MFHttpRespInfo getRespInfo(){
  20. return respInfo;
  21. }
  22. /**
  23. * 调用 [$!map.get("name")->$!map.get("交易名称")(($!map.get("交易编码"))]的通讯接口
  24. * @param model 接口模型
  25. * @param extMap 扩展输入
  26. * @param url 请求地址
  27. * @return model 接口模型
  28. * @throws Exception
  29. */
  30. @SuppressWarnings({ "rawtypes", "unchecked" })
  31. public $tools.toUpper($!map.get("交易编码"))BaseModel execute($tools.toUpper($!map.get("交易编码"))BaseModel model,final Map extMap,final String url) throws Exception {
  32. this.executeToRespInfo(model,extMap,url);
  33. return model;
  34. }
  35. @SuppressWarnings({ "rawtypes", "unchecked" })
  36. public $tools.toUpper($!map.get("交易编码"))BaseModel execute($tools.toUpper($!map.get("交易编码"))BaseModel model,final Map extMap) throws Exception {
  37. this.executeToRespInfo(model,extMap,null);
  38. return model;
  39. }
  40. @SuppressWarnings({ "rawtypes", "unchecked" })
  41. public MFHttpRespInfo executeToRespInfo($tools.toUpper($!map.get("交易编码"))BaseModel model,final Map extMap,final String url) throws Exception {
  42. if (logger.isDebugEnabled()) {
  43. logger.debug("execute($tools.toUpper($!map.get("交易编码"))BaseModel) - start");
  44. }
  45. if(UtilTools.isNullOrBlank(model.getA_$tools.toLower($!map.get("head"))().getTransCode())){
  46. model.getA_$tools.toLower($!map.get("head"))().setTransCode("$tools.toUpper($!map.get("交易编码"))");
  47. }
  48. Map inMap = new LinkedHashMap();
  49. inMap.putAll(UtilTools.obj2Map(model.getA_$tools.toLower($!map.get("head"))()));
  50. inMap.putAll(UtilTools.obj2Map(model.getA_$tools.toLower($!map.get("交易编码"))()));
  51. #set($temp0=""+$!map.get("apater")+".doPostDataToRespInfo(inMap)")
  52. #set($temp01=""+$!map.get("apater")+".doPostDataToRespInfo(inMap,url)")
  53. if(extMap!=null && extMap.size()>0){
  54. inMap.putAll(extMap);
  55. }
  56. Transmitter $!map.get("apater") = (Transmitter) UtilTools.getBean("$!map.get("apater")");
  57. MFHttpRespInfo respInfo;
  58. if(UtilTools.isNotNullAndBlank(url)){
  59. respInfo = $temp01;
  60. }else{
  61. respInfo = $temp0;
  62. }
  63. if(respInfo!=null) {
  64. Map outMap=respInfo.getParamMap();
  65. #set($d_head="D_"+$tools.toUpper($!map.get("head"))+" d_"+ $tools.toLower($!map.get("head"))+" = UtilTools.map2Obj(outMap, D_"+$tools.toUpper($!map.get("head"))+".class);")
  66. $d_head
  67. #set($d_body="D_"+$tools.toUpper($!map.get("交易编码"))+" d_"+ $tools.toLower($!map.get("交易编码"))+" = UtilTools.map2Obj(outMap, D_"+$tools.toUpper($!map.get("交易编码"))+".class);")
  68. $d_body
  69. model.setD_$tools.toLower($!map.get("head"))(d_$tools.toLower($!map.get("head")));
  70. model.setD_$tools.toLower($!map.get("交易编码"))(d_$tools.toLower($!map.get("交易编码")));
  71. }
  72. if (logger.isDebugEnabled()) {
  73. logger.debug("execute($tools.toUpper($!map.get("交易编码"))BaseModel) - end");
  74. }
  75. this.respInfo=respInfo;
  76. return respInfo;
  77. }
  78. @SuppressWarnings({ "rawtypes", "unchecked" })
  79. public $tools.toUpper($!map.get("交易编码"))BaseModel execute($tools.toUpper($!map.get("交易编码"))BaseModel model) throws Exception {
  80. return this.execute(model,null,null);
  81. }
  82. }