Commit a41d6fa0a08bdd2d19f83058f78592b448e82cec

Authored by maliang
1 parent 5701e4bca6
Exists in master

修改信息

Showing 1 changed file with 29 additions and 34 deletions

mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/generator/MysqlGenerator.java View file @ a41d6fa
... ... @@ -39,38 +39,35 @@
39 39 * @date 2016-12-01
40 40 */
41 41 public class MysqlGenerator {
42   -
43   - private static void customSet(GlobalConfig gc,StrategyConfig strategy,PackageConfig pc){
  42 +
  43 + private static void customSet(GlobalConfig gc, StrategyConfig strategy, PackageConfig pc) {
44 44 gc.setOutputDir("E://mybatis-plus-generate");
45   - gc.setAuthor("fangcheng");
46   - //strategy.setInclude(new String[] { "SYS_USERS","SYS_USER_ROLE_MAPS","SYS_ROLES" }); // 需要生成的表
47   - strategy.setInclude(new String[] { "SYS_USERS","SYS_USER_ROLE_MAPS","SYS_ROLES" }); // 需要生成的表
48   -// pc.setParent("com.lyms.hospital");
  45 + gc.setAuthor("maliang");
  46 + // strategy.setInclude(new String[] {
  47 + // "SYS_USERS","SYS_USER_ROLE_MAPS","SYS_ROLES" }); // 需要生成的表
  48 + strategy.setInclude(new String[] { "SYS_REGIONS", "SYS_ORGANIZATIONS", "SYS_DEPARTMENTS" }); // 需要生成的表
  49 + // pc.setParent("com.lyms.hospital");
49 50 pc.setParent("com.lyms.cm");
50   -
51   - pc.setFunctionName("sys"); //com.lyms.hospital.web.controller.sys 加在controller后面
52   -// pc.setModuleName("sys"); //com.lyms.hospital.sys.controller 加在controller前面
53   -
54   - //以下基本不变
55   - pc.setServiceImpl(pc.getService()+".impl");
  51 +
  52 + pc.setFunctionName("sys"); // com.lyms.hospital.web.controller.sys
  53 + // 加在controller后面
  54 + // pc.setModuleName("sys"); //com.lyms.hospital.sys.controller
  55 + // 加在controller前面
  56 +
  57 + // 以下基本不变
  58 + pc.setServiceImpl(pc.getService() + ".impl");
56 59 pc.setMapper("dao");
57 60 pc.setXml("dao");
58 61 }
59   -
60   -
61   -
  62 +
62 63 @Test
63   - public void entityWarpperTest(){
  64 + public void entityWarpperTest() {
64 65 EntityWrapper<Object> ew = new EntityWrapper<Object>();
65   - ew.where("name={0}", "'zhangsan'").and("id=1")
66   - .orNew("status={0}", "0").or("status=1")
67   - .notLike("nlike", "notvalue")
68   - .andNew("new=xx").like("hhh", "ddd")
69   - .andNew("pwd=11").isNotNull("n1,n2").isNull("n3")
70   - .groupBy("x1").groupBy("x2,x3")
71   - .having("x1=11").having("x3=433")
72   - .orderBy("dd").orderBy("d1,d2");
73   - System.out.println(ew.getSqlSegment());
  66 + ew.where("name={0}", "'zhangsan'").and("id=1").orNew("status={0}", "0").or("status=1")
  67 + .notLike("nlike", "notvalue").andNew("new=xx").like("hhh", "ddd").andNew("pwd=11").isNotNull("n1,n2")
  68 + .isNull("n3").groupBy("x1").groupBy("x2,x3").having("x1=11").having("x3=433").orderBy("dd")
  69 + .orderBy("d1,d2");
  70 + System.out.println(ew.getSqlSegment());
74 71 }
75 72  
76 73 /**
... ... @@ -89,7 +86,7 @@
89 86 gc.setEnableCache(false);// XML 二级缓存
90 87 gc.setBaseResultMap(true);// XML ResultMap
91 88 gc.setBaseColumnList(true);// XML columList
92   - //gc.setAuthor("Yanghu");
  89 + // gc.setAuthor("Yanghu");
93 90  
94 91 // 自定义文件命名,注意 %s 会自动填充表实体属性!
95 92 // gc.setMapperName("%sDao");
... ... @@ -110,7 +107,7 @@
110 107  
111 108 // 策略配置
112 109 StrategyConfig strategy = new StrategyConfig();
113   - //strategy.setTablePrefix("bmd_");// 此处可以修改为您的表前缀
  110 + // strategy.setTablePrefix("bmd_");// 此处可以修改为您的表前缀
114 111 strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
115 112 strategy.setInclude(new String[] { "user" }); // 需要生成的表
116 113 // strategy.setExclude(new String[]{"test"}); // 排除生成的表
... ... @@ -127,7 +124,7 @@
127 124 // 自定义 service 实现类父类
128 125 // strategy.setSuperServiceImplClass("com.baomidou.demo.TestServiceImpl");
129 126 // 自定义 controller 父类
130   - strategy.setSuperControllerClass("com.lyms.web.controller.BaseController");
  127 + strategy.setSuperControllerClass("com.lyms.web.controller.BaseController");
131 128 // 【实体】是否生成字段常量(默认 false)
132 129 // public static final String ID = "test_id";
133 130 // strategy.setEntityColumnConstant(true);
... ... @@ -139,7 +136,7 @@
139 136 // 包配置
140 137 PackageConfig pc = new PackageConfig();
141 138 pc.setController("controller");
142   - //pc.setModuleName("test");
  139 + // pc.setModuleName("test");
143 140 mpg.setPackageInfo(pc);
144 141  
145 142 // 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值
... ... @@ -162,11 +159,9 @@
162 159 // tc.setService("...");
163 160 // tc.setServiceImpl("...");
164 161 // mpg.setTemplate(tc);
165   -
166   -
167   - customSet(gc,strategy,pc);//自定义,一般清空修改这个就可以了
168   -
169   -
  162 +
  163 + customSet(gc, strategy, pc);// 自定义,一般清空修改这个就可以了
  164 +
170 165 // 执行生成
171 166 mpg.execute();
172 167