Commit 4bdfca59 by WOSHINPC

修复BigDecimal未导包问题

添加moduleName配置,用于分模块创建代码,使原本固定生成在generator下改为可配置
添加mainPath配置,当使用者将人人项目的包名io.renren改为其他时,需配置此项
parent f1bbec38
#\u4EE3\u7801\u751F\u6210\u5668\uFF0C\u914D\u7F6E\u4FE1\u606F
mainPath=io.renren
#\u5305\u540D
package=io.renren.modules.generator
package=io.renren.modules
moduleName=generator
#\u4F5C\u8005
author=chenshun
#Email
......
package ${package}.controller;
package ${package}.${moduleName}.controller;
import java.util.List;
import java.util.Map;
......@@ -11,11 +11,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import ${package}.entity.${className}Entity;
import ${package}.service.${className}Service;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;
import ${package}.${moduleName}.entity.${className}Entity;
import ${package}.${moduleName}.service.${className}Service;
import ${mainPath}.common.utils.PageUtils;
import ${mainPath}.common.utils.Query;
import ${mainPath}.common.utils.R;
......@@ -28,7 +28,7 @@ import io.renren.common.utils.R;
* @date ${datetime}
*/
@RestController
@RequestMapping("${pathName}")
@RequestMapping("/${moduleName}/${pathName}")
public class ${className}Controller {
@Autowired
private ${className}Service ${classname}Service;
......@@ -37,7 +37,7 @@ public class ${className}Controller {
* 列表
*/
@RequestMapping("/list")
@RequiresPermissions("${pathName}:list")
@RequiresPermissions("${moduleName}:${pathName}:list")
public R list(@RequestParam Map<String, Object> params){
//查询列表数据
Query query = new Query(params);
......@@ -55,7 +55,7 @@ public class ${className}Controller {
* 信息
*/
@RequestMapping("/info/{${pk.attrname}}")
@RequiresPermissions("${pathName}:info")
@RequiresPermissions("${moduleName}:${pathName}:info")
public R info(@PathVariable("${pk.attrname}") ${pk.attrType} ${pk.attrname}){
${className}Entity ${classname} = ${classname}Service.queryObject(${pk.attrname});
......@@ -66,7 +66,7 @@ public class ${className}Controller {
* 保存
*/
@RequestMapping("/save")
@RequiresPermissions("${pathName}:save")
@RequiresPermissions("${moduleName}:${pathName}:save")
public R save(@RequestBody ${className}Entity ${classname}){
${classname}Service.save(${classname});
......@@ -77,7 +77,7 @@ public class ${className}Controller {
* 修改
*/
@RequestMapping("/update")
@RequiresPermissions("${pathName}:update")
@RequiresPermissions("${moduleName}:${pathName}:update")
public R update(@RequestBody ${className}Entity ${classname}){
${classname}Service.update(${classname});
......@@ -88,7 +88,7 @@ public class ${className}Controller {
* 删除
*/
@RequestMapping("/delete")
@RequiresPermissions("${pathName}:delete")
@RequiresPermissions("${moduleName}:${pathName}:delete")
public R delete(@RequestBody ${pk.attrType}[] ${pk.attrname}s){
${classname}Service.deleteBatch(${pk.attrname}s);
......
package ${package}.dao;
package ${package}.${moduleName}.dao;
import ${package}.entity.${className}Entity;
import io.renren.modules.sys.dao.BaseDao;
import ${package}.${moduleName}.entity.${className}Entity;
import ${mainPath}.modules.sys.dao.BaseDao;
import org.apache.ibatis.annotations.Mapper;
/**
......
<?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}.dao.${className}Dao">
<mapper namespace="${package}.${moduleName}.dao.${className}Dao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="${package}.entity.${className}Entity" id="${classname}Map">
<resultMap type="${package}.${moduleName}.entity.${className}Entity" id="${classname}Map">
#foreach($column in $columns)
<result property="${column.attrname}" column="${column.columnName}"/>
#end
</resultMap>
<select id="queryObject" resultType="${package}.entity.${className}Entity">
<select id="queryObject" resultType="${package}.${moduleName}.entity.${className}Entity">
select * from ${tableName} where ${pk.columnName} = #{value}
</select>
<select id="queryList" resultType="${package}.entity.${className}Entity">
<select id="queryList" resultType="${package}.${moduleName}.entity.${className}Entity">
select * from ${tableName}
<choose>
<when test="sidx != null and sidx.trim() != ''">
......@@ -33,7 +33,7 @@
select count(*) from ${tableName}
</select>
<insert id="save" parameterType="${package}.entity.${className}Entity"#if($pk.extra == 'auto_increment') useGeneratedKeys="true" keyProperty="$pk.attrname"#end>
<insert id="save" parameterType="${package}.${moduleName}.entity.${className}Entity"#if($pk.extra == 'auto_increment') useGeneratedKeys="true" keyProperty="$pk.attrname"#end>
insert into ${tableName}
(
#foreach($column in $columns)
......@@ -54,7 +54,7 @@
)
</insert>
<update id="update" parameterType="${package}.entity.${className}Entity">
<update id="update" parameterType="${package}.${moduleName}.entity.${className}Entity">
update ${tableName}
<set>
#foreach($column in $columns)
......
package ${package}.entity;
package ${package}.${moduleName}.entity;
import java.io.Serializable;
import java.util.Date;
#if(${hasBigDecimal})
import java.math.BigDecimal;
#end
......
package ${package}.service;
package ${package}.${moduleName}.service;
import ${package}.entity.${className}Entity;
import ${package}.${moduleName}.entity.${className}Entity;
import java.util.List;
import java.util.Map;
......
package ${package}.service.impl;
package ${package}.${moduleName}.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -6,9 +6,9 @@ import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import ${package}.dao.${className}Dao;
import ${package}.entity.${className}Entity;
import ${package}.service.${className}Service;
import ${package}.${moduleName}.dao.${className}Dao;
import ${package}.${moduleName}.entity.${className}Entity;
import ${package}.${moduleName}.service.${className}Service;
......
......@@ -23,9 +23,9 @@
<div id="rrapp" v-cloak>
<div v-show="showList">
<div class="grid-btn">
<a v-if="hasPermission('${pathName}:save')" class="btn btn-primary" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</a>
<a v-if="hasPermission('${pathName}:update')" class="btn btn-primary" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>
<a v-if="hasPermission('${pathName}:delete')" class="btn btn-primary" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
<a v-if="hasPermission('${moduleName}:${pathName}:save')" class="btn btn-primary" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</a>
<a v-if="hasPermission('${moduleName}:${pathName}:update')" class="btn btn-primary" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>
<a v-if="hasPermission('${moduleName}:${pathName}:delete')" class="btn btn-primary" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
</div>
<table id="jqGrid"></table>
<div id="jqGridPager"></div>
......@@ -53,6 +53,6 @@
</div>
</div>
<script src="../../js/modules/generator/${pathName}.js"></script>
<script src="../../js/modules/${moduleName}/${pathName}.js"></script>
</body>
</html>
\ No newline at end of file
$(function () {
$("#jqGrid").jqGrid({
url: baseURL + '${pathName}/list',
url: baseURL + '${moduleName}/${pathName}/list',
datatype: "json",
colModel: [
#foreach($column in $columns)
......@@ -66,7 +66,7 @@ var vm = new Vue({
vm.getInfo(${pk.attrname})
},
saveOrUpdate: function (event) {
var url = vm.${classname}.${pk.attrname} == null ? "${pathName}/save" : "${pathName}/update";
var url = vm.${classname}.${pk.attrname} == null ? "${moduleName}/${pathName}/save" : "${moduleName}/${pathName}/update";
$.ajax({
type: "POST",
url: baseURL + url,
......@@ -92,7 +92,7 @@ var vm = new Vue({
confirm('确定要删除选中的记录?', function(){
$.ajax({
type: "POST",
url: baseURL + "${pathName}/delete",
url: baseURL + "${moduleName}/${pathName}/delete",
contentType: "application/json",
data: JSON.stringify(${pk.attrname}s),
success: function(r){
......@@ -108,7 +108,7 @@ var vm = new Vue({
});
},
getInfo: function(${pk.attrname}){
$.get(baseURL + "${pathName}/info/"+${pk.attrname}, function(r){
$.get(baseURL + "${moduleName}/${pathName}/info/"+${pk.attrname}, function(r){
vm.${classname} = r.${classname};
});
},
......
-- 菜单SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('1', '${comments}', 'modules/generator/${pathName}.html', NULL, '1', 'fa fa-file-code-o', '6');
VALUES ('1', '${comments}', 'modules/${moduleName}/${pathName}.html', NULL, '1', 'fa fa-file-code-o', '6');
-- 按钮父菜单ID
set @parentId = @@identity;
-- 菜单对应按钮SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '查看', null, '${pathName}:list,${pathName}:info', '2', null, '6';
SELECT @parentId, '查看', null, '${moduleName}:${pathName}:list,${pathName}:info', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '新增', null, '${pathName}:save', '2', null, '6';
SELECT @parentId, '新增', null, '${moduleName}:${pathName}:save', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '修改', null, '${pathName}:update', '2', null, '6';
SELECT @parentId, '修改', null, '${moduleName}:${pathName}:update', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '删除', null, '${pathName}:delete', '2', null, '6';
SELECT @parentId, '删除', null, '${moduleName}:${pathName}:delete', '2', null, '6';
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