mybatis-generator-extend修改测试完毕

This commit is contained in:
lsy
2017-12-02 20:27:12 +08:00
parent 3e045b578f
commit 37ee1bd3ed
11 changed files with 485 additions and 148 deletions
@@ -1,50 +1,42 @@
package com.micro.fast.mybatis.generator.extend.mojo;
import com.micro.fast.mybatis.generator.extend.service.MybatisGeneratorExtend;
import com.micro.fast.mybatis.generator.extend.util.FreemarkerUtil;
import com.micro.fast.mybatis.generator.extend.util.JarUtil;
import com.micro.fast.mybatis.generator.extend.util.PropertiesUtil;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
@Mojo(name = "generateFiles")
public class MyabtisGeneratorExtendMojo extends AbstractMojo {
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
//获取当前项目jar包的路径
String path = MyabtisGeneratorExtendMojo.class.getProtectionDomain().getCodeSource().getLocation().getPath();
JarInputStream jarInputStream =null;
try {
jarInputStream = new JarInputStream(new FileInputStream(new File(path)));
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
jarInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
InputStream templates = this.getClass().getClassLoader().getResourceAsStream("templates");
System.out.println(path);
String projectPath =null;
Map pluginContext = getPluginContext();
Set set = pluginContext.entrySet();
Iterator iterator = set.iterator();
while (iterator.hasNext()){
Object next = iterator.next();
System.out.println("---++++++++++++++++++++"+next);
System.out.println(pluginContext.get(next)+"++++++++++++++++++++++++");
String s = next.toString();
String[] split = s.split(" ");
for (String s1 : split) {
if (s1.endsWith("pom.xml")){
int lastIndexOf = s1.lastIndexOf("pom.xml");
projectPath = s1.substring(0,lastIndexOf-1);
}
}
}
new PropertiesUtil().loadProperties(projectPath);
MybatisGeneratorExtend.GenerateMybatisGeneratorNeedFilesByTemplates(projectPath);
}
}
@@ -4,8 +4,10 @@ import com.micro.fast.mybatis.generator.extend.db.JdbcConnection;
import com.micro.fast.mybatis.generator.extend.pojo.Db;
import com.micro.fast.mybatis.generator.extend.pojo.MybatisGenerator;
import com.micro.fast.mybatis.generator.extend.util.FreemarkerUtil;
import com.micro.fast.mybatis.generator.extend.util.JarUtil;
import com.micro.fast.mybatis.generator.extend.util.PropertiesUtil;
import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -46,7 +48,7 @@ public class MybatisGeneratorExtend {
/**
* 根据模板引擎生成mybatis-generator需要的文件
*/
public static void GenerateMybatisGeneratorNeedFilesByTemplates() {
public static void GenerateMybatisGeneratorNeedFilesByTemplates(String projectPath) {
Connection jdbcConection = JdbcConnection.getJdbcConection();
Statement statement = null;
ResultSet resultSet = null;
@@ -77,8 +79,16 @@ public class MybatisGeneratorExtend {
Map<String,Object> mybatisGeneratorModel = new HashMap<>();
mybatisGeneratorModel.put("db",MybatisGeneratorExtend.db);
mybatisGeneratorModel.put("mybatisGenerator",MybatisGeneratorExtend.mybatisGenerator);
boolean mybatisGeneratorFileSuccess = FreemarkerUtil.createFile("mybatisGenerator.ftl", mybatisGeneratorModel, "mybatisGenerator.properties");
boolean generatorConfigFileSuccess = FreemarkerUtil.createFile("generatorConfig.ftl", mybatisGeneratorModel, "generatorConfig.xml");
boolean mybatisGeneratorFileSuccess = FreemarkerUtil.createFile("mybatisGenerator.ftl", mybatisGeneratorModel, "mybatisGenerator.properties",projectPath);
File file = new File(JarUtil.getThisJarPathParent() + "/templates" + "/mybatisGenerator.ftl");
if (file.exists()){
file.delete();
}
boolean generatorConfigFileSuccess = FreemarkerUtil.createFile("generatorConfig.ftl", mybatisGeneratorModel, "generatorConfig.xml",projectPath);
File file1 = new File(JarUtil.getThisJarPathParent() + "/templates" + "/generatorConfig.ftl");
if (file1.exists()){
file1.delete();
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
@@ -1,12 +1,15 @@
package com.micro.fast.mybatis.generator.extend.util;
import com.micro.fast.mybatis.generator.extend.mojo.MyabtisGeneratorExtendMojo;
import com.micro.fast.mybatis.generator.extend.service.MybatisGeneratorExtend;
import freemarker.core.ParseException;
import freemarker.template.*;
import java.io.*;
import java.net.URL;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
/**
* 根据freemarker模板生成文件
@@ -36,14 +39,12 @@ public class FreemarkerUtil {
//1.设置编码
cfg.setDefaultEncoding("utf-8");
//2.设置加载模板文件的位置,这个位置是随着这个class加载的目录位置而确定的
URL resource = FreemarkerUtil.class.getResource("/" + templatesDirUrl);
String path = resource.getPath();
//2.解压所需要的jar中的文件,设置加载模板文件的位置
JarUtil.unThisJar();
try {
cfg.setDirectoryForTemplateLoading(new File(path));
cfg.setDirectoryForTemplateLoading(new File(JarUtil.getThisJarPathParent()+"/"+templatesDirUrl));
} catch (IOException e) {
e.printStackTrace();
System.out.println("-----------加载mybatis-generator-extend模板文件失败------------");
}
}
@@ -54,14 +55,11 @@ public class FreemarkerUtil {
* @param targetFileName
* @return
*/
public static boolean createFile(String templateName, Map<String, Object> data, String targetFileName) {
public static boolean createFile(String templateName, Map<String, Object> data, String targetFileName,String projectPath) {
Template template = null;
Writer out = null;
//1.获取当前项目classpath路径
String classPath = FreemarkerUtil.class.getResource("/").getPath();
int lastIndexOf = classPath.lastIndexOf("target");
String projectDir = classPath.substring(0, lastIndexOf);
String resourcesDir = projectDir+"src/main/resources";
String resourcesDir = projectPath+"/"+"src/main/resources";
File file = new File(resourcesDir);
if (!file.exists()){
try {
@@ -133,6 +131,5 @@ public class FreemarkerUtil {
System.out.println(System.getProperty("user.dir"));
//5.获取所有的类的jar的加载路径
System.out.println(System.getProperty("java.class.path"));
MybatisGeneratorExtend.GenerateMybatisGeneratorNeedFilesByTemplates();
}
}
@@ -19,16 +19,20 @@ public class JarUtil {
JarInputStream jarInputStream = null;
JarFile jarFile = null;
try {
//1.获取当前项目jar包的路径
jarInputStream = new JarInputStream(new FileInputStream(new File(getThisJarPath())));
jarFile = new JarFile(new File(getThisJarPath()));
JarEntry jarEntry = null;
while ((jarEntry = jarInputStream.getNextJarEntry())!=null){
String fileName = jarEntry.getName();
if ("generatorConfig.ftl".equals(fileName)||"mybatisGenerator.ftl".equals(fileName)){
if (fileName.endsWith("generatorConfig.ftl")||fileName.endsWith("mybatisGenerator.ftl")){
File file = new File(getThisJarPathParent() +"/"+fileName);
if (file.exists()){
file.delete();
}
if (!new File(file.getParent()).exists()){
new File(file.getParent()).mkdirs();
}
InputStream inputStream = null;
OutputStream outputStream = null;
try {
@@ -43,9 +47,7 @@ public class JarUtil {
outputStream.close();
inputStream.close();
}
}
jarEntry = null;
}
} catch (IOException e) {
e.printStackTrace();
@@ -7,27 +7,7 @@ public class PropertiesUtil {
private static final String PROPERTIES_PATH = "mybatisStart.properties";
private static Properties properties = null;
static {
//1.获取当前项目classpath路径
String classPath = FreemarkerUtil.class.getResource("/").getPath();
//2.将mybatisStart.properties配置文件加载到输入流中
File file = new File(classPath + PROPERTIES_PATH);
if (file.exists()){
InputStream inputStream = null;
try {
inputStream = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
//3.将输入流写入到properties对象中
if (properties==null){
properties = new Properties();
}
try {
properties.load(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
@@ -58,4 +38,25 @@ public class PropertiesUtil {
public static void setProperties(Properties properties) {
PropertiesUtil.properties = properties;
}
public void loadProperties(String projectPath){
//2.将mybatisStart.properties配置文件加载到输入流中
File file = new File( projectPath+"/src/main/resources/"+PROPERTIES_PATH);
if (file.exists()){
InputStream inputStream = null;
try {
inputStream = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
//3.将输入流写入到properties对象中
if (properties==null){
properties = new Properties();
}
try {
properties.load(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
@@ -0,0 +1,17 @@
package com.micro.fast.upms.dao;
import com.micro.fast.upms.pojo.UpmsSystem;
public interface UpmsSystemMapper {
int deleteByPrimaryKey(Integer id);
int insert(UpmsSystem record);
int insertSelective(UpmsSystem record);
UpmsSystem selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(UpmsSystem record);
int updateByPrimaryKey(UpmsSystem record);
}
@@ -0,0 +1,156 @@
package com.micro.fast.upms.pojo;
import java.io.Serializable;
public class UpmsSystem implements Serializable {
private Integer id;
private String icon;
private String banner;
private String theme;
private String basepath;
private Byte status;
private String name;
private String title;
private String description;
private Long ctime;
private Long orders;
private static final long serialVersionUID = 1L;
public UpmsSystem(Integer id, String icon, String banner, String theme, String basepath, Byte status, String name, String title, String description, Long ctime, Long orders) {
this.id = id;
this.icon = icon;
this.banner = banner;
this.theme = theme;
this.basepath = basepath;
this.status = status;
this.name = name;
this.title = title;
this.description = description;
this.ctime = ctime;
this.orders = orders;
}
public UpmsSystem() {
super();
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon == null ? null : icon.trim();
}
public String getBanner() {
return banner;
}
public void setBanner(String banner) {
this.banner = banner == null ? null : banner.trim();
}
public String getTheme() {
return theme;
}
public void setTheme(String theme) {
this.theme = theme == null ? null : theme.trim();
}
public String getBasepath() {
return basepath;
}
public void setBasepath(String basepath) {
this.basepath = basepath == null ? null : basepath.trim();
}
public Byte getStatus() {
return status;
}
public void setStatus(Byte status) {
this.status = status;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title == null ? null : title.trim();
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description == null ? null : description.trim();
}
public Long getCtime() {
return ctime;
}
public void setCtime(Long ctime) {
this.ctime = ctime;
}
public Long getOrders() {
return orders;
}
public void setOrders(Long orders) {
this.orders = orders;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", icon=").append(icon);
sb.append(", banner=").append(banner);
sb.append(", theme=").append(theme);
sb.append(", basepath=").append(basepath);
sb.append(", status=").append(status);
sb.append(", name=").append(name);
sb.append(", title=").append(title);
sb.append(", description=").append(description);
sb.append(", ctime=").append(ctime);
sb.append(", orders=").append(orders);
sb.append("]");
return sb.toString();
}
}
@@ -1,83 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!--导入属性配置-->
<properties resource="mybatisGenerator.properties"></properties>
<!--指定特定数据库的jdbc驱动jar包的位置-->
<classPathEntry location="${db.driverLocation}"/>
<context id="default" targetRuntime="MyBatis3" defaultModelType="flat">
<!--java文件的编码设置-->
<property name="javaFileEncoding" value="UTF-8"/>
<!-- 由于beginningDelimiter和endingDelimiter的默认值为双引号("),在Mysql中不能这么写,所以还要将这两个默认值改为` -->
<property name="beginningDelimiter" value="`"/>
<property name="endingDelimiter" value="`"/>
<!-- 为生成的Java模型创建一个toString方法 -->
<plugin type="org.mybatis.generator.plugins.ToStringPlugin"></plugin>
<!-- 对生成的pojo集成serializable接口-->
<plugin type="org.mybatis.generator.plugins.SerializablePlugin" ></plugin>
<!-- optional,旨在创建class时,对注释进行控制 -->
<commentGenerator>
<property name="suppressDate" value="true"/>
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--jdbc的数据库连接 -->
<jdbcConnection
driverClass="${db.driverClassName}"
connectionURL="${db.url}"
userId="${db.username}"
password="${db.password}">
</jdbcConnection>
<!-- 非必需,类型处理器,在数据库类型和java类型之间的转换控制-->
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径
-->
<javaModelGenerator targetPackage="com.micro.fast.upms.pojo" targetProject="./src/main/java">
<!-- 是否允许子包,即targetPackage.schemaName.tableName -->
<property name="enableSubPackages" value="false"/>
<!-- 是否对model添加 构造函数 -->
<property name="constructorBased" value="true"/>
<!-- 是否对类CHAR类型的列的数据进行trim操作 -->
<property name="trimStrings" value="true"/>
<!-- 建立的Model对象是否 不可改变 即生成的Model对象不会有 setter方法,只有构造方法 -->
<property name="immutable" value="false"/>
</javaModelGenerator>
<!--mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 -->
<!--<sqlMapGenerator targetPackage="mappers" targetProject=".\src\main\resources">-->
<sqlMapGenerator targetPackage="mappers" targetProject="./src/main/resources">
<property name="enableSubPackages" value="false"/>
</sqlMapGenerator>
<!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口
-->
<!-- targetPackage:mapper接口dao生成的位置 -->
<!--<javaClientGenerator type="XMLMAPPER" targetPackage="com.mmall.dao" targetProject=".\src\main\java">-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.micro.fast.upms.dao" targetProject="./src/main/java" >
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<table tableName="upms_log" domainObjectName="UpmsLog" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_organization" domainObjectName="UpmsOrganization" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_permission" domainObjectName="UpmsPermission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_role" domainObjectName="UpmsRole" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_role_permission" domainObjectName="UpmsRolePermission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="system" domainObjectName="System" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_user" domainObjectName="UpmsUser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_user_organization" domainObjectName="UpmsUserOrganization" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_user_permission" domainObjectName="UpmsUserPermission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_user_role" domainObjectName="UpmsUserRole" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!--指定特定数据库的jdbc驱动jar包的位置-->
<classPathEntry location="/root/mysql-connector-java-5.1.40-bin.jar"/>
<context id="default" targetRuntime="MyBatis3" defaultModelType="flat">
<!--java文件的编码设置-->
<property name="javaFileEncoding" value="UTF-8"/>
<!-- 由于beginningDelimiter和endingDelimiter的默认值为双引号("),在Mysql中不能这么写,所以还要将这两个默认值改为` -->
<property name="beginningDelimiter" value="`"/>
<property name="endingDelimiter" value="`"/>
<!-- 为生成的Java模型创建一个toString方法 -->
<plugin type="org.mybatis.generator.plugins.ToStringPlugin"></plugin>
<!-- 对生成的pojo集成serializable接口-->
<plugin type="org.mybatis.generator.plugins.SerializablePlugin" ></plugin>
<!-- optional,旨在创建class时,对注释进行控制 -->
<commentGenerator>
<property name="suppressDate" value="true"/>
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--jdbc的数据库连接 -->
<jdbcConnection
driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://172.17.0.1:3317/micro?useUncoide=true&amp;chracterEncoding=utf-8&amp;useSSL=false"
userId="root"
password="studyj2e">
</jdbcConnection>
<!-- 非必需,类型处理器,在数据库类型和java类型之间的转换控制-->
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径
-->
<javaModelGenerator targetPackage="com.micro.fast.upms.pojo" targetProject="./src/main/java">
<!-- 是否允许子包,即targetPackage.schemaName.tableName -->
<property name="enableSubPackages" value="false"/>
<!-- 是否对model添加 构造函数 -->
<property name="constructorBased" value="true"/>
<!-- 是否对类CHAR类型的列的数据进行trim操作 -->
<property name="trimStrings" value="true"/>
<!-- 建立的Model对象是否 不可改变 即生成的Model对象不会有 setter方法,只有构造方法 -->
<property name="immutable" value="false"/>
</javaModelGenerator>
<!--mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 -->
<!--<sqlMapGenerator targetPackage="mappers" targetProject=".\src\main\resources">-->
<sqlMapGenerator targetPackage="mappers" targetProject="./src/main/resources">
<property name="enableSubPackages" value="false"/>
</sqlMapGenerator>
<!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口
-->
<!-- targetPackage:mapper接口dao生成的位置 -->
<!--<javaClientGenerator type="XMLMAPPER" targetPackage="com.mmall.dao" targetProject=".\src\main\java">-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.micro.fast.upms.dao" targetProject="./src/main/java" >
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<table tableName="upms_user_role" domainObjectName="UpmsUserRole" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_log" domainObjectName="UpmsLog" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_system" domainObjectName="UpmsSystem" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_organization" domainObjectName="UpmsOrganization" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_role_permission" domainObjectName="UpmsRolePermission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_permission" domainObjectName="UpmsPermission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_user" domainObjectName="UpmsUser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_user_organization" domainObjectName="UpmsUserOrganization" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_role" domainObjectName="UpmsRole" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_user_permission" domainObjectName="UpmsUserPermission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>
@@ -0,0 +1,165 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.micro.fast.upms.dao.UpmsSystemMapper" >
<resultMap id="BaseResultMap" type="com.micro.fast.upms.pojo.UpmsSystem" >
<constructor >
<idArg column="id" jdbcType="INTEGER" javaType="java.lang.Integer" />
<arg column="icon" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="banner" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="theme" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="basepath" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="status" jdbcType="TINYINT" javaType="java.lang.Byte" />
<arg column="name" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="title" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="description" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="ctime" jdbcType="BIGINT" javaType="java.lang.Long" />
<arg column="orders" jdbcType="BIGINT" javaType="java.lang.Long" />
</constructor>
</resultMap>
<sql id="Base_Column_List" >
id, icon, banner, theme, basepath, status, name, title, description, ctime, orders
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from upms_system
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from upms_system
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.micro.fast.upms.pojo.UpmsSystem" >
insert into upms_system (id, icon, banner,
theme, basepath, status,
name, title, description,
ctime, orders)
values (#{id,jdbcType=INTEGER}, #{icon,jdbcType=VARCHAR}, #{banner,jdbcType=VARCHAR},
#{theme,jdbcType=VARCHAR}, #{basepath,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT},
#{name,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
#{ctime,jdbcType=BIGINT}, #{orders,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="com.micro.fast.upms.pojo.UpmsSystem" >
insert into upms_system
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="icon != null" >
icon,
</if>
<if test="banner != null" >
banner,
</if>
<if test="theme != null" >
theme,
</if>
<if test="basepath != null" >
basepath,
</if>
<if test="status != null" >
status,
</if>
<if test="name != null" >
name,
</if>
<if test="title != null" >
title,
</if>
<if test="description != null" >
description,
</if>
<if test="ctime != null" >
ctime,
</if>
<if test="orders != null" >
orders,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="icon != null" >
#{icon,jdbcType=VARCHAR},
</if>
<if test="banner != null" >
#{banner,jdbcType=VARCHAR},
</if>
<if test="theme != null" >
#{theme,jdbcType=VARCHAR},
</if>
<if test="basepath != null" >
#{basepath,jdbcType=VARCHAR},
</if>
<if test="status != null" >
#{status,jdbcType=TINYINT},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="title != null" >
#{title,jdbcType=VARCHAR},
</if>
<if test="description != null" >
#{description,jdbcType=VARCHAR},
</if>
<if test="ctime != null" >
#{ctime,jdbcType=BIGINT},
</if>
<if test="orders != null" >
#{orders,jdbcType=BIGINT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.micro.fast.upms.pojo.UpmsSystem" >
update upms_system
<set >
<if test="icon != null" >
icon = #{icon,jdbcType=VARCHAR},
</if>
<if test="banner != null" >
banner = #{banner,jdbcType=VARCHAR},
</if>
<if test="theme != null" >
theme = #{theme,jdbcType=VARCHAR},
</if>
<if test="basepath != null" >
basepath = #{basepath,jdbcType=VARCHAR},
</if>
<if test="status != null" >
status = #{status,jdbcType=TINYINT},
</if>
<if test="name != null" >
name = #{name,jdbcType=VARCHAR},
</if>
<if test="title != null" >
title = #{title,jdbcType=VARCHAR},
</if>
<if test="description != null" >
description = #{description,jdbcType=VARCHAR},
</if>
<if test="ctime != null" >
ctime = #{ctime,jdbcType=BIGINT},
</if>
<if test="orders != null" >
orders = #{orders,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.micro.fast.upms.pojo.UpmsSystem" >
update upms_system
set icon = #{icon,jdbcType=VARCHAR},
banner = #{banner,jdbcType=VARCHAR},
theme = #{theme,jdbcType=VARCHAR},
basepath = #{basepath,jdbcType=VARCHAR},
status = #{status,jdbcType=TINYINT},
name = #{name,jdbcType=VARCHAR},
title = #{title,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
ctime = #{ctime,jdbcType=BIGINT},
orders = #{orders,jdbcType=BIGINT}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
@@ -1,5 +1,5 @@
db.driverLocation=/root/mysql-connector-java-5.1.40-bin.jar
db.driverClassName=com.mysql.jdbc.Driver
db.url=jdbc:mysql://172.17.0.1:3317/micro?useUncoide=true&chracterEncoding=utf-8&useSSL=false
db.url=jdbc:mysql://172.17.0.1:3317/micro?useUncoide=true&amp;chracterEncoding=utf-8&amp;useSSL=false
db.username=root
db.password=studyj2e
@@ -4,6 +4,6 @@ db.driverClassName=com.mysql.jdbc.Driver
db.url=jdbc:mysql://172.17.0.1:3317/micro?useUncoide=true&chracterEncoding=utf-8&useSSL=false
db.username=root
db.password=studyj2e
mybatisGenerator.pojoPackage=pojoPackage
mybatisGenerator.daoPackage=daoPackage
mybatisGenerator.pojoPackage=com.micro.fast.upms.pojo
mybatisGenerator.daoPackage=com.micro.fast.upms.dao
mybatisGenerator.tablesPrefix=upms