Commit a760cd2f authored by 黄瑜's avatar 黄瑜

更新

parent aeb789e6
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="Encoding"> <component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
<file url="file://$PROJECT_DIR$" charset="UTF-8" /> <file url="file://$PROJECT_DIR$" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/dao" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/dao" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/domain" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/domain" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/service" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/service" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/web" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/web" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/web/src/main/sql/SpringMvcTemplate.sql" charset="UTF-8" />
</component> </component>
</project> </project>
\ No newline at end of file
#NOTE: This is an Aether internal implementation file, its format can be changed without prior notice. #NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
#Tue Oct 09 18:09:05 CST 2018 #Wed Oct 10 15:26:51 CST 2018
SpringMVCTemplate-0.0.1-SNAPSHOT.pom>= SpringMVCTemplate-0.0.1-SNAPSHOT.pom>=
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
<snapshot> <snapshot>
<localCopy>true</localCopy> <localCopy>true</localCopy>
</snapshot> </snapshot>
<lastUpdated>20181009100905</lastUpdated> <lastUpdated>20181010072652</lastUpdated>
<snapshotVersions> <snapshotVersions>
<snapshotVersion> <snapshotVersion>
<extension>pom</extension> <extension>pom</extension>
<value>0.0.1-SNAPSHOT</value> <value>0.0.1-SNAPSHOT</value>
<updated>20181009100905</updated> <updated>20181010072652</updated>
</snapshotVersion> </snapshotVersion>
</snapshotVersions> </snapshotVersions>
</versioning> </versioning>
......
...@@ -6,6 +6,6 @@ ...@@ -6,6 +6,6 @@
<versions> <versions>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</versions> </versions>
<lastUpdated>20181009100905</lastUpdated> <lastUpdated>20181010072652</lastUpdated>
</versioning> </versioning>
</metadata> </metadata>
#NOTE: This is an Aether internal implementation file, its format can be changed without prior notice. #NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
#Tue Oct 09 18:09:12 CST 2018 #Wed Oct 10 15:26:59 CST 2018
dao-0.0.1-SNAPSHOT.pom>= dao-0.0.1-SNAPSHOT.pom>=
dao-0.0.1-SNAPSHOT.jar>= dao-0.0.1-SNAPSHOT.jar>=
...@@ -7,17 +7,17 @@ ...@@ -7,17 +7,17 @@
<snapshot> <snapshot>
<localCopy>true</localCopy> <localCopy>true</localCopy>
</snapshot> </snapshot>
<lastUpdated>20181009100912</lastUpdated> <lastUpdated>20181010072659</lastUpdated>
<snapshotVersions> <snapshotVersions>
<snapshotVersion> <snapshotVersion>
<extension>jar</extension> <extension>jar</extension>
<value>0.0.1-SNAPSHOT</value> <value>0.0.1-SNAPSHOT</value>
<updated>20181009100912</updated> <updated>20181010072659</updated>
</snapshotVersion> </snapshotVersion>
<snapshotVersion> <snapshotVersion>
<extension>pom</extension> <extension>pom</extension>
<value>0.0.1-SNAPSHOT</value> <value>0.0.1-SNAPSHOT</value>
<updated>20181009100912</updated> <updated>20181010072659</updated>
</snapshotVersion> </snapshotVersion>
</snapshotVersions> </snapshotVersions>
</versioning> </versioning>
......
...@@ -6,6 +6,6 @@ ...@@ -6,6 +6,6 @@
<versions> <versions>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</versions> </versions>
<lastUpdated>20181009100912</lastUpdated> <lastUpdated>20181010072659</lastUpdated>
</versioning> </versioning>
</metadata> </metadata>
#NOTE: This is an Aether internal implementation file, its format can be changed without prior notice. #NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
#Tue Oct 09 18:09:12 CST 2018 #Wed Oct 10 15:26:58 CST 2018
domain-0.0.1-SNAPSHOT.pom>= domain-0.0.1-SNAPSHOT.pom>=
domain-0.0.1-SNAPSHOT.jar>= domain-0.0.1-SNAPSHOT.jar>=
...@@ -7,17 +7,17 @@ ...@@ -7,17 +7,17 @@
<snapshot> <snapshot>
<localCopy>true</localCopy> <localCopy>true</localCopy>
</snapshot> </snapshot>
<lastUpdated>20181009100912</lastUpdated> <lastUpdated>20181010072658</lastUpdated>
<snapshotVersions> <snapshotVersions>
<snapshotVersion> <snapshotVersion>
<extension>jar</extension> <extension>jar</extension>
<value>0.0.1-SNAPSHOT</value> <value>0.0.1-SNAPSHOT</value>
<updated>20181009100912</updated> <updated>20181010072658</updated>
</snapshotVersion> </snapshotVersion>
<snapshotVersion> <snapshotVersion>
<extension>pom</extension> <extension>pom</extension>
<value>0.0.1-SNAPSHOT</value> <value>0.0.1-SNAPSHOT</value>
<updated>20181009100912</updated> <updated>20181010072658</updated>
</snapshotVersion> </snapshotVersion>
</snapshotVersions> </snapshotVersions>
</versioning> </versioning>
......
...@@ -6,6 +6,6 @@ ...@@ -6,6 +6,6 @@
<versions> <versions>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</versions> </versions>
<lastUpdated>20181009100912</lastUpdated> <lastUpdated>20181010072658</lastUpdated>
</versioning> </versioning>
</metadata> </metadata>
#NOTE: This is an Aether internal implementation file, its format can be changed without prior notice. #NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
#Tue Oct 09 18:09:14 CST 2018 #Wed Oct 10 15:27:01 CST 2018
service-0.0.1-SNAPSHOT.pom>= service-0.0.1-SNAPSHOT.pom>=
service-0.0.1-SNAPSHOT.jar>= service-0.0.1-SNAPSHOT.jar>=
...@@ -7,17 +7,17 @@ ...@@ -7,17 +7,17 @@
<snapshot> <snapshot>
<localCopy>true</localCopy> <localCopy>true</localCopy>
</snapshot> </snapshot>
<lastUpdated>20181009100914</lastUpdated> <lastUpdated>20181010072701</lastUpdated>
<snapshotVersions> <snapshotVersions>
<snapshotVersion> <snapshotVersion>
<extension>jar</extension> <extension>jar</extension>
<value>0.0.1-SNAPSHOT</value> <value>0.0.1-SNAPSHOT</value>
<updated>20181009100914</updated> <updated>20181010072701</updated>
</snapshotVersion> </snapshotVersion>
<snapshotVersion> <snapshotVersion>
<extension>pom</extension> <extension>pom</extension>
<value>0.0.1-SNAPSHOT</value> <value>0.0.1-SNAPSHOT</value>
<updated>20181009100914</updated> <updated>20181010072701</updated>
</snapshotVersion> </snapshotVersion>
</snapshotVersions> </snapshotVersions>
</versioning> </versioning>
......
...@@ -6,6 +6,6 @@ ...@@ -6,6 +6,6 @@
<versions> <versions>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</versions> </versions>
<lastUpdated>20181009100914</lastUpdated> <lastUpdated>20181010072701</lastUpdated>
</versioning> </versioning>
</metadata> </metadata>
#NOTE: This is an Aether internal implementation file, its format can be changed without prior notice. #NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
#Tue Oct 09 18:09:20 CST 2018 #Wed Oct 10 15:27:07 CST 2018
web-0.0.1-SNAPSHOT.pom>= web-0.0.1-SNAPSHOT.pom>=
web-0.0.1-SNAPSHOT.war>= web-0.0.1-SNAPSHOT.war>=
...@@ -7,17 +7,17 @@ ...@@ -7,17 +7,17 @@
<snapshot> <snapshot>
<localCopy>true</localCopy> <localCopy>true</localCopy>
</snapshot> </snapshot>
<lastUpdated>20181009100920</lastUpdated> <lastUpdated>20181010072707</lastUpdated>
<snapshotVersions> <snapshotVersions>
<snapshotVersion> <snapshotVersion>
<extension>war</extension> <extension>war</extension>
<value>0.0.1-SNAPSHOT</value> <value>0.0.1-SNAPSHOT</value>
<updated>20181009100920</updated> <updated>20181010072707</updated>
</snapshotVersion> </snapshotVersion>
<snapshotVersion> <snapshotVersion>
<extension>pom</extension> <extension>pom</extension>
<value>0.0.1-SNAPSHOT</value> <value>0.0.1-SNAPSHOT</value>
<updated>20181009100920</updated> <updated>20181010072707</updated>
</snapshotVersion> </snapshotVersion>
</snapshotVersions> </snapshotVersions>
</versioning> </versioning>
......
...@@ -6,6 +6,6 @@ ...@@ -6,6 +6,6 @@
<versions> <versions>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</versions> </versions>
<lastUpdated>20181009100920</lastUpdated> <lastUpdated>20181010072707</lastUpdated>
</versioning> </versioning>
</metadata> </metadata>
...@@ -28,8 +28,8 @@ public class TesRoleController { ...@@ -28,8 +28,8 @@ public class TesRoleController {
@ApiOperation(value = "创建'TESROLE'表中一条信息", notes = "通过post方法请求,传入表中字段的对应信息,创建一条数据。并返回给View层") @ApiOperation(value = "创建'TESROLE'表中一条信息", notes = "通过post方法请求,传入表中字段的对应信息,创建一条数据。并返回给View层")
@RequestMapping(value = "/tes_roles/new", @RequestMapping(value = "/tes_roles/new",
method = RequestMethod.POST, method = RequestMethod.POST,
produces = "application/json;charset=UTF-8") produces = "application/json;charset=UTF-8")
@ResponseBody @ResponseBody
public Object createTesRole( public Object createTesRole(
HttpServletRequest request, HttpServletRequest request,
...@@ -43,23 +43,22 @@ public class TesRoleController { ...@@ -43,23 +43,22 @@ public class TesRoleController {
TesRole item = new TesRole(); TesRole item = new TesRole();
String id = Tools.getUUID(); String id = Tools.getUUID();
item.setId(id); item.setId(id);
if( name != null ){ if (name != null) {
item.setName(name); item.setName(name);
} }
if( description != null ){ if (description != null) {
item.setDescription(description); item.setDescription(description);
} }
if( menu_id != null ){ if (menu_id != null) {
item.setMenuId(menu_id); item.setMenuId(menu_id);
} }
if( create_date != null ){ if (create_date != null) {
item.setCreateDate(Tools.convertStringToDate(create_date, "yyyy-MM-dd HH:mm:ss")); item.setCreateDate(Tools.convertStringToDate(create_date, "yyyy-MM-dd HH:mm:ss"));
} }
if( last_update_time != null ){ if (last_update_time != null) {
item.setLastUpdateTime(Tools.convertStringToDate(last_update_time, "yyyy-MM-dd HH:mm:ss")); item.setLastUpdateTime(Tools.convertStringToDate(last_update_time, "yyyy-MM-dd HH:mm:ss"));
} }
tesRoleService.create(item); tesRoleService.create(item);
//若request param为null,但字段定义有默认值,则需从数据库中返回结果 //若request param为null,但字段定义有默认值,则需从数据库中返回结果
return tesRoleService.get(id); return tesRoleService.get(id);
//return item; //return item;
...@@ -67,8 +66,8 @@ public class TesRoleController { ...@@ -67,8 +66,8 @@ public class TesRoleController {
@ApiOperation(value = "删除'TESROLE'表中的某条记录", notes = "根据url传入的数据id,删除整条记录。") @ApiOperation(value = "删除'TESROLE'表中的某条记录", notes = "根据url传入的数据id,删除整条记录。")
@RequestMapping(value = "/tes_roles/{tes_role_id}/delete", @RequestMapping(value = "/tes_roles/{tes_role_id}/delete",
method = RequestMethod.POST, method = RequestMethod.POST,
produces = "application/json;charset=UTF-8") produces = "application/json;charset=UTF-8")
@ResponseBody @ResponseBody
public Object deleteTesRole( public Object deleteTesRole(
@RequestHeader(value = "X-Auth-Token") String token, @RequestHeader(value = "X-Auth-Token") String token,
...@@ -86,8 +85,8 @@ public class TesRoleController { ...@@ -86,8 +85,8 @@ public class TesRoleController {
@ApiOperation(value = "修改'TESROLE'表中的某条记录", notes = "根据url传入的数据id,确定修改表中的某条记录,传入表中字段要修改的信息,不传代表不修改。并返回给View层") @ApiOperation(value = "修改'TESROLE'表中的某条记录", notes = "根据url传入的数据id,确定修改表中的某条记录,传入表中字段要修改的信息,不传代表不修改。并返回给View层")
@RequestMapping(value = "/tes_roles/{tes_role_id}/edit", @RequestMapping(value = "/tes_roles/{tes_role_id}/edit",
method = RequestMethod.POST, method = RequestMethod.POST,
produces = "application/json;charset=UTF-8") produces = "application/json;charset=UTF-8")
@ResponseBody @ResponseBody
public Object editTesRole( public Object editTesRole(
HttpServletRequest request, HttpServletRequest request,
...@@ -105,19 +104,19 @@ public class TesRoleController { ...@@ -105,19 +104,19 @@ public class TesRoleController {
return Resp.fail("the asset to be edited doesn't exist"); return Resp.fail("the asset to be edited doesn't exist");
} }
if( name != null ){ if (name != null) {
item.setName(name); item.setName(name);
} }
if( description != null ){ if (description != null) {
item.setDescription(description); item.setDescription(description);
} }
if( menu_id != null ){ if (menu_id != null) {
item.setMenuId(menu_id); item.setMenuId(menu_id);
} }
if( create_date != null ){ if (create_date != null) {
item.setCreateDate(Tools.convertStringToDate(create_date, "yyyy-MM-dd HH:mm:ss")); item.setCreateDate(Tools.convertStringToDate(create_date, "yyyy-MM-dd HH:mm:ss"));
} }
if( last_update_time != null ){ if (last_update_time != null) {
item.setLastUpdateTime(Tools.convertStringToDate(last_update_time, "yyyy-MM-dd HH:mm:ss")); item.setLastUpdateTime(Tools.convertStringToDate(last_update_time, "yyyy-MM-dd HH:mm:ss"));
} }
tesRoleService.update(item); tesRoleService.update(item);
...@@ -127,8 +126,8 @@ public class TesRoleController { ...@@ -127,8 +126,8 @@ public class TesRoleController {
@ApiOperation(value = "查询'TESROLE'表中的某条记录", notes = "根据url传入的数据id,查询对应的一条数据。") @ApiOperation(value = "查询'TESROLE'表中的某条记录", notes = "根据url传入的数据id,查询对应的一条数据。")
@RequestMapping(value = "/tes_roles/{tes_role_id}", @RequestMapping(value = "/tes_roles/{tes_role_id}",
method = {RequestMethod.GET, RequestMethod.DELETE, RequestMethod.PUT}, method = {RequestMethod.GET, RequestMethod.DELETE, RequestMethod.PUT},
produces = "application/json;charset=UTF-8") produces = "application/json;charset=UTF-8")
@ResponseBody @ResponseBody
public Object getTesRole( public Object getTesRole(
HttpServletRequest request, HttpServletRequest request,
...@@ -140,7 +139,7 @@ public class TesRoleController { ...@@ -140,7 +139,7 @@ public class TesRoleController {
@RequestParam(value = "create_date", required = false) String create_date, @RequestParam(value = "create_date", required = false) String create_date,
@RequestParam(value = "last_update_time", required = false) String last_update_time @RequestParam(value = "last_update_time", required = false) String last_update_time
) { ) {
if(request.getMethod().equals("GET")){ if (request.getMethod().equals("GET")) {
TesRole item = tesRoleService.get(id); TesRole item = tesRoleService.get(id);
if (null == item) { if (null == item) {
response.setStatus(404); response.setStatus(404);
...@@ -148,34 +147,32 @@ public class TesRoleController { ...@@ -148,34 +147,32 @@ public class TesRoleController {
} }
return item; return item;
} } else if (request.getMethod().equals("PUT")) {
else if(request.getMethod().equals("PUT")){
TesRole item = tesRoleService.get(id); TesRole item = tesRoleService.get(id);
if (null == item) { if (null == item) {
response.setStatus(404); response.setStatus(404);
return Resp.fail("the asset to be edited doesn't exist"); return Resp.fail("the asset to be edited doesn't exist");
} }
if( name != null ){ if (name != null) {
item.setName(name); item.setName(name);
} }
if( description != null ){ if (description != null) {
item.setDescription(description); item.setDescription(description);
} }
if( menu_id != null ){ if (menu_id != null) {
item.setMenuId(menu_id); item.setMenuId(menu_id);
} }
if( create_date != null ){ if (create_date != null) {
item.setCreateDate(Tools.convertStringToDate(create_date, "yyyy-MM-dd HH:mm:ss")); item.setCreateDate(Tools.convertStringToDate(create_date, "yyyy-MM-dd HH:mm:ss"));
} }
if( last_update_time != null ){ if (last_update_time != null) {
item.setLastUpdateTime(Tools.convertStringToDate(last_update_time, "yyyy-MM-dd HH:mm:ss")); item.setLastUpdateTime(Tools.convertStringToDate(last_update_time, "yyyy-MM-dd HH:mm:ss"));
} }
tesRoleService.update(item); tesRoleService.update(item);
return tesRoleService.get(id); return tesRoleService.get(id);
} } else if (request.getMethod().equals("DELETE")) {
else if(request.getMethod().equals("DELETE")){
TesRole item = tesRoleService.get(id); TesRole item = tesRoleService.get(id);
if (null == item) { if (null == item) {
response.setStatus(404); response.setStatus(404);
...@@ -190,8 +187,8 @@ public class TesRoleController { ...@@ -190,8 +187,8 @@ public class TesRoleController {
@ApiOperation(value = "查询'TESROLE'表中的多条记录或者新增某条记录", notes = "get传参:根据url传入的filters(过滤条件),查询对应的多条数据。数据数量取决于page_no和page_size;数据的先后顺序取决于sort_item,sort_order; post请求:新增某条记录,传入表字段对应的值") @ApiOperation(value = "查询'TESROLE'表中的多条记录或者新增某条记录", notes = "get传参:根据url传入的filters(过滤条件),查询对应的多条数据。数据数量取决于page_no和page_size;数据的先后顺序取决于sort_item,sort_order; post请求:新增某条记录,传入表字段对应的值")
@RequestMapping(value = "/tes_roles", @RequestMapping(value = "/tes_roles",
method = { RequestMethod.GET, RequestMethod.POST }, method = {RequestMethod.GET, RequestMethod.POST},
produces = "application/json;charset=UTF-8") produces = "application/json;charset=UTF-8")
@ResponseBody @ResponseBody
public Object getTesRoles( public Object getTesRoles(
HttpServletRequest request, HttpServletRequest request,
...@@ -210,46 +207,45 @@ public class TesRoleController { ...@@ -210,46 +207,45 @@ public class TesRoleController {
@RequestParam(value = "refers", required = false) String refers, @RequestParam(value = "refers", required = false) String refers,
@RequestParam(value = "relates", required = false) String relates @RequestParam(value = "relates", required = false) String relates
) { ) {
if(request.getMethod().equals("GET")){ if (request.getMethod().equals("GET")) {
if(pageNo == null){ if (pageNo == null) {
pageNo = 1; pageNo = 1;
} }
if(pageSize == null){ if (pageSize == null) {
pageSize = 10; pageSize = 10;
} }
if(sortItem == null){ if (sortItem == null) {
sortItem = "id"; sortItem = "id";
} }
if(sortOrder == null){ if (sortOrder == null) {
sortOrder = "asc"; sortOrder = "asc";
} }
if(filters == null){ if (filters == null) {
filters = "{}"; filters = "{}";
} }
Long total = tesRoleService.countListWithPagingAndFilter(filters); Long total = tesRoleService.countListWithPagingAndFilter(filters);
response.addHeader("total", String.valueOf(total)); response.addHeader("total", String.valueOf(total));
return tesRoleService.getListWithPagingAndFilter( return tesRoleService.getListWithPagingAndFilter(
pageNo, pageSize, sortItem, sortOrder, filters, includes, refers, relates); pageNo, pageSize, sortItem, sortOrder, filters, includes, refers, relates);
} } else {
else{
TesRole item = new TesRole(); TesRole item = new TesRole();
String id = Tools.getUUID(); String id = Tools.getUUID();
item.setId(id); item.setId(id);
if( name != null ){ if (name != null) {
item.setName(name); item.setName(name);
} }
if( description != null ){ if (description != null) {
item.setDescription(description); item.setDescription(description);
} }
if( menu_id != null ){ if (menu_id != null) {
item.setMenuId(menu_id); item.setMenuId(menu_id);
} }
if( create_date != null ){ if (create_date != null) {
item.setCreateDate(Tools.convertStringToDate(create_date, "yyyy-MM-dd HH:mm:ss")); item.setCreateDate(Tools.convertStringToDate(create_date, "yyyy-MM-dd HH:mm:ss"));
} }
if( last_update_time != null ){ if (last_update_time != null) {
item.setLastUpdateTime(Tools.convertStringToDate(last_update_time, "yyyy-MM-dd HH:mm:ss")); item.setLastUpdateTime(Tools.convertStringToDate(last_update_time, "yyyy-MM-dd HH:mm:ss"));
} }
tesRoleService.create(item); tesRoleService.create(item);
......
##Mybatis Generator完整配置详解
###整理了一个最完整的Mybatis Generator(简称MBG)的最完整配置文件,以后修改我们自己修改的GeneratorConfig.xml可以参考此文档
```
<?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>
<!-- 可以用于加载配置项或者配置文件,在整个配置文件中就可以使用${propertyKey}的方式来引用配置项
resource:配置资源加载地址,使用resource,MBG从classpath开始找,比如com/myproject/generatorConfig.properties
url:配置资源加载地质,使用URL的方式,比如file:///C:/myfolder/generatorConfig.properties.
注意,两个属性只能选址一个;
另外,如果使用了mybatis-generator-maven-plugin,那么在pom.xml中定义的properties都可以直接在generatorConfig.xml中使用
<properties resource="" url="" />
-->
<!-- 在MBG工作的时候,需要额外加载的依赖包
location属性指明加载jar/zip包的全路径
<classPathEntry location="/Program Files/IBM/SQLLIB/java/db2java.zip" />
-->
<!--
context:生成一组对象的环境
id:必选,上下文id,用于在生成错误时提示
defaultModelType:指定生成对象的样式
1,conditional:类似hierarchical;
2,flat:所有内容(主键,blob)等全部生成在一个对象中;
3,hierarchical:主键生成一个XXKey对象(key class),Blob等单独生成一个对象,其他简单属性在一个对象中(record class)
targetRuntime:
1,MyBatis3:默认的值,生成基于MyBatis3.x以上版本的内容,包括XXXBySample;
2,MyBatis3Simple:类似MyBatis3,只是不生成XXXBySample;
introspectedColumnImpl:类全限定名,用于扩展MBG
-->
<context id="mysql" defaultModelType="hierarchical" targetRuntime="MyBatis3Simple" >
<!-- 自动识别数据库关键字,默认false,如果设置为true,根据SqlReservedWords中定义的关键字列表;
一般保留默认值,遇到数据库关键字(Java关键字),使用columnOverride覆盖
-->
<property name="autoDelimitKeywords" value="false"/>
<!-- 生成的Java文件的编码 -->
<property name="javaFileEncoding" value="UTF-8"/>
<!-- 格式化java代码 -->
<property name="javaFormatter" value="org.mybatis.generator.api.dom.DefaultJavaFormatter"/>
<!-- 格式化XML代码 -->
<property name="xmlFormatter" value="org.mybatis.generator.api.dom.DefaultXmlFormatter"/>
<!-- beginningDelimiter和endingDelimiter:指明数据库的用于标记数据库对象名的符号,比如ORACLE就是双引号,MYSQL默认是`反引号; -->
<property name="beginningDelimiter" value="`"/>
<property name="endingDelimiter" value="`"/>
<!-- 必须要有的,使用这个配置链接数据库
@TODO:是否可以扩展
-->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql:///pss" userId="root" password="admin">
<!-- 这里面可以设置property属性,每一个property属性都设置到配置的Driver上 -->
</jdbcConnection>
<!-- java类型处理器
用于处理DB中的类型到Java中的类型,默认使用JavaTypeResolverDefaultImpl;
注意一点,默认会先尝试使用Integer,Long,Short等来对应DECIMAL和 NUMERIC数据类型;
-->
<javaTypeResolver type="org.mybatis.generator.internal.types.JavaTypeResolverDefaultImpl">
<!--
true:使用BigDecimal对应DECIMAL和 NUMERIC数据类型
false:默认,
scale>0;length>18:使用BigDecimal;
scale=0;length[10,18]:使用Long;
scale=0;length[5,9]:使用Integer;
scale=0;length<5:使用Short;
-->
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- java模型创建器,是必须要的元素
负责:1,key类(见context的defaultModelType);2,java类;3,查询类
targetPackage:生成的类要放的包,真实的包受enableSubPackages属性控制;
targetProject:目标项目,指定一个存在的目录下,生成的内容会放到指定目录中,如果目录不存在,MBG不会自动建目录
-->
<javaModelGenerator targetPackage="com._520it.mybatis.domain" targetProject="src/main/java">
<!-- for MyBatis3/MyBatis3Simple
自动为每一个生成的类创建一个构造方法,构造方法包含了所有的field;而不是使用setter;
-->
<property name="constructorBased" value="false"/>
<!-- 在targetPackage的基础上,根据数据库的schema再生成一层package,最终生成的类放在这个package下,默认为false -->
<property name="enableSubPackages" value="true"/>
<!-- for MyBatis3 / MyBatis3Simple
是否创建一个不可变的类,如果为true,
那么MBG会创建一个没有setter方法的类,取而代之的是类似constructorBased的类
-->
<property name="immutable" value="false"/>
<!-- 设置一个根对象,
如果设置了这个根对象,那么生成的keyClass或者recordClass会继承这个类;在Table的rootClass属性中可以覆盖该选项
注意:如果在key class或者record class中有root class相同的属性,MBG就不会重新生成这些属性了,包括:
1,属性名相同,类型相同,有相同的getter/setter方法;
-->
<property name="rootClass" value="com._520it.mybatis.domain.BaseDomain"/>
<!-- 设置是否在getter方法中,对String类型字段调用trim()方法 -->
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 生成SQL map的XML文件生成器,
注意,在Mybatis3之后,我们可以使用mapper.xml文件+Mapper接口(或者不用mapper接口),
或者只使用Mapper接口+Annotation,所以,如果 javaClientGenerator配置中配置了需要生成XML的话,这个元素就必须配置
targetPackage/targetProject:同javaModelGenerator
-->
<sqlMapGenerator targetPackage="com._520it.mybatis.mapper" targetProject="src/main/resources">
<!-- 在targetPackage的基础上,根据数据库的schema再生成一层package,最终生成的类放在这个package下,默认为false -->
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 对于mybatis来说,即生成Mapper接口,注意,如果没有配置该元素,那么默认不会生成Mapper接口
targetPackage/targetProject:同javaModelGenerator
type:选择怎么生成mapper接口(在MyBatis3/MyBatis3Simple下):
1,ANNOTATEDMAPPER:会生成使用Mapper接口+Annotation的方式创建(SQL生成在annotation中),不会生成对应的XML;
2,MIXEDMAPPER:使用混合配置,会生成Mapper接口,并适当添加合适的Annotation,但是XML会生成在XML中;
3,XMLMAPPER:会生成Mapper接口,接口完全依赖XML;
注意,如果context是MyBatis3Simple:只支持ANNOTATEDMAPPER和XMLMAPPER
-->
<javaClientGenerator targetPackage="com._520it.mybatis.mapper" type="ANNOTATEDMAPPER" targetProject="src/main/java">
<!-- 在targetPackage的基础上,根据数据库的schema再生成一层package,最终生成的类放在这个package下,默认为false -->
<property name="enableSubPackages" value="true"/>
<!-- 可以为所有生成的接口添加一个父接口,但是MBG只负责生成,不负责检查
<property name="rootInterface" value=""/>
-->
</javaClientGenerator>
<!-- 选择一个table来生成相关文件,可以有一个或多个table,必须要有table元素
选择的table会生成一下文件:
1,SQL map文件
2,生成一个主键类;
3,除了BLOB和主键的其他字段的类;
4,包含BLOB的类;
5,一个用户生成动态查询的条件类(selectByExample, deleteByExample),可选;
6,Mapper接口(可选)
tableName(必要):要生成对象的表名;
注意:大小写敏感问题。正常情况下,MBG会自动的去识别数据库标识符的大小写敏感度,在一般情况下,MBG会
根据设置的schema,catalog或tablename去查询数据表,按照下面的流程:
1,如果schema,catalog或tablename中有空格,那么设置的是什么格式,就精确的使用指定的大小写格式去查询;
2,否则,如果数据库的标识符使用大写的,那么MBG自动把表名变成大写再查找;
3,否则,如果数据库的标识符使用小写的,那么MBG自动把表名变成小写再查找;
4,否则,使用指定的大小写格式查询;
另外的,如果在创建表的时候,使用的""把数据库对象规定大小写,就算数据库标识符是使用的大写,在这种情况下也会使用给定的大小写来创建表名;
这个时候,请设置delimitIdentifiers="true"即可保留大小写格式;
可选:
1,schema:数据库的schema;
2,catalog:数据库的catalog;
3,alias:为数据表设置的别名,如果设置了alias,那么生成的所有的SELECT SQL语句中,列名会变成:alias_actualColumnName
4,domainObjectName:生成的domain类的名字,如果不设置,直接使用表名作为domain类的名字;可以设置为somepck.domainName,那么会自动把domainName类再放到somepck包里面;
5,enableInsert(默认true):指定是否生成insert语句;
6,enableSelectByPrimaryKey(默认true):指定是否生成按照主键查询对象的语句(就是getById或get);
7,enableSelectByExample(默认true):MyBatis3Simple为false,指定是否生成动态查询语句;
8,enableUpdateByPrimaryKey(默认true):指定是否生成按照主键修改对象的语句(即update);
9,enableDeleteByPrimaryKey(默认true):指定是否生成按照主键删除对象的语句(即delete);
10,enableDeleteByExample(默认true):MyBatis3Simple为false,指定是否生成动态删除语句;
11,enableCountByExample(默认true):MyBatis3Simple为false,指定是否生成动态查询总条数语句(用于分页的总条数查询);
12,enableUpdateByExample(默认true):MyBatis3Simple为false,指定是否生成动态修改语句(只修改对象中不为空的属性);
13,modelType:参考context元素的defaultModelType,相当于覆盖;
14,delimitIdentifiers:参考tableName的解释,注意,默认的delimitIdentifiers是双引号,如果类似MYSQL这样的数据库,使用的是`(反引号,那么还需要设置context的beginningDelimiter和endingDelimiter属性)
15,delimitAllColumns:设置是否所有生成的SQL中的列名都使用标识符引起来。默认为false,delimitIdentifiers参考context的属性
注意,table里面很多参数都是对javaModelGenerator,context等元素的默认属性的一个复写;
-->
<table tableName="userinfo" >
<!-- 参考 javaModelGenerator 的 constructorBased属性-->
<property name="constructorBased" value="false"/>
<!-- 默认为false,如果设置为true,在生成的SQL中,table名字不会加上catalog或schema; -->
<property name="ignoreQualifiersAtRuntime" value="false"/>
<!-- 参考 javaModelGenerator 的 immutable 属性 -->
<property name="immutable" value="false"/>
<!-- 指定是否只生成domain类,如果设置为true,只生成domain类,如果还配置了sqlMapGenerator,那么在mapper XML文件中,只生成resultMap元素 -->
<property name="modelOnly" value="false"/>
<!-- 参考 javaModelGenerator 的 rootClass 属性
<property name="rootClass" value=""/>
-->
<!-- 参考javaClientGenerator 的 rootInterface 属性
<property name="rootInterface" value=""/>
-->
<!-- 如果设置了runtimeCatalog,那么在生成的SQL中,使用该指定的catalog,而不是table元素上的catalog
<property name="runtimeCatalog" value=""/>
-->
<!-- 如果设置了runtimeSchema,那么在生成的SQL中,使用该指定的schema,而不是table元素上的schema
<property name="runtimeSchema" value=""/>
-->
<!-- 如果设置了runtimeTableName,那么在生成的SQL中,使用该指定的tablename,而不是table元素上的tablename
<property name="runtimeTableName" value=""/>
-->
<!-- 注意,该属性只针对MyBatis3Simple有用;
如果选择的runtime是MyBatis3Simple,那么会生成一个SelectAll方法,如果指定了selectAllOrderByClause,那么会在该SQL中添加指定的这个order条件;
-->
<property name="selectAllOrderByClause" value="age desc,username asc"/>
<!-- 如果设置为true,生成的model类会直接使用column本身的名字,而不会再使用驼峰命名方法,比如BORN_DATE,生成的属性名字就是BORN_DATE,而不会是bornDate -->
<property name="useActualColumnNames" value="false"/>
<!-- generatedKey用于生成生成主键的方法,
如果设置了该元素,MBG会在生成的<insert>元素中生成一条正确的<selectKey>元素,该元素可选
column:主键的列名;
sqlStatement:要生成的selectKey语句,有以下可选项:
Cloudscape:相当于selectKey的SQL为: VALUES IDENTITY_VAL_LOCAL()
DB2 :相当于selectKey的SQL为: VALUES IDENTITY_VAL_LOCAL()
DB2_MF :相当于selectKey的SQL为:SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1
Derby :相当于selectKey的SQL为:VALUES IDENTITY_VAL_LOCAL()
HSQLDB :相当于selectKey的SQL为:CALL IDENTITY()
Informix :相当于selectKey的SQL为:select dbinfo('sqlca.sqlerrd1') from systables where tabid=1
MySql :相当于selectKey的SQL为:SELECT LAST_INSERT_ID()
SqlServer :相当于selectKey的SQL为:SELECT SCOPE_IDENTITY()
SYBASE :相当于selectKey的SQL为:SELECT @@IDENTITY
JDBC :相当于在生成的insert元素上添加useGeneratedKeys="true"和keyProperty属性
<generatedKey column="" sqlStatement=""/>
-->
<!--
该元素会在根据表中列名计算对象属性名之前先重命名列名,非常适合用于表中的列都有公用的前缀字符串的时候,
比如列名为:CUST_ID,CUST_NAME,CUST_EMAIL,CUST_ADDRESS等;
那么就可以设置searchString为"^CUST_",并使用空白替换,那么生成的Customer对象中的属性名称就不是
custId,custName等,而是先被替换为ID,NAME,EMAIL,然后变成属性:id,name,email;
注意,MBG是使用java.util.regex.Matcher.replaceAll来替换searchString和replaceString的,
如果使用了columnOverride元素,该属性无效;
<columnRenamingRule searchString="" replaceString=""/>
-->
<!-- 用来修改表中某个列的属性,MBG会使用修改后的列来生成domain的属性;
column:要重新设置的列名;
注意,一个table元素中可以有多个columnOverride元素哈~
-->
<columnOverride column="username">
<!-- 使用property属性来指定列要生成的属性名称 -->
<property name="property" value="userName"/>
<!-- javaType用于指定生成的domain的属性类型,使用类型的全限定名
<property name="javaType" value=""/>
-->
<!-- jdbcType用于指定该列的JDBC类型
<property name="jdbcType" value=""/>
-->
<!-- typeHandler 用于指定该列使用到的TypeHandler,如果要指定,配置类型处理器的全限定名
注意,mybatis中,不会生成到mybatis-config.xml中的typeHandler
只会生成类似:where id = #{id,jdbcType=BIGINT,typeHandler=com._520it.mybatis.MyTypeHandler}的参数描述
<property name="jdbcType" value=""/>
-->
<!-- 参考table元素的delimitAllColumns配置,默认为false
<property name="delimitedColumnName" value=""/>
-->
</columnOverride>
<!-- ignoreColumn设置一个MGB忽略的列,如果设置了改列,那么在生成的domain中,生成的SQL中,都不会有该列出现
column:指定要忽略的列的名字;
delimitedColumnName:参考table元素的delimitAllColumns配置,默认为false
注意,一个table元素中可以有多个ignoreColumn元素
<ignoreColumn column="deptId" delimitedColumnName=""/>
-->
</table>
</context>
</generatorConfiguration>
```
\ No newline at end of file
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Oct 08 10:08:33 CST 2018. This element was generated on Mon Oct 08 10:08:33 CST 2018.
--> -->
<id column="ID" jdbcType="INTEGER" property="id"/> <id column="ID" jdbcType="VARCHAR" property="id"/>
<result column="NAME" jdbcType="VARCHAR" property="name"/> <result column="NAME" jdbcType="VARCHAR" property="name"/>
<result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/> <result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/>
<result column="LAST_UPDATE_TIME" jdbcType="TIMESTAMP" property="lastUpdateTime"/> <result column="LAST_UPDATE_TIME" jdbcType="TIMESTAMP" property="lastUpdateTime"/>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Oct 08 10:08:33 CST 2018. This element was generated on Mon Oct 08 10:08:33 CST 2018.
--> -->
<id column="ID" jdbcType="INTEGER" property="id" /> <id column="ID" jdbcType="VARCHAR" property="id" />
<result column="NAME" jdbcType="VARCHAR" property="name" /> <result column="NAME" jdbcType="VARCHAR" property="name" />
<result column="SORT" jdbcType="VARCHAR" property="sort" /> <result column="SORT" jdbcType="VARCHAR" property="sort" />
<result column="MODULE_ID" jdbcType="VARCHAR" property="moduleId" /> <result column="MODULE_ID" jdbcType="VARCHAR" property="moduleId" />
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Oct 08 10:08:33 CST 2018. This element was generated on Mon Oct 08 10:08:33 CST 2018.
--> -->
<id column="ID" jdbcType="INTEGER" property="id" /> <id column="ID" jdbcType="VARCHAR" property="id" />
<result column="NAME" jdbcType="VARCHAR" property="name" /> <result column="NAME" jdbcType="VARCHAR" property="name" />
<result column="URL" jdbcType="VARCHAR" property="url" /> <result column="URL" jdbcType="VARCHAR" property="url" />
<result column="GROUP_ID" jdbcType="VARCHAR" property="groupId" /> <result column="GROUP_ID" jdbcType="VARCHAR" property="groupId" />
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Oct 08 10:08:33 CST 2018. This element was generated on Mon Oct 08 10:08:33 CST 2018.
--> -->
<id column="ID" jdbcType="INTEGER" property="id" /> <id column="ID" jdbcType="VARCHAR" property="id" />
<result column="NAME" jdbcType="VARCHAR" property="name" /> <result column="NAME" jdbcType="VARCHAR" property="name" />
<result column="SORT" jdbcType="INTEGER" property="sort" /> <result column="SORT" jdbcType="INTEGER" property="sort" />
<result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime" /> <result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime" />
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Oct 08 10:08:33 CST 2018. This element was generated on Mon Oct 08 10:08:33 CST 2018.
--> -->
<id column="ID" jdbcType="INTEGER" property="id" /> <id column="ID" jdbcType="VARCHAR" property="id" />
<result column="NAME" jdbcType="VARCHAR" property="name" /> <result column="NAME" jdbcType="VARCHAR" property="name" />
<result column="DESCRIPTION" jdbcType="VARCHAR" property="description" /> <result column="DESCRIPTION" jdbcType="VARCHAR" property="description" />
<result column="MENU_ID" jdbcType="VARCHAR" property="menuId" /> <result column="MENU_ID" jdbcType="VARCHAR" property="menuId" />
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Oct 08 10:08:33 CST 2018. This element was generated on Mon Oct 08 10:08:33 CST 2018.
--> -->
<id column="ID" jdbcType="INTEGER" property="id" /> <id column="ID" jdbcType="VARCHAR" property="id" />
<result column="USERNAME" jdbcType="VARCHAR" property="username" /> <result column="USERNAME" jdbcType="VARCHAR" property="username" />
<result column="PASSWORD" jdbcType="VARCHAR" property="password" /> <result column="PASSWORD" jdbcType="VARCHAR" property="password" />
<result column="DEPT_ID" jdbcType="VARCHAR" property="deptId" /> <result column="DEPT_ID" jdbcType="VARCHAR" property="deptId" />
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Oct 08 10:08:33 CST 2018. This element was generated on Mon Oct 08 10:08:33 CST 2018.
--> -->
<id column="ID" jdbcType="INTEGER" property="id" /> <id column="ID" jdbcType="VARCHAR" property="id" />
<result column="NAME" jdbcType="VARCHAR" property="name" /> <result column="NAME" jdbcType="VARCHAR" property="name" />
<result column="ROLE_ID" jdbcType="VARCHAR" property="roleId" /> <result column="ROLE_ID" jdbcType="VARCHAR" property="roleId" />
<result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime" /> <result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime" />
...@@ -176,7 +176,7 @@ ...@@ -176,7 +176,7 @@
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
#{id,jdbcType=INTEGER}, #{id,jdbcType=VARCHAR},
</if> </if>
<if test="name != null"> <if test="name != null">
#{name,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
......
/*==============================================================*/
/* Database name: db_test */
/* DBMS name: MySQL 5.7 */
/* Created on: 2018/9/30 17:18:06 */
/*==============================================================*/
drop database if exists db_test;
/*==============================================================*/
/* Database: db_test */
/*==============================================================*/
create database db_test;
use db_test;
/*==============================================================*/
/* Table: TEST_ROLE_GROUP */
/*==============================================================*/
create table TEST_ROLE_GROUP
(
ID VARCHAR(255) not null,
NAME VARCHAR(30),
ROLE_ID VARCHAR(30),
CREATE_TIME DATETIME,
LAST_UPDATE_TIME DATETIME,
primary key(ID)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
alter table TEST_ROLE_GROUP comment '角色组';
/*==============================================================*/
/* Table: TES_DEPARTMENT */
/*==============================================================*/
create table TES_DEPARTMENT
(
ID VARCHAR(255) not null,
NAME VARCHAR(30),
CREATE_TIME DATETIME,
LAST_UPDATE_TIME DATETIME,
primary key(ID)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
alter table TES_DEPARTMENT comment '部门表';
/*==============================================================*/
/* Table: TES_MENU */
/*==============================================================*/
create table TES_MENU
(
ID VARCHAR(255) not null,
NAME VARCHAR(30),
URL VARCHAR(30),
GROUP_ID VARCHAR(30),
SORT INTEGER(10),
CREATE_TIME DATETIME,
LAST_UPDATE_TIME DATETIME,
primary key(ID)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
alter table TES_MENU comment '菜单表';
/*==============================================================*/
/* Table: TES_MENU_GROUP */
/*==============================================================*/
create table TES_MENU_GROUP
(
ID VARCHAR(255) not null,
NAME VARCHAR(30),
SORT VARCHAR(30),
MODULE_ID VARCHAR(30),
CREATE_TIME DATETIME,
LAST_UPDATE_TIME DATETIME,
primary key(ID)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
alter table TES_MENU_GROUP comment '模块组表';
/*==============================================================*/
/* Table: TES_MENU_MODULE */
/*==============================================================*/
create table TES_MENU_MODULE
(
ID VARCHAR(255) not null,
NAME VARCHAR(30),
SORT INTEGER(10),
CREATE_TIME DATETIME,
LAST_UPDATE_TIME DATETIME,
primary key(ID)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
alter table TES_MENU_MODULE comment '菜单模块表';
/*==============================================================*/
/* Table: TES_ROLE */
/*==============================================================*/
create table TES_ROLE
(
ID VARCHAR(255) not null,
NAME VARCHAR(30),
DESCRIPTION VARCHAR(30),
MENU_ID VARCHAR(20),
CREATE_DATE DATETIME,
LAST_UPDATE_TIME DATETIME,
primary key(ID)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
alter table TES_ROLE comment '角色表';
/*==============================================================*/
/* Table: TES_USER */
/*==============================================================*/
create table TES_USER
(
ID VARCHAR(255) not null,
USERNAME VARCHAR(32),
PASSWORD VARCHAR(30),
DEPT_ID VARCHAR(32),
STATUS VARCHAR(22),
ROLES_GROUP VARCHAR(32),
CREATE_TIME DATETIME,
LAST_UPDATE_TIME DATETIME,
primary key(ID)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
alter table TES_USER comment '用户表';
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment