From a41d6fa0a08bdd2d19f83058f78592b448e82cec Mon Sep 17 00:00:00 2001 From: maliang Date: Wed, 8 Mar 2017 17:32:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatisplus/test/generator/MysqlGenerator.java | 63 ++++++++++------------ 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/generator/MysqlGenerator.java b/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/generator/MysqlGenerator.java index 1226210..c817871 100644 --- a/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/generator/MysqlGenerator.java +++ b/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/generator/MysqlGenerator.java @@ -39,38 +39,35 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper; * @date 2016-12-01 */ public class MysqlGenerator { - - private static void customSet(GlobalConfig gc,StrategyConfig strategy,PackageConfig pc){ + + private static void customSet(GlobalConfig gc, StrategyConfig strategy, PackageConfig pc) { gc.setOutputDir("E://mybatis-plus-generate"); - gc.setAuthor("fangcheng"); - //strategy.setInclude(new String[] { "SYS_USERS","SYS_USER_ROLE_MAPS","SYS_ROLES" }); // 需要生成的表 - strategy.setInclude(new String[] { "SYS_USERS","SYS_USER_ROLE_MAPS","SYS_ROLES" }); // 需要生成的表 -// pc.setParent("com.lyms.hospital"); + gc.setAuthor("maliang"); + // strategy.setInclude(new String[] { + // "SYS_USERS","SYS_USER_ROLE_MAPS","SYS_ROLES" }); // 需要生成的表 + strategy.setInclude(new String[] { "SYS_REGIONS", "SYS_ORGANIZATIONS", "SYS_DEPARTMENTS" }); // 需要生成的表 + // pc.setParent("com.lyms.hospital"); pc.setParent("com.lyms.cm"); - - pc.setFunctionName("sys"); //com.lyms.hospital.web.controller.sys 加在controller后面 -// pc.setModuleName("sys"); //com.lyms.hospital.sys.controller 加在controller前面 - - //以下基本不变 - pc.setServiceImpl(pc.getService()+".impl"); + + pc.setFunctionName("sys"); // com.lyms.hospital.web.controller.sys + // 加在controller后面 + // pc.setModuleName("sys"); //com.lyms.hospital.sys.controller + // 加在controller前面 + + // 以下基本不变 + pc.setServiceImpl(pc.getService() + ".impl"); pc.setMapper("dao"); pc.setXml("dao"); } - - - + @Test - public void entityWarpperTest(){ + public void entityWarpperTest() { EntityWrapper ew = new EntityWrapper(); - ew.where("name={0}", "'zhangsan'").and("id=1") - .orNew("status={0}", "0").or("status=1") - .notLike("nlike", "notvalue") - .andNew("new=xx").like("hhh", "ddd") - .andNew("pwd=11").isNotNull("n1,n2").isNull("n3") - .groupBy("x1").groupBy("x2,x3") - .having("x1=11").having("x3=433") - .orderBy("dd").orderBy("d1,d2"); - System.out.println(ew.getSqlSegment()); + ew.where("name={0}", "'zhangsan'").and("id=1").orNew("status={0}", "0").or("status=1") + .notLike("nlike", "notvalue").andNew("new=xx").like("hhh", "ddd").andNew("pwd=11").isNotNull("n1,n2") + .isNull("n3").groupBy("x1").groupBy("x2,x3").having("x1=11").having("x3=433").orderBy("dd") + .orderBy("d1,d2"); + System.out.println(ew.getSqlSegment()); } /** @@ -89,7 +86,7 @@ public class MysqlGenerator { gc.setEnableCache(false);// XML 二级缓存 gc.setBaseResultMap(true);// XML ResultMap gc.setBaseColumnList(true);// XML columList - //gc.setAuthor("Yanghu"); + // gc.setAuthor("Yanghu"); // 自定义文件命名,注意 %s 会自动填充表实体属性! // gc.setMapperName("%sDao"); @@ -110,7 +107,7 @@ public class MysqlGenerator { // 策略配置 StrategyConfig strategy = new StrategyConfig(); - //strategy.setTablePrefix("bmd_");// 此处可以修改为您的表前缀 + // strategy.setTablePrefix("bmd_");// 此处可以修改为您的表前缀 strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略 strategy.setInclude(new String[] { "user" }); // 需要生成的表 // strategy.setExclude(new String[]{"test"}); // 排除生成的表 @@ -127,7 +124,7 @@ public class MysqlGenerator { // 自定义 service 实现类父类 // strategy.setSuperServiceImplClass("com.baomidou.demo.TestServiceImpl"); // 自定义 controller 父类 - strategy.setSuperControllerClass("com.lyms.web.controller.BaseController"); + strategy.setSuperControllerClass("com.lyms.web.controller.BaseController"); // 【实体】是否生成字段常量(默认 false) // public static final String ID = "test_id"; // strategy.setEntityColumnConstant(true); @@ -139,7 +136,7 @@ public class MysqlGenerator { // 包配置 PackageConfig pc = new PackageConfig(); pc.setController("controller"); - //pc.setModuleName("test"); + // pc.setModuleName("test"); mpg.setPackageInfo(pc); // 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值 @@ -162,11 +159,9 @@ public class MysqlGenerator { // tc.setService("..."); // tc.setServiceImpl("..."); // mpg.setTemplate(tc); - - - customSet(gc,strategy,pc);//自定义,一般清空修改这个就可以了 - - + + customSet(gc, strategy, pc);// 自定义,一般清空修改这个就可以了 + // 执行生成 mpg.execute(); -- 1.8.3.1