P3OneToMainUtil.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package test.p3;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import org.jeecgframework.p3.cg.factory.CodeGenerateFactoryOneToMany;
  5. import org.jeecgframework.p3.cg.pojo.onetomany.CodeParamEntity;
  6. import org.jeecgframework.p3.cg.pojo.onetomany.SubTableEntity;
  7. /**
  8. * 代码生成器入口【一对多】
  9. * @author 张代浩
  10. * @site www.jeecg.org
  11. *
  12. */
  13. public class P3OneToMainUtil {
  14. /**
  15. * 一对多(父子表)数据模型,生成方法
  16. * @param args
  17. */
  18. public static void main(String[] args) {
  19. //第一步:设置主表配置
  20. CodeParamEntity codeParamEntityIn = new CodeParamEntity();
  21. codeParamEntityIn.setTableName("jeecg_order_main");//主表名
  22. codeParamEntityIn.setEntityName("Order"); //实体名
  23. codeParamEntityIn.setFtlDescription("订单"); //描述
  24. //第二步:设置子表集合配置
  25. List<SubTableEntity> subTabParamIn = new ArrayList<SubTableEntity>();
  26. //[1].子表一
  27. SubTableEntity po = new SubTableEntity();
  28. po.setTableName("jeecg_order_custom");//子表名
  29. po.setEntityName("Custom"); //实体名
  30. po.setEntityPackage("test"); //包名
  31. po.setFtlDescription("客户明细"); //描述
  32. //子表外键参数配置
  33. po.setForeignKey("go_order_code");//子表外键
  34. po.setMainForeignKey("go_order_code");//对应的主表字段
  35. subTabParamIn.add(po);
  36. //[2].子表二
  37. SubTableEntity po2 = new SubTableEntity();
  38. po2.setTableName("jeecg_order_product"); //子表名
  39. po2.setEntityName("Product"); //实体名
  40. po2.setEntityPackage("test"); //包名
  41. po2.setFtlDescription("产品明细"); //描述
  42. //子表外键参数配置
  43. po2.setForeignKey("go_order_code");//子表外键
  44. po2.setMainForeignKey("go_order_code");//对应的主表字段
  45. subTabParamIn.add(po2);
  46. codeParamEntityIn.setSubTabParam(subTabParamIn);
  47. //第三步:一对多(父子表)数据模型,代码生成
  48. CodeGenerateFactoryOneToMany.oneToManyCreate(codeParamEntityIn,subTabParamIn);
  49. }
  50. }