代码生成路径调整
This commit is contained in:
@ -20,7 +20,7 @@ import com.ruoyi.generator.domain.TableInfo;
|
||||
public class GenUtils
|
||||
{
|
||||
/** 项目空间路径 */
|
||||
private static final String PROJECT_PATH = "main/java/com/ruoyi/project";
|
||||
private static final String PROJECT_PATH = "main/java/com/ruoyi";
|
||||
|
||||
/** mybatis空间路径 */
|
||||
private static final String MYBATIS_PATH = "main/resources/mybatis";
|
||||
@ -71,7 +71,7 @@ public class GenUtils
|
||||
velocityContext.put("classname", table.getClassname());
|
||||
velocityContext.put("moduleName", GenUtils.getModuleName(packageName));
|
||||
velocityContext.put("columns", table.getColumns());
|
||||
velocityContext.put("package", packageName + "." + table.getClassname());
|
||||
velocityContext.put("package", packageName);
|
||||
velocityContext.put("author", Global.getAuthor());
|
||||
velocityContext.put("datetime", DateUtils.getDate());
|
||||
return velocityContext;
|
||||
@ -85,16 +85,16 @@ public class GenUtils
|
||||
public static List<String> getTemplates()
|
||||
{
|
||||
List<String> templates = new ArrayList<String>();
|
||||
templates.add("templates/vm/java/domain.java.vm");
|
||||
templates.add("templates/vm/java/Mapper.java.vm");
|
||||
templates.add("templates/vm/java/Service.java.vm");
|
||||
templates.add("templates/vm/java/ServiceImpl.java.vm");
|
||||
templates.add("templates/vm/java/Controller.java.vm");
|
||||
templates.add("templates/vm/xml/Mapper.xml.vm");
|
||||
templates.add("templates/vm/html/list.html.vm");
|
||||
templates.add("templates/vm/html/add.html.vm");
|
||||
templates.add("templates/vm/html/edit.html.vm");
|
||||
templates.add("templates/vm/sql/sql.vm");
|
||||
templates.add("vm/java/domain.java.vm");
|
||||
templates.add("vm/java/Mapper.java.vm");
|
||||
templates.add("vm/java/Service.java.vm");
|
||||
templates.add("vm/java/ServiceImpl.java.vm");
|
||||
templates.add("vm/java/Controller.java.vm");
|
||||
templates.add("vm/xml/Mapper.xml.vm");
|
||||
templates.add("vm/html/list.html.vm");
|
||||
templates.add("vm/html/add.html.vm");
|
||||
templates.add("vm/html/edit.html.vm");
|
||||
templates.add("vm/sql/sql.vm");
|
||||
return templates;
|
||||
}
|
||||
|
||||
@ -127,11 +127,6 @@ public class GenUtils
|
||||
String mybatisPath = MYBATIS_PATH + "/" + moduleName + "/" + className;
|
||||
String htmlPath = TEMPLATES_PATH + "/" + moduleName + "/" + classname;
|
||||
|
||||
if (StringUtils.isNotEmpty(classname))
|
||||
{
|
||||
javaPath += classname.replace(".", "/") + "/";
|
||||
}
|
||||
|
||||
if (template.contains("domain.java.vm"))
|
||||
{
|
||||
return javaPath + "domain" + "/" + className + ".java";
|
||||
@ -229,6 +224,6 @@ public class GenUtils
|
||||
{
|
||||
System.out.println(StringUtils.convertToCamelCase("user_name"));
|
||||
System.out.println(replaceKeyword("岗位信息表"));
|
||||
System.out.println(getModuleName("com.ruoyi.project.system"));
|
||||
System.out.println(getModuleName("com.ruoyi.system"));
|
||||
}
|
||||
}
|
||||
|
38
ruoyi-generator/src/main/resources/vm/html/add.html.vm
Normal file
38
ruoyi-generator/src/main/resources/vm/html/add.html.vm
Normal file
@ -0,0 +1,38 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
|
||||
<meta charset="utf-8">
|
||||
<head th:include="include :: header"></head>
|
||||
<body class="white-bg">
|
||||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||
<form class="form-horizontal m" id="form-${classname}-add">
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $primaryKey.columnName)
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">${column.columnComment}:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="${column.attrname}" name="${column.attrname}" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
#end
|
||||
#end
|
||||
</form>
|
||||
</div>
|
||||
<div th:include="include::footer"></div>
|
||||
<script type="text/javascript">
|
||||
var prefix = ctx + "${moduleName}/${classname}"
|
||||
$("#form-${classname}-add").validate({
|
||||
rules:{
|
||||
xxxx:{
|
||||
required:true,
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
function submitHandler() {
|
||||
if ($.validate.form()) {
|
||||
$.operate.save(prefix + "/add", $('#form-${classname}-add').serialize());
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
39
ruoyi-generator/src/main/resources/vm/html/edit.html.vm
Normal file
39
ruoyi-generator/src/main/resources/vm/html/edit.html.vm
Normal file
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
|
||||
<meta charset="utf-8">
|
||||
<head th:include="include :: header"></head>
|
||||
<body class="white-bg">
|
||||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||
<form class="form-horizontal m" id="form-${classname}-edit" th:object="${${classname}}">
|
||||
<input id="${primaryKey.attrname}" name="${primaryKey.attrname}" th:field="*{${primaryKey.attrname}}" type="hidden">
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $primaryKey.columnName)
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">${column.columnComment}:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="${column.attrname}" name="${column.attrname}" th:field="*{${column.attrname}}" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
#end
|
||||
#end
|
||||
</form>
|
||||
</div>
|
||||
<div th:include="include::footer"></div>
|
||||
<script type="text/javascript">
|
||||
var prefix = ctx + "${moduleName}/${classname}"
|
||||
$("#form-${classname}-edit").validate({
|
||||
rules:{
|
||||
xxxx:{
|
||||
required:true,
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
function submitHandler() {
|
||||
if ($.validate.form()) {
|
||||
$.operate.save(prefix + "/edit", $('#form-${classname}-edit').serialize());
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
60
ruoyi-generator/src/main/resources/vm/html/list.html.vm
Normal file
60
ruoyi-generator/src/main/resources/vm/html/list.html.vm
Normal file
@ -0,0 +1,60 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
||||
<meta charset="utf-8">
|
||||
<head th:include="include :: header"></head>
|
||||
<body class="gray-bg">
|
||||
<div class="container-div">
|
||||
<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
|
||||
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="${moduleName}:${classname}:add">
|
||||
<i class="fa fa-plus"></i> 添加
|
||||
</a>
|
||||
<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="${moduleName}:${classname}:edit">
|
||||
<i class="fa fa-edit"></i> 修改
|
||||
</a>
|
||||
<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="${moduleName}:${classname}:remove">
|
||||
<i class="fa fa-remove"></i> 删除
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table" data-mobile-responsive="true"></table>
|
||||
</div>
|
||||
</div>
|
||||
<div th:include="include :: footer"></div>
|
||||
<script th:inline="javascript">
|
||||
var editFlag = [[${@permission.hasPermi('${moduleName}:${classname}:edit')}]];
|
||||
var removeFlag = [[${@permission.hasPermi('${moduleName}:${classname}:remove')}]];
|
||||
var prefix = ctx + "${moduleName}/${classname}";
|
||||
|
||||
$(function() {
|
||||
var options = {
|
||||
url: prefix + "/list",
|
||||
createUrl: prefix + "/add",
|
||||
updateUrl: prefix + "/edit/{id}",
|
||||
removeUrl: prefix + "/remove",
|
||||
modalName: "${tableComment}",
|
||||
columns: [{
|
||||
checkbox: true
|
||||
},
|
||||
#foreach($column in $columns)
|
||||
{
|
||||
field : '${column.attrname}',
|
||||
title : '${column.columnComment}'
|
||||
},
|
||||
#end
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.${primaryKey.attrname} + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.${primaryKey.attrname} + '\')"><i class="fa fa-remove"></i>删除</a>');
|
||||
return actions.join('');
|
||||
}
|
||||
}]
|
||||
};
|
||||
$.table.init(options);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
112
ruoyi-generator/src/main/resources/vm/java/Controller.java.vm
Normal file
112
ruoyi-generator/src/main/resources/vm/java/Controller.java.vm
Normal file
@ -0,0 +1,112 @@
|
||||
package ${package}.web.controller;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import ${package}.domain.${className};
|
||||
import ${package}.service.I${className}Service;
|
||||
import com.ruoyi.web.core.base.BaseController;
|
||||
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||
import com.ruoyi.common.base.AjaxResult;
|
||||
|
||||
/**
|
||||
* ${tableComment} 信息操作处理
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/${moduleName}/${classname}")
|
||||
public class ${className}Controller extends BaseController
|
||||
{
|
||||
private String prefix = "${moduleName}/${classname}";
|
||||
|
||||
@Autowired
|
||||
private I${className}Service ${classname}Service;
|
||||
|
||||
@RequiresPermissions("${moduleName}:${classname}:view")
|
||||
@GetMapping()
|
||||
public String ${classname}()
|
||||
{
|
||||
return prefix + "/${classname}";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询${tableComment}列表
|
||||
*/
|
||||
@RequiresPermissions("${moduleName}:${classname}:list")
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public TableDataInfo list(${className} ${classname})
|
||||
{
|
||||
startPage();
|
||||
List<${className}> list = ${classname}Service.select${className}List(${classname});
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增${tableComment}
|
||||
*/
|
||||
@GetMapping("/add")
|
||||
public String add()
|
||||
{
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存${tableComment}
|
||||
*/
|
||||
@RequiresPermissions("${moduleName}:${classname}:add")
|
||||
@Log(title = "${tableComment}", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(${className} ${classname})
|
||||
{
|
||||
return toAjax(${classname}Service.insert${className}(${classname}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改${tableComment}
|
||||
*/
|
||||
@GetMapping("/edit/{${primaryKey.attrname}}")
|
||||
public String edit(@PathVariable("${primaryKey.attrname}") ${primaryKey.attrType} ${primaryKey.attrname}, ModelMap mmap)
|
||||
{
|
||||
${className} ${classname} = ${classname}Service.select${className}ById(${primaryKey.attrname});
|
||||
mmap.put("${classname}", ${classname});
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存${tableComment}
|
||||
*/
|
||||
@RequiresPermissions("${moduleName}:${classname}:edit")
|
||||
@Log(title = "${tableComment}", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(${className} ${classname})
|
||||
{
|
||||
return toAjax(${classname}Service.update${className}(${classname}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除${tableComment}
|
||||
*/
|
||||
@RequiresPermissions("${moduleName}:${classname}:remove")
|
||||
@Log(title = "${tableComment}", businessType = BusinessType.DELETE)
|
||||
@PostMapping( "/remove")
|
||||
@ResponseBody
|
||||
public AjaxResult remove(String ids)
|
||||
{
|
||||
return toAjax(${classname}Service.delete${className}ByIds(ids));
|
||||
}
|
||||
|
||||
}
|
62
ruoyi-generator/src/main/resources/vm/java/Mapper.java.vm
Normal file
62
ruoyi-generator/src/main/resources/vm/java/Mapper.java.vm
Normal file
@ -0,0 +1,62 @@
|
||||
package ${package}.mapper;
|
||||
|
||||
import ${package}.domain.${className};
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${tableComment} 数据层
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
public interface ${className}Mapper
|
||||
{
|
||||
/**
|
||||
* 查询${tableComment}信息
|
||||
*
|
||||
* @param ${primaryKey.attrname} ${tableComment}ID
|
||||
* @return ${tableComment}信息
|
||||
*/
|
||||
public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname});
|
||||
|
||||
/**
|
||||
* 查询${tableComment}列表
|
||||
*
|
||||
* @param ${classname} ${tableComment}信息
|
||||
* @return ${tableComment}集合
|
||||
*/
|
||||
public List<${className}> select${className}List(${className} ${classname});
|
||||
|
||||
/**
|
||||
* 新增${tableComment}
|
||||
*
|
||||
* @param ${classname} ${tableComment}信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insert${className}(${className} ${classname});
|
||||
|
||||
/**
|
||||
* 修改${tableComment}
|
||||
*
|
||||
* @param ${classname} ${tableComment}信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int update${className}(${className} ${classname});
|
||||
|
||||
/**
|
||||
* 删除${tableComment}
|
||||
*
|
||||
* @param ${primaryKey.attrname} ${tableComment}ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${className}ById(${primaryKey.attrType} ${primaryKey.attrname});
|
||||
|
||||
/**
|
||||
* 批量删除${tableComment}
|
||||
*
|
||||
* @param ${primaryKey.attrname}s 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${className}ByIds(String[] ${primaryKey.attrname}s);
|
||||
|
||||
}
|
54
ruoyi-generator/src/main/resources/vm/java/Service.java.vm
Normal file
54
ruoyi-generator/src/main/resources/vm/java/Service.java.vm
Normal file
@ -0,0 +1,54 @@
|
||||
package ${package}.service;
|
||||
|
||||
import ${package}.domain.${className};
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${tableComment} 服务层
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
public interface I${className}Service
|
||||
{
|
||||
/**
|
||||
* 查询${tableComment}信息
|
||||
*
|
||||
* @param ${primaryKey.attrname} ${tableComment}ID
|
||||
* @return ${tableComment}信息
|
||||
*/
|
||||
public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname});
|
||||
|
||||
/**
|
||||
* 查询${tableComment}列表
|
||||
*
|
||||
* @param ${classname} ${tableComment}信息
|
||||
* @return ${tableComment}集合
|
||||
*/
|
||||
public List<${className}> select${className}List(${className} ${classname});
|
||||
|
||||
/**
|
||||
* 新增${tableComment}
|
||||
*
|
||||
* @param ${classname} ${tableComment}信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insert${className}(${className} ${classname});
|
||||
|
||||
/**
|
||||
* 修改${tableComment}
|
||||
*
|
||||
* @param ${classname} ${tableComment}信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int update${className}(${className} ${classname});
|
||||
|
||||
/**
|
||||
* 删除${tableComment}信息
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${className}ByIds(String ids);
|
||||
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package ${package}.service;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ${package}.mapper.${className}Mapper;
|
||||
import ${package}.domain.${className};
|
||||
import ${package}.service.I${className}Service;
|
||||
import com.ruoyi.common.support.Convert;
|
||||
|
||||
/**
|
||||
* ${tableComment} 服务层实现
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Service
|
||||
public class ${className}ServiceImpl implements I${className}Service
|
||||
{
|
||||
@Autowired
|
||||
private ${className}Mapper ${classname}Mapper;
|
||||
|
||||
/**
|
||||
* 查询${tableComment}信息
|
||||
*
|
||||
* @param ${primaryKey.attrname} ${tableComment}ID
|
||||
* @return ${tableComment}信息
|
||||
*/
|
||||
@Override
|
||||
public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname})
|
||||
{
|
||||
return ${classname}Mapper.select${className}ById(${primaryKey.attrname});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询${tableComment}列表
|
||||
*
|
||||
* @param ${classname} ${tableComment}信息
|
||||
* @return ${tableComment}集合
|
||||
*/
|
||||
@Override
|
||||
public List<${className}> select${className}List(${className} ${classname})
|
||||
{
|
||||
return ${classname}Mapper.select${className}List(${classname});
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增${tableComment}
|
||||
*
|
||||
* @param ${classname} ${tableComment}信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insert${className}(${className} ${classname})
|
||||
{
|
||||
return ${classname}Mapper.insert${className}(${classname});
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改${tableComment}
|
||||
*
|
||||
* @param ${classname} ${tableComment}信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int update${className}(${className} ${classname})
|
||||
{
|
||||
return ${classname}Mapper.update${className}(${classname});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除${tableComment}对象
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int delete${className}ByIds(String ids)
|
||||
{
|
||||
return ${classname}Mapper.delete${className}ByIds(Convert.toStrArray(ids));
|
||||
}
|
||||
|
||||
}
|
47
ruoyi-generator/src/main/resources/vm/java/domain.java.vm
Normal file
47
ruoyi-generator/src/main/resources/vm/java/domain.java.vm
Normal file
@ -0,0 +1,47 @@
|
||||
package ${package}.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.base.BaseEntity;
|
||||
#foreach ($column in $columns)
|
||||
#if($column.attrType == 'Date')
|
||||
import java.util.Date;
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${tableComment}表 ${tableName}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
public class ${className} extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
#foreach ($column in $columns)
|
||||
/** $column.columnComment */
|
||||
private $column.attrType $column.attrname;
|
||||
#end
|
||||
|
||||
#foreach ($column in $columns)
|
||||
public void set${column.attrName}($column.attrType $column.attrname)
|
||||
{
|
||||
this.$column.attrname = $column.attrname;
|
||||
}
|
||||
|
||||
public $column.attrType get${column.attrName}()
|
||||
{
|
||||
return $column.attrname;
|
||||
}
|
||||
#end
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
#foreach ($column in $columns)
|
||||
.append("${column.attrname}", get${column.attrName}())
|
||||
#end
|
||||
.toString();
|
||||
}
|
||||
}
|
19
ruoyi-generator/src/main/resources/vm/sql/sql.vm
Normal file
19
ruoyi-generator/src/main/resources/vm/sql/sql.vm
Normal file
@ -0,0 +1,19 @@
|
||||
-- 菜单 SQL
|
||||
insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${tableComment}', '3', '1', '/${moduleName}/${classname}', 'C', '0', '${moduleName}:${classname}:view', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${tableComment}菜单');
|
||||
|
||||
-- 按钮父菜单ID
|
||||
SELECT @parentId := LAST_INSERT_ID();
|
||||
|
||||
-- 按钮 SQL
|
||||
insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${tableComment}查询', @parentId, '1', '#', 'F', '0', '${moduleName}:${classname}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${tableComment}新增', @parentId, '2', '#', 'F', '0', '${moduleName}:${classname}:add', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${tableComment}修改', @parentId, '3', '#', 'F', '0', '${moduleName}:${classname}:edit', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${tableComment}删除', @parentId, '4', '#', 'F', '0', '${moduleName}:${classname}:remove', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
|
72
ruoyi-generator/src/main/resources/vm/xml/Mapper.xml.vm
Normal file
72
ruoyi-generator/src/main/resources/vm/xml/Mapper.xml.vm
Normal file
@ -0,0 +1,72 @@
|
||||
<?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="${package}.mapper.${className}Mapper">
|
||||
|
||||
<resultMap type="${className}" id="${className}Result">
|
||||
#foreach ($column in $columns)
|
||||
<result property="${column.attrname}" column="${column.columnName}" />
|
||||
#end
|
||||
</resultMap>
|
||||
|
||||
<sql id="select${className}Vo">
|
||||
select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
|
||||
</sql>
|
||||
|
||||
<select id="select${className}List" parameterType="${className}" resultMap="${className}Result">
|
||||
<include refid="select${className}Vo"/>
|
||||
<where>
|
||||
#foreach($column in $columns)
|
||||
<if test="$column.attrname != null #if($column.attrType == 'String' ) and $column.attrname.trim() != '' #end"> and $column.columnName = #{$column.attrname}</if>
|
||||
#end
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="select${className}ById" parameterType="${primaryKey.attrType}" resultMap="${className}Result">
|
||||
<include refid="select${className}Vo"/>
|
||||
where ${primaryKey.columnName} = #{${primaryKey.attrname}}
|
||||
</select>
|
||||
|
||||
<insert id="insert${className}" parameterType="${className}"#if($primaryKey.extra == 'auto_increment') useGeneratedKeys="true" keyProperty="$primaryKey.attrname"#end>
|
||||
insert into ${tableName}
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $primaryKey.columnName || $primaryKey.extra != 'auto_increment')
|
||||
<if test="$column.attrname != null #if($column.attrType == 'String' ) and $column.attrname != '' #end ">$column.columnName,</if>
|
||||
#end
|
||||
#end
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $primaryKey.columnName || $primaryKey.extra != 'auto_increment')
|
||||
<if test="$column.attrname != null #if($column.attrType == 'String' ) and $column.attrname != '' #end ">#{$column.attrname},</if>
|
||||
#end
|
||||
#end
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="update${className}" parameterType="${className}">
|
||||
update ${tableName}
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $primaryKey.columnName)
|
||||
<if test="$column.attrname != null #if($column.attrType == 'String' ) and $column.attrname != '' #end ">$column.columnName = #{$column.attrname},</if>
|
||||
#end
|
||||
#end
|
||||
</trim>
|
||||
where ${primaryKey.columnName} = #{${primaryKey.attrname}}
|
||||
</update>
|
||||
|
||||
<delete id="delete${className}ById" parameterType="${primaryKey.attrType}">
|
||||
delete from ${tableName} where ${primaryKey.columnName} = #{${primaryKey.attrname}}
|
||||
</delete>
|
||||
|
||||
<delete id="delete${className}ByIds" parameterType="String">
|
||||
delete from ${tableName} where ${primaryKey.columnName} in
|
||||
<foreach item="${primaryKey.attrname}" collection="array" open="(" separator="," close=")">
|
||||
#{${primaryKey.attrname}}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user