Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finance-manage
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
finance-oa
finance-manage
Commits
14a85989
Commit
14a85989
authored
Jan 08, 2021
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码生成模板支持主子表
parent
f3cb18c8
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
620 additions
and
59 deletions
+620
-59
ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java
...src/main/java/com/ruoyi/common/constant/GenConstants.java
+3
-0
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java
...in/java/com/ruoyi/generator/controller/GenController.java
+2
-0
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java
...or/src/main/java/com/ruoyi/generator/domain/GenTable.java
+50
-1
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java
.../main/java/com/ruoyi/generator/domain/GenTableColumn.java
+5
-0
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java
.../main/java/com/ruoyi/generator/mapper/GenTableMapper.java
+7
-0
ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
...java/com/ruoyi/generator/service/GenTableServiceImpl.java
+70
-13
ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java
...in/java/com/ruoyi/generator/service/IGenTableService.java
+7
-0
ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java
...in/java/com/ruoyi/generator/util/VelocityInitializer.java
+1
-1
ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
...src/main/java/com/ruoyi/generator/util/VelocityUtils.java
+41
-4
ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml
...or/src/main/resources/mapper/generator/GenTableMapper.xml
+33
-21
ruoyi-generator/src/main/resources/vm/java/controller.java.vm
...i-generator/src/main/resources/vm/java/controller.java.vm
+2
-2
ruoyi-generator/src/main/resources/vm/java/domain.java.vm
ruoyi-generator/src/main/resources/vm/java/domain.java.vm
+22
-2
ruoyi-generator/src/main/resources/vm/java/mapper.java.vm
ruoyi-generator/src/main/resources/vm/java/mapper.java.vm
+30
-0
ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm
...-generator/src/main/resources/vm/java/serviceImpl.java.vm
+57
-0
ruoyi-generator/src/main/resources/vm/java/sub-domain.java.vm
...i-generator/src/main/resources/vm/java/sub-domain.java.vm
+76
-0
ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm
ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm
+1
-1
ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
+87
-4
ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm
ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm
+41
-1
ruoyi-ui/src/views/tool/gen/editTable.vue
ruoyi-ui/src/views/tool/gen/editTable.vue
+4
-1
ruoyi-ui/src/views/tool/gen/genInfoForm.vue
ruoyi-ui/src/views/tool/gen/genInfoForm.vue
+78
-7
ruoyi-ui/src/views/tool/gen/index.vue
ruoyi-ui/src/views/tool/gen/index.vue
+1
-1
sql/ry_20210108.sql
sql/ry_20210108.sql
+2
-0
No files found.
ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java
View file @
14a85989
...
@@ -13,6 +13,9 @@ public class GenConstants
...
@@ -13,6 +13,9 @@ public class GenConstants
/** 树表(增删改查) */
/** 树表(增删改查) */
public
static
final
String
TPL_TREE
=
"tree"
;
public
static
final
String
TPL_TREE
=
"tree"
;
/** 主子表(增删改查) */
public
static
final
String
TPL_SUB
=
"sub"
;
/** 树编码字段 */
/** 树编码字段 */
public
static
final
String
TREE_CODE
=
"treeCode"
;
public
static
final
String
TREE_CODE
=
"treeCode"
;
...
...
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java
View file @
14a85989
...
@@ -63,10 +63,12 @@ public class GenController extends BaseController
...
@@ -63,10 +63,12 @@ public class GenController extends BaseController
public
AjaxResult
getInfo
(
@PathVariable
Long
talbleId
)
public
AjaxResult
getInfo
(
@PathVariable
Long
talbleId
)
{
{
GenTable
table
=
genTableService
.
selectGenTableById
(
talbleId
);
GenTable
table
=
genTableService
.
selectGenTableById
(
talbleId
);
List
<
GenTable
>
tables
=
genTableService
.
selectGenTableAll
();
List
<
GenTableColumn
>
list
=
genTableColumnService
.
selectGenTableColumnListByTableId
(
talbleId
);
List
<
GenTableColumn
>
list
=
genTableColumnService
.
selectGenTableColumnListByTableId
(
talbleId
);
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"info"
,
table
);
map
.
put
(
"info"
,
table
);
map
.
put
(
"rows"
,
list
);
map
.
put
(
"rows"
,
list
);
map
.
put
(
"tables"
,
tables
);
return
AjaxResult
.
success
(
map
);
return
AjaxResult
.
success
(
map
);
}
}
...
...
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java
View file @
14a85989
...
@@ -28,11 +28,17 @@ public class GenTable extends BaseEntity
...
@@ -28,11 +28,17 @@ public class GenTable extends BaseEntity
@NotBlank
(
message
=
"表描述不能为空"
)
@NotBlank
(
message
=
"表描述不能为空"
)
private
String
tableComment
;
private
String
tableComment
;
/** 关联父表的表名 */
private
String
subTableName
;
/** 本表关联父表的外键名 */
private
String
subTableFkName
;
/** 实体类名称(首字母大写) */
/** 实体类名称(首字母大写) */
@NotBlank
(
message
=
"实体类名称不能为空"
)
@NotBlank
(
message
=
"实体类名称不能为空"
)
private
String
className
;
private
String
className
;
/** 使用的模板(crud单表操作 tree树表操作) */
/** 使用的模板(crud单表操作 tree树表操作
sub主子表操作
) */
private
String
tplCategory
;
private
String
tplCategory
;
/** 生成包路径 */
/** 生成包路径 */
...
@@ -64,6 +70,9 @@ public class GenTable extends BaseEntity
...
@@ -64,6 +70,9 @@ public class GenTable extends BaseEntity
/** 主键信息 */
/** 主键信息 */
private
GenTableColumn
pkColumn
;
private
GenTableColumn
pkColumn
;
/** 子表信息 */
private
GenTable
subTable
;
/** 表列信息 */
/** 表列信息 */
@Valid
@Valid
private
List
<
GenTableColumn
>
columns
;
private
List
<
GenTableColumn
>
columns
;
...
@@ -116,6 +125,26 @@ public class GenTable extends BaseEntity
...
@@ -116,6 +125,26 @@ public class GenTable extends BaseEntity
this
.
tableComment
=
tableComment
;
this
.
tableComment
=
tableComment
;
}
}
public
String
getSubTableName
()
{
return
subTableName
;
}
public
void
setSubTableName
(
String
subTableName
)
{
this
.
subTableName
=
subTableName
;
}
public
String
getSubTableFkName
()
{
return
subTableFkName
;
}
public
void
setSubTableFkName
(
String
subTableFkName
)
{
this
.
subTableFkName
=
subTableFkName
;
}
public
String
getClassName
()
public
String
getClassName
()
{
{
return
className
;
return
className
;
...
@@ -216,6 +245,16 @@ public class GenTable extends BaseEntity
...
@@ -216,6 +245,16 @@ public class GenTable extends BaseEntity
this
.
pkColumn
=
pkColumn
;
this
.
pkColumn
=
pkColumn
;
}
}
public
GenTable
getSubTable
()
{
return
subTable
;
}
public
void
setSubTable
(
GenTable
subTable
)
{
this
.
subTable
=
subTable
;
}
public
List
<
GenTableColumn
>
getColumns
()
public
List
<
GenTableColumn
>
getColumns
()
{
{
return
columns
;
return
columns
;
...
@@ -286,6 +325,16 @@ public class GenTable extends BaseEntity
...
@@ -286,6 +325,16 @@ public class GenTable extends BaseEntity
this
.
parentMenuName
=
parentMenuName
;
this
.
parentMenuName
=
parentMenuName
;
}
}
public
boolean
isSub
()
{
return
isSub
(
this
.
tplCategory
);
}
public
static
boolean
isSub
(
String
tplCategory
)
{
return
tplCategory
!=
null
&&
StringUtils
.
equals
(
GenConstants
.
TPL_SUB
,
tplCategory
);
}
public
boolean
isTree
()
public
boolean
isTree
()
{
{
return
isTree
(
this
.
tplCategory
);
return
isTree
(
this
.
tplCategory
);
...
...
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java
View file @
14a85989
...
@@ -138,6 +138,11 @@ public class GenTableColumn extends BaseEntity
...
@@ -138,6 +138,11 @@ public class GenTableColumn extends BaseEntity
return
javaField
;
return
javaField
;
}
}
public
String
getCapJavaField
()
{
return
StringUtils
.
capitalize
(
javaField
);
}
public
void
setIsPk
(
String
isPk
)
public
void
setIsPk
(
String
isPk
)
{
{
this
.
isPk
=
isPk
;
this
.
isPk
=
isPk
;
...
...
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java
View file @
14a85989
...
@@ -34,6 +34,13 @@ public interface GenTableMapper
...
@@ -34,6 +34,13 @@ public interface GenTableMapper
*/
*/
public
List
<
GenTable
>
selectDbTableListByNames
(
String
[]
tableNames
);
public
List
<
GenTable
>
selectDbTableListByNames
(
String
[]
tableNames
);
/**
* 查询所有表信息
*
* @return 表信息集合
*/
public
List
<
GenTable
>
selectGenTableAll
();
/**
/**
* 查询表ID业务信息
* 查询表ID业务信息
*
*
...
...
ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
View file @
14a85989
...
@@ -102,6 +102,17 @@ public class GenTableServiceImpl implements IGenTableService
...
@@ -102,6 +102,17 @@ public class GenTableServiceImpl implements IGenTableService
return
genTableMapper
.
selectDbTableListByNames
(
tableNames
);
return
genTableMapper
.
selectDbTableListByNames
(
tableNames
);
}
}
/**
* 查询所有表信息
*
* @return 表信息集合
*/
@Override
public
List
<
GenTable
>
selectGenTableAll
()
{
return
genTableMapper
.
selectGenTableAll
();
}
/**
/**
* 修改业务
* 修改业务
*
*
...
@@ -185,9 +196,10 @@ public class GenTableServiceImpl implements IGenTableService
...
@@ -185,9 +196,10 @@ public class GenTableServiceImpl implements IGenTableService
Map
<
String
,
String
>
dataMap
=
new
LinkedHashMap
<>();
Map
<
String
,
String
>
dataMap
=
new
LinkedHashMap
<>();
// 查询表信息
// 查询表信息
GenTable
table
=
genTableMapper
.
selectGenTableById
(
tableId
);
GenTable
table
=
genTableMapper
.
selectGenTableById
(
tableId
);
// 查询列信息
// 设置主子表信息
List
<
GenTableColumn
>
columns
=
table
.
getColumns
();
setSubTable
(
table
);
setPkColumn
(
table
,
columns
);
// 设置主键列信息
setPkColumn
(
table
);
VelocityInitializer
.
initVelocity
();
VelocityInitializer
.
initVelocity
();
VelocityContext
context
=
VelocityUtils
.
prepareContext
(
table
);
VelocityContext
context
=
VelocityUtils
.
prepareContext
(
table
);
...
@@ -231,9 +243,10 @@ public class GenTableServiceImpl implements IGenTableService
...
@@ -231,9 +243,10 @@ public class GenTableServiceImpl implements IGenTableService
{
{
// 查询表信息
// 查询表信息
GenTable
table
=
genTableMapper
.
selectGenTableByName
(
tableName
);
GenTable
table
=
genTableMapper
.
selectGenTableByName
(
tableName
);
// 查询列信息
// 设置主子表信息
List
<
GenTableColumn
>
columns
=
table
.
getColumns
();
setSubTable
(
table
);
setPkColumn
(
table
,
columns
);
// 设置主键列信息
setPkColumn
(
table
);
VelocityInitializer
.
initVelocity
();
VelocityInitializer
.
initVelocity
();
...
@@ -276,6 +289,10 @@ public class GenTableServiceImpl implements IGenTableService
...
@@ -276,6 +289,10 @@ public class GenTableServiceImpl implements IGenTableService
List
<
String
>
tableColumnNames
=
tableColumns
.
stream
().
map
(
GenTableColumn:
:
getColumnName
).
collect
(
Collectors
.
toList
());
List
<
String
>
tableColumnNames
=
tableColumns
.
stream
().
map
(
GenTableColumn:
:
getColumnName
).
collect
(
Collectors
.
toList
());
List
<
GenTableColumn
>
dbTableColumns
=
genTableColumnMapper
.
selectDbTableColumnsByName
(
tableName
);
List
<
GenTableColumn
>
dbTableColumns
=
genTableColumnMapper
.
selectDbTableColumnsByName
(
tableName
);
if
(
StringUtils
.
isEmpty
(
dbTableColumns
))
{
throw
new
CustomException
(
"同步数据失败,原表结构不存在"
);
}
List
<
String
>
dbTableColumnNames
=
dbTableColumns
.
stream
().
map
(
GenTableColumn:
:
getColumnName
).
collect
(
Collectors
.
toList
());
List
<
String
>
dbTableColumnNames
=
dbTableColumns
.
stream
().
map
(
GenTableColumn:
:
getColumnName
).
collect
(
Collectors
.
toList
());
dbTableColumns
.
forEach
(
column
->
{
dbTableColumns
.
forEach
(
column
->
{
...
@@ -319,9 +336,10 @@ public class GenTableServiceImpl implements IGenTableService
...
@@ -319,9 +336,10 @@ public class GenTableServiceImpl implements IGenTableService
{
{
// 查询表信息
// 查询表信息
GenTable
table
=
genTableMapper
.
selectGenTableByName
(
tableName
);
GenTable
table
=
genTableMapper
.
selectGenTableByName
(
tableName
);
// 查询列信息
// 设置主子表信息
List
<
GenTableColumn
>
columns
=
table
.
getColumns
();
setSubTable
(
table
);
setPkColumn
(
table
,
columns
);
// 设置主键列信息
setPkColumn
(
table
);
VelocityInitializer
.
initVelocity
();
VelocityInitializer
.
initVelocity
();
...
@@ -375,6 +393,17 @@ public class GenTableServiceImpl implements IGenTableService
...
@@ -375,6 +393,17 @@ public class GenTableServiceImpl implements IGenTableService
{
{
throw
new
CustomException
(
"树名称字段不能为空"
);
throw
new
CustomException
(
"树名称字段不能为空"
);
}
}
else
if
(
GenConstants
.
TPL_SUB
.
equals
(
genTable
.
getTplCategory
()))
{
if
(
StringUtils
.
isEmpty
(
genTable
.
getSubTableName
()))
{
throw
new
CustomException
(
"关联子表的表名不能为空"
);
}
else
if
(
StringUtils
.
isEmpty
(
genTable
.
getSubTableFkName
()))
{
throw
new
CustomException
(
"子表关联的外键名不能为空"
);
}
}
}
}
}
}
...
@@ -382,11 +411,10 @@ public class GenTableServiceImpl implements IGenTableService
...
@@ -382,11 +411,10 @@ public class GenTableServiceImpl implements IGenTableService
* 设置主键列信息
* 设置主键列信息
*
*
* @param table 业务表信息
* @param table 业务表信息
* @param columns 业务字段列表
*/
*/
public
void
setPkColumn
(
GenTable
table
,
List
<
GenTableColumn
>
columns
)
public
void
setPkColumn
(
GenTable
table
)
{
{
for
(
GenTableColumn
column
:
columns
)
for
(
GenTableColumn
column
:
table
.
getColumns
()
)
{
{
if
(
column
.
isPk
())
if
(
column
.
isPk
())
{
{
...
@@ -396,7 +424,36 @@ public class GenTableServiceImpl implements IGenTableService
...
@@ -396,7 +424,36 @@ public class GenTableServiceImpl implements IGenTableService
}
}
if
(
StringUtils
.
isNull
(
table
.
getPkColumn
()))
if
(
StringUtils
.
isNull
(
table
.
getPkColumn
()))
{
{
table
.
setPkColumn
(
columns
.
get
(
0
));
table
.
setPkColumn
(
table
.
getColumns
().
get
(
0
));
}
if
(
GenConstants
.
TPL_SUB
.
equals
(
table
.
getTplCategory
()))
{
for
(
GenTableColumn
column
:
table
.
getSubTable
().
getColumns
())
{
if
(
column
.
isPk
())
{
table
.
getSubTable
().
setPkColumn
(
column
);
break
;
}
}
if
(
StringUtils
.
isNull
(
table
.
getSubTable
().
getPkColumn
()))
{
table
.
getSubTable
().
setPkColumn
(
table
.
getSubTable
().
getColumns
().
get
(
0
));
}
}
}
/**
* 设置主子表信息
*
* @param table 业务表信息
*/
public
void
setSubTable
(
GenTable
table
)
{
String
subTableName
=
table
.
getSubTableName
();
if
(
StringUtils
.
isNotEmpty
(
subTableName
))
{
table
.
setSubTable
(
genTableMapper
.
selectGenTableByName
(
subTableName
));
}
}
}
}
...
...
ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java
View file @
14a85989
...
@@ -35,6 +35,13 @@ public interface IGenTableService
...
@@ -35,6 +35,13 @@ public interface IGenTableService
*/
*/
public
List
<
GenTable
>
selectDbTableListByNames
(
String
[]
tableNames
);
public
List
<
GenTable
>
selectDbTableListByNames
(
String
[]
tableNames
);
/**
* 查询所有表信息
*
* @return 表信息集合
*/
public
List
<
GenTable
>
selectGenTableAll
();
/**
/**
* 查询业务信息
* 查询业务信息
*
*
...
...
ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java
View file @
14a85989
...
@@ -7,7 +7,7 @@ import com.ruoyi.common.constant.Constants;
...
@@ -7,7 +7,7 @@ import com.ruoyi.common.constant.Constants;
/**
/**
* VelocityEngine工厂
* VelocityEngine工厂
*
*
* @author
RuoY
i
* @author
ruoy
i
*/
*/
public
class
VelocityInitializer
public
class
VelocityInitializer
{
{
...
...
ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
View file @
14a85989
...
@@ -54,7 +54,7 @@ public class VelocityUtils
...
@@ -54,7 +54,7 @@ public class VelocityUtils
velocityContext
.
put
(
"author"
,
genTable
.
getFunctionAuthor
());
velocityContext
.
put
(
"author"
,
genTable
.
getFunctionAuthor
());
velocityContext
.
put
(
"datetime"
,
DateUtils
.
getDate
());
velocityContext
.
put
(
"datetime"
,
DateUtils
.
getDate
());
velocityContext
.
put
(
"pkColumn"
,
genTable
.
getPkColumn
());
velocityContext
.
put
(
"pkColumn"
,
genTable
.
getPkColumn
());
velocityContext
.
put
(
"importList"
,
getImportList
(
genTable
.
getColumns
()
));
velocityContext
.
put
(
"importList"
,
getImportList
(
genTable
));
velocityContext
.
put
(
"permissionPrefix"
,
getPermissionPrefix
(
moduleName
,
businessName
));
velocityContext
.
put
(
"permissionPrefix"
,
getPermissionPrefix
(
moduleName
,
businessName
));
velocityContext
.
put
(
"columns"
,
genTable
.
getColumns
());
velocityContext
.
put
(
"columns"
,
genTable
.
getColumns
());
velocityContext
.
put
(
"table"
,
genTable
);
velocityContext
.
put
(
"table"
,
genTable
);
...
@@ -63,6 +63,10 @@ public class VelocityUtils
...
@@ -63,6 +63,10 @@ public class VelocityUtils
{
{
setTreeVelocityContext
(
velocityContext
,
genTable
);
setTreeVelocityContext
(
velocityContext
,
genTable
);
}
}
if
(
GenConstants
.
TPL_SUB
.
equals
(
tplCategory
))
{
setSubVelocityContext
(
velocityContext
,
genTable
);
}
return
velocityContext
;
return
velocityContext
;
}
}
...
@@ -96,6 +100,24 @@ public class VelocityUtils
...
@@ -96,6 +100,24 @@ public class VelocityUtils
}
}
}
}
public
static
void
setSubVelocityContext
(
VelocityContext
context
,
GenTable
genTable
)
{
GenTable
subTable
=
genTable
.
getSubTable
();
String
subTableName
=
genTable
.
getSubTableName
();
String
subTableFkName
=
genTable
.
getSubTableFkName
();
String
subClassName
=
genTable
.
getSubTable
().
getClassName
();
String
subTableFkClassName
=
StringUtils
.
convertToCamelCase
(
subTableFkName
);
context
.
put
(
"subTable"
,
subTable
);
context
.
put
(
"subTableName"
,
subTableName
);
context
.
put
(
"subTableFkName"
,
subTableFkName
);
context
.
put
(
"subTableFkClassName"
,
subTableFkClassName
);
context
.
put
(
"subTableFkclassName"
,
StringUtils
.
uncapitalize
(
subTableFkClassName
));
context
.
put
(
"subClassName"
,
subClassName
);
context
.
put
(
"subclassName"
,
StringUtils
.
uncapitalize
(
subClassName
));
context
.
put
(
"subImportList"
,
getImportList
(
genTable
.
getSubTable
()));
}
/**
/**
* 获取模板信息
* 获取模板信息
*
*
...
@@ -120,6 +142,11 @@ public class VelocityUtils
...
@@ -120,6 +142,11 @@ public class VelocityUtils
{
{
templates
.
add
(
"vm/vue/index-tree.vue.vm"
);
templates
.
add
(
"vm/vue/index-tree.vue.vm"
);
}
}
else
if
(
GenConstants
.
TPL_SUB
.
equals
(
tplCategory
))
{
templates
.
add
(
"vm/vue/index.vue.vm"
);
templates
.
add
(
"vm/java/sub-domain.java.vm"
);
}
return
templates
;
return
templates
;
}
}
...
@@ -147,6 +174,10 @@ public class VelocityUtils
...
@@ -147,6 +174,10 @@ public class VelocityUtils
{
{
fileName
=
StringUtils
.
format
(
"{}/domain/{}.java"
,
javaPath
,
className
);
fileName
=
StringUtils
.
format
(
"{}/domain/{}.java"
,
javaPath
,
className
);
}
}
if
(
template
.
contains
(
"sub-domain.java.vm"
)
&&
StringUtils
.
equals
(
GenConstants
.
TPL_SUB
,
genTable
.
getTplCategory
()))
{
fileName
=
StringUtils
.
format
(
"{}/domain/{}.java"
,
javaPath
,
genTable
.
getSubTable
().
getClassName
());
}
else
if
(
template
.
contains
(
"mapper.java.vm"
))
else
if
(
template
.
contains
(
"mapper.java.vm"
))
{
{
fileName
=
StringUtils
.
format
(
"{}/mapper/{}Mapper.java"
,
javaPath
,
className
);
fileName
=
StringUtils
.
format
(
"{}/mapper/{}Mapper.java"
,
javaPath
,
className
);
...
@@ -201,13 +232,19 @@ public class VelocityUtils
...
@@ -201,13 +232,19 @@ public class VelocityUtils
/**
/**
* 根据列类型获取导入包
* 根据列类型获取导入包
*
*
* @param
columns 列集合
* @param
genTable 业务表对象
* @return 返回需要导入的包列表
* @return 返回需要导入的包列表
*/
*/
public
static
HashSet
<
String
>
getImportList
(
List
<
GenTableColumn
>
columns
)
public
static
HashSet
<
String
>
getImportList
(
GenTable
genTable
)
{
{
List
<
GenTableColumn
>
columns
=
genTable
.
getColumns
();
GenTable
subGenTable
=
genTable
.
getSubTable
();
HashSet
<
String
>
importList
=
new
HashSet
<
String
>();
HashSet
<
String
>
importList
=
new
HashSet
<
String
>();
if
(
StringUtils
.
isNotNull
(
subGenTable
))
{
importList
.
add
(
"java.util.List"
);
}
for
(
GenTableColumn
column
:
columns
)
for
(
GenTableColumn
column
:
columns
)
{
{
if
(!
column
.
isSuperColumn
()
&&
GenConstants
.
TYPE_DATE
.
equals
(
column
.
getJavaType
()))
if
(!
column
.
isSuperColumn
()
&&
GenConstants
.
TYPE_DATE
.
equals
(
column
.
getJavaType
()))
...
...
ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml
View file @
14a85989
...
@@ -5,24 +5,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -5,24 +5,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper
namespace=
"com.ruoyi.generator.mapper.GenTableMapper"
>
<mapper
namespace=
"com.ruoyi.generator.mapper.GenTableMapper"
>
<resultMap
type=
"GenTable"
id=
"GenTableResult"
>
<resultMap
type=
"GenTable"
id=
"GenTableResult"
>
<id
property=
"tableId"
column=
"table_id"
/>
<id
property=
"tableId"
column=
"table_id"
/>
<result
property=
"tableName"
column=
"table_name"
/>
<result
property=
"tableName"
column=
"table_name"
/>
<result
property=
"tableComment"
column=
"table_comment"
/>
<result
property=
"tableComment"
column=
"table_comment"
/>
<result
property=
"className"
column=
"class_name"
/>
<result
property=
"subTableName"
column=
"sub_table_name"
/>
<result
property=
"tplCategory"
column=
"tpl_category"
/>
<result
property=
"subTableFkName"
column=
"sub_table_fk_name"
/>
<result
property=
"packageName"
column=
"package_name"
/>
<result
property=
"className"
column=
"class_name"
/>
<result
property=
"moduleName"
column=
"module_name"
/>
<result
property=
"tplCategory"
column=
"tpl_category"
/>
<result
property=
"businessName"
column=
"business_name"
/>
<result
property=
"packageName"
column=
"package_name"
/>
<result
property=
"functionName"
column=
"function_name"
/>
<result
property=
"moduleName"
column=
"module_name"
/>
<result
property=
"functionAuthor"
column=
"function_author"
/>
<result
property=
"businessName"
column=
"business_name"
/>
<result
property=
"genType"
column=
"gen_type"
/>
<result
property=
"functionName"
column=
"function_name"
/>
<result
property=
"genPath"
column=
"gen_path"
/>
<result
property=
"functionAuthor"
column=
"function_author"
/>
<result
property=
"options"
column=
"options"
/>
<result
property=
"genType"
column=
"gen_type"
/>
<result
property=
"createBy"
column=
"create_by"
/>
<result
property=
"genPath"
column=
"gen_path"
/>
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"options"
column=
"options"
/>
<result
property=
"updateBy"
column=
"update_by"
/>
<result
property=
"createBy"
column=
"create_by"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"remark"
column=
"remark"
/>
<result
property=
"updateBy"
column=
"update_by"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"remark"
column=
"remark"
/>
<collection
property=
"columns"
javaType=
"java.util.List"
resultMap=
"GenTableColumnResult"
/>
<collection
property=
"columns"
javaType=
"java.util.List"
resultMap=
"GenTableColumnResult"
/>
</resultMap>
</resultMap>
...
@@ -52,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -52,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
</resultMap>
<sql
id=
"selectGenTableVo"
>
<sql
id=
"selectGenTableVo"
>
select table_id, table_name, table_comment, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table
select table_id, table_name, table_comment,
sub_table_name, sub_table_fk_name,
class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table
</sql>
</sql>
<select
id=
"selectGenTableList"
parameterType=
"GenTable"
resultMap=
"GenTableResult"
>
<select
id=
"selectGenTableList"
parameterType=
"GenTable"
resultMap=
"GenTableResult"
>
...
@@ -108,7 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -108,7 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
</select>
<select
id=
"selectGenTableById"
parameterType=
"Long"
resultMap=
"GenTableResult"
>
<select
id=
"selectGenTableById"
parameterType=
"Long"
resultMap=
"GenTableResult"
>
SELECT t.table_id, t.table_name, t.table_comment, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
SELECT t.table_id, t.table_name, t.table_comment, t.
sub_table_name, t.sub_table_fk_name, t.
class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
FROM gen_table t
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
...
@@ -116,13 +118,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -116,13 +118,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
</select>
<select
id=
"selectGenTableByName"
parameterType=
"String"
resultMap=
"GenTableResult"
>
<select
id=
"selectGenTableByName"
parameterType=
"String"
resultMap=
"GenTableResult"
>
SELECT t.table_id, t.table_name, t.table_comment, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
SELECT t.table_id, t.table_name, t.table_comment, t.
sub_table_name, t.sub_table_fk_name, t.
class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
FROM gen_table t
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
where t.table_name = #{tableName} order by c.sort
where t.table_name = #{tableName} order by c.sort
</select>
</select>
<select
id=
"selectGenTableAll"
parameterType=
"String"
resultMap=
"GenTableResult"
>
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
order by c.sort
</select>
<insert
id=
"insertGenTable"
parameterType=
"GenTable"
useGeneratedKeys=
"true"
keyProperty=
"tableId"
>
<insert
id=
"insertGenTable"
parameterType=
"GenTable"
useGeneratedKeys=
"true"
keyProperty=
"tableId"
>
insert into gen_table (
insert into gen_table (
<if
test=
"tableName != null"
>
table_name,
</if>
<if
test=
"tableName != null"
>
table_name,
</if>
...
@@ -162,6 +172,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -162,6 +172,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<set>
<set>
<if
test=
"tableName != null"
>
table_name = #{tableName},
</if>
<if
test=
"tableName != null"
>
table_name = #{tableName},
</if>
<if
test=
"tableComment != null and tableComment != ''"
>
table_comment = #{tableComment},
</if>
<if
test=
"tableComment != null and tableComment != ''"
>
table_comment = #{tableComment},
</if>
<if
test=
"subTableName != null"
>
sub_table_name = #{subTableName},
</if>
<if
test=
"subTableFkName != null"
>
sub_table_fk_name = #{subTableFkName},
</if>
<if
test=
"className != null and className != ''"
>
class_name = #{className},
</if>
<if
test=
"className != null and className != ''"
>
class_name = #{className},
</if>
<if
test=
"functionAuthor != null and functionAuthor != ''"
>
function_author = #{functionAuthor},
</if>
<if
test=
"functionAuthor != null and functionAuthor != ''"
>
function_author = #{functionAuthor},
</if>
<if
test=
"genType != null and genType != ''"
>
gen_type = #{genType},
</if>
<if
test=
"genType != null and genType != ''"
>
gen_type = #{genType},
</if>
...
...
ruoyi-generator/src/main/resources/vm/java/controller.java.vm
View file @
14a85989
...
@@ -18,7 +18,7 @@ import com.ruoyi.common.enums.BusinessType;
...
@@ -18,7 +18,7 @@ import com.ruoyi.common.enums.BusinessType;
import
${
packageName
}.
domain
.${
ClassName
};
import
${
packageName
}.
domain
.${
ClassName
};
import
${
packageName
}.
service
.
I
${
ClassName
}
Service
;
import
${
packageName
}.
service
.
I
${
ClassName
}
Service
;
import
com
.
ruoyi
.
common
.
utils
.
poi
.
ExcelUtil
;
import
com
.
ruoyi
.
common
.
utils
.
poi
.
ExcelUtil
;
#
if
($
table
.
crud
)
#
if
($
table
.
crud
||
$
table
.
sub
)
import
com
.
ruoyi
.
common
.
core
.
page
.
TableDataInfo
;
import
com
.
ruoyi
.
common
.
core
.
page
.
TableDataInfo
;
#
elseif
($
table
.
tree
)
#
elseif
($
table
.
tree
)
#
end
#
end
...
@@ -41,7 +41,7 @@ public class ${ClassName}Controller extends BaseController
...
@@ -41,7 +41,7 @@ public class ${ClassName}Controller extends BaseController
*/
*/
@
PreAuthorize
(
"@ss.hasPermi('${permissionPrefix}:list')"
)
@
PreAuthorize
(
"@ss.hasPermi('${permissionPrefix}:list')"
)
@
GetMapping
(
"/list"
)
@
GetMapping
(
"/list"
)
#
if
($
table
.
crud
)
#
if
($
table
.
crud
||
$
table
.
sub
)
public
TableDataInfo
list
(${
ClassName
}
${
className
})
public
TableDataInfo
list
(${
ClassName
}
${
className
})
{
{
startPage
();
startPage
();
...
...
ruoyi-generator/src/main/resources/vm/java/domain.java.vm
View file @
14a85989
...
@@ -6,7 +6,7 @@ import ${import};
...
@@ -6,7 +6,7 @@ import ${import};
import
org
.
apache
.
commons
.
lang3
.
builder
.
ToStringBuilder
;
import
org
.
apache
.
commons
.
lang3
.
builder
.
ToStringBuilder
;
import
org
.
apache
.
commons
.
lang3
.
builder
.
ToStringStyle
;
import
org
.
apache
.
commons
.
lang3
.
builder
.
ToStringStyle
;
import
com
.
ruoyi
.
common
.
annotation
.
Excel
;
import
com
.
ruoyi
.
common
.
annotation
.
Excel
;
#
if
($
table
.
crud
)
#
if
($
table
.
crud
||
$
table
.
sub
)
import
com
.
ruoyi
.
common
.
core
.
domain
.
BaseEntity
;
import
com
.
ruoyi
.
common
.
core
.
domain
.
BaseEntity
;
#
elseif
($
table
.
tree
)
#
elseif
($
table
.
tree
)
import
com
.
ruoyi
.
common
.
core
.
domain
.
TreeEntity
;
import
com
.
ruoyi
.
common
.
core
.
domain
.
TreeEntity
;
...
@@ -18,7 +18,7 @@ import com.ruoyi.common.core.domain.TreeEntity;
...
@@ -18,7 +18,7 @@ import com.ruoyi.common.core.domain.TreeEntity;
*
@
author
${
author
}
*
@
author
${
author
}
*
@
date
${
datetime
}
*
@
date
${
datetime
}
*/
*/
#
if
($
table
.
crud
)
#
if
($
table
.
crud
||
$
table
.
sub
)
#
set
($
Entity
=
"BaseEntity"
)
#
set
($
Entity
=
"BaseEntity"
)
#
elseif
($
table
.
tree
)
#
elseif
($
table
.
tree
)
#
set
($
Entity
=
"TreeEntity"
)
#
set
($
Entity
=
"TreeEntity"
)
...
@@ -49,6 +49,11 @@ public class ${ClassName} extends ${Entity}
...
@@ -49,6 +49,11 @@ public class ${ClassName} extends ${Entity}
private
$
column
.
javaType
$
column
.
javaField
;
private
$
column
.
javaType
$
column
.
javaField
;
#
end
#
end
#
end
#
if
($
table
.
sub
)
/**
$
table
.
subTable
.
functionName
信息
*/
private
List
<${
subClassName
}>
${
subclassName
}
List
;
#
end
#
end
#
foreach
($
column
in
$
columns
)
#
foreach
($
column
in
$
columns
)
#
if
(
!$table.isSuperColumn($column.javaField))
#
if
(
!$table.isSuperColumn($column.javaField))
...
@@ -69,6 +74,18 @@ public class ${ClassName} extends ${Entity}
...
@@ -69,6 +74,18 @@ public class ${ClassName} extends ${Entity}
#
end
#
end
#
end
#
end
#
if
($
table
.
sub
)
public
List
<${
subClassName
}>
get
${
subClassName
}
List
()
{
return
${
subclassName
}
List
;
}
public
void
set
${
subClassName
}
List
(
List
<${
subClassName
}>
${
subclassName
}
List
)
{
this
.${
subclassName
}
List
=
${
subclassName
}
List
;
}
#
end
@
Override
@
Override
public
String
toString
()
{
public
String
toString
()
{
return
new
ToStringBuilder
(
this
,
ToStringStyle
.
MULTI_LINE_STYLE
)
return
new
ToStringBuilder
(
this
,
ToStringStyle
.
MULTI_LINE_STYLE
)
...
@@ -79,6 +96,9 @@ public class ${ClassName} extends ${Entity}
...
@@ -79,6 +96,9 @@ public class ${ClassName} extends ${Entity}
#
set
($
AttrName
=$
column
.
javaField
.
substring
(
0
,
1
).
toUpperCase
()
+
${
column
.
javaField
.
substring
(
1
)})
#
set
($
AttrName
=$
column
.
javaField
.
substring
(
0
,
1
).
toUpperCase
()
+
${
column
.
javaField
.
substring
(
1
)})
#
end
#
end
.
append
(
"${column.javaField}"
,
get
${
AttrName
}())
.
append
(
"${column.javaField}"
,
get
${
AttrName
}())
#
end
#
if
($
table
.
sub
)
.
append
(
"${subclassName}List"
,
get
${
subClassName
}
List
())
#
end
#
end
.
toString
();
.
toString
();
}
}
...
...
ruoyi-generator/src/main/resources/vm/java/mapper.java.vm
View file @
14a85989
...
@@ -2,6 +2,9 @@ package ${packageName}.mapper;
...
@@ -2,6 +2,9 @@ package ${packageName}.mapper;
import
java
.
util
.
List
;
import
java
.
util
.
List
;
import
${
packageName
}.
domain
.${
ClassName
};
import
${
packageName
}.
domain
.${
ClassName
};
#
if
($
table
.
sub
)
import
${
packageName
}.
domain
.${
subClassName
};
#
end
/**
/**
*
${
functionName
}
Mapper
接口
*
${
functionName
}
Mapper
接口
...
@@ -58,4 +61,31 @@ public interface ${ClassName}Mapper
...
@@ -58,4 +61,31 @@ public interface ${ClassName}Mapper
*
@
return
结果
*
@
return
结果
*/
*/
public
int
delete
${
ClassName
}
ByIds
(${
pkColumn
.
javaType
}[]
${
pkColumn
.
javaField
}
s
);
public
int
delete
${
ClassName
}
ByIds
(${
pkColumn
.
javaType
}[]
${
pkColumn
.
javaField
}
s
);
#
if
($
table
.
sub
)
/**
*
批量删除
${
subTable
.
functionName
}
*
*
@
param
customerIds
需要删除的数据
ID
*
@
return
结果
*/
public
int
delete
${
subClassName
}
By
${
subTableFkClassName
}
s
(${
pkColumn
.
javaType
}[]
${
pkColumn
.
javaField
}
s
);
/**
*
批量新增
${
subTable
.
functionName
}
*
*
@
param
${
subclassName
}
List
${
subTable
.
functionName
}
列表
*
@
return
结果
*/
public
int
batch
${
subClassName
}(
List
<${
subClassName
}>
${
subclassName
}
List
);
/**
*
通过
${
functionName
}
ID
删除
${
subTable
.
functionName
}
信息
*
*
@
param
roleId
角色
ID
*
@
return
结果
*/
public
int
delete
${
subClassName
}
By
${
subTableFkClassName
}(${
pkColumn
.
javaType
}
${
pkColumn
.
javaField
});
#
end
}
}
ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm
View file @
14a85989
...
@@ -9,6 +9,12 @@ import com.ruoyi.common.utils.DateUtils;
...
@@ -9,6 +9,12 @@ import com.ruoyi.common.utils.DateUtils;
#
end
#
end
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
import
org
.
springframework
.
stereotype
.
Service
;
import
org
.
springframework
.
stereotype
.
Service
;
#
if
($
table
.
sub
)
import
java
.
util
.
ArrayList
;
import
com
.
ruoyi
.
common
.
utils
.
StringUtils
;
import
org
.
springframework
.
transaction
.
annotation
.
Transactional
;
import
${
packageName
}.
domain
.${
subClassName
};
#
end
import
${
packageName
}.
mapper
.${
ClassName
}
Mapper
;
import
${
packageName
}.
mapper
.${
ClassName
}
Mapper
;
import
${
packageName
}.
domain
.${
ClassName
};
import
${
packageName
}.
domain
.${
ClassName
};
import
${
packageName
}.
service
.
I
${
ClassName
}
Service
;
import
${
packageName
}.
service
.
I
${
ClassName
}
Service
;
...
@@ -55,6 +61,9 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
...
@@ -55,6 +61,9 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
*
@
param
${
className
}
${
functionName
}
*
@
param
${
className
}
${
functionName
}
*
@
return
结果
*
@
return
结果
*/
*/
#
if
($
table
.
sub
)
@
Transactional
#
end
@
Override
@
Override
public
int
insert
${
ClassName
}(${
ClassName
}
${
className
})
public
int
insert
${
ClassName
}(${
ClassName
}
${
className
})
{
{
...
@@ -63,7 +72,13 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
...
@@ -63,7 +72,13 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
${
className
}.
setCreateTime
(
DateUtils
.
getNowDate
());
${
className
}.
setCreateTime
(
DateUtils
.
getNowDate
());
#
end
#
end
#
end
#
end
#
if
($
table
.
sub
)
int
rows
=
${
className
}
Mapper
.
insert
${
ClassName
}(${
className
});
insert
${
subClassName
}(${
className
});
return
rows
;
#
else
return
${
className
}
Mapper
.
insert
${
ClassName
}(${
className
});
return
${
className
}
Mapper
.
insert
${
ClassName
}(${
className
});
#
end
}
}
/**
/**
...
@@ -72,6 +87,9 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
...
@@ -72,6 +87,9 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
*
@
param
${
className
}
${
functionName
}
*
@
param
${
className
}
${
functionName
}
*
@
return
结果
*
@
return
结果
*/
*/
#
if
($
table
.
sub
)
@
Transactional
#
end
@
Override
@
Override
public
int
update
${
ClassName
}(${
ClassName
}
${
className
})
public
int
update
${
ClassName
}(${
ClassName
}
${
className
})
{
{
...
@@ -79,6 +97,10 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
...
@@ -79,6 +97,10 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
#
if
($
column
.
javaField
==
'updateTime'
)
#
if
($
column
.
javaField
==
'updateTime'
)
${
className
}.
setUpdateTime
(
DateUtils
.
getNowDate
());
${
className
}.
setUpdateTime
(
DateUtils
.
getNowDate
());
#
end
#
end
#
end
#
if
($
table
.
sub
)
${
className
}
Mapper
.
delete
${
subClassName
}
By
${
subTableFkClassName
}(${
className
}.
get
${
pkColumn
.
capJavaField
}());
insert
${
subClassName
}(${
className
});
#
end
#
end
return
${
className
}
Mapper
.
update
${
ClassName
}(${
className
});
return
${
className
}
Mapper
.
update
${
ClassName
}(${
className
});
}
}
...
@@ -89,9 +111,15 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
...
@@ -89,9 +111,15 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
*
@
param
${
pkColumn
.
javaField
}
s
需要删除的
${
functionName
}
ID
*
@
param
${
pkColumn
.
javaField
}
s
需要删除的
${
functionName
}
ID
*
@
return
结果
*
@
return
结果
*/
*/
#
if
($
table
.
sub
)
@
Transactional
#
end
@
Override
@
Override
public
int
delete
${
ClassName
}
ByIds
(${
pkColumn
.
javaType
}[]
${
pkColumn
.
javaField
}
s
)
public
int
delete
${
ClassName
}
ByIds
(${
pkColumn
.
javaType
}[]
${
pkColumn
.
javaField
}
s
)
{
{
#
if
($
table
.
sub
)
${
className
}
Mapper
.
delete
${
subClassName
}
By
${
subTableFkClassName
}
s
(${
pkColumn
.
javaField
}
s
);
#
end
return
${
className
}
Mapper
.
delete
${
ClassName
}
ByIds
(${
pkColumn
.
javaField
}
s
);
return
${
className
}
Mapper
.
delete
${
ClassName
}
ByIds
(${
pkColumn
.
javaField
}
s
);
}
}
...
@@ -104,6 +132,35 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
...
@@ -104,6 +132,35 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
@
Override
@
Override
public
int
delete
${
ClassName
}
ById
(${
pkColumn
.
javaType
}
${
pkColumn
.
javaField
})
public
int
delete
${
ClassName
}
ById
(${
pkColumn
.
javaType
}
${
pkColumn
.
javaField
})
{
{
#
if
($
table
.
sub
)
${
className
}
Mapper
.
delete
${
subClassName
}
By
${
subTableFkClassName
}(${
pkColumn
.
javaField
});
#
end
return
${
className
}
Mapper
.
delete
${
ClassName
}
ById
(${
pkColumn
.
javaField
});
return
${
className
}
Mapper
.
delete
${
ClassName
}
ById
(${
pkColumn
.
javaField
});
}
}
#
if
($
table
.
sub
)
/**
*
新增
${
subTable
.
functionName
}
信息
*
*
@
param
${
className
}
${
functionName
}
对象
*/
public
void
insert
${
subClassName
}(${
ClassName
}
${
className
})
{
List
<${
subClassName
}>
${
subclassName
}
List
=
${
className
}.
get
${
subClassName
}
List
();
Long
${
pkColumn
.
javaField
}
=
${
className
}.
get
${
pkColumn
.
capJavaField
}();
if
(
StringUtils
.
isNotNull
(${
subclassName
}
List
))
{
List
<${
subClassName
}>
list
=
new
ArrayList
<${
subClassName
}>();
for
(${
subClassName
}
${
subclassName
}
:
${
subclassName
}
List
)
{
${
subclassName
}.
set
${
subTableFkClassName
}(${
pkColumn
.
javaField
});
list
.
add
(${
subclassName
});
}
if
(
list
.
size
()
>
0
)
{
${
className
}
Mapper
.
batch
${
subClassName
}(
list
);
}
}
}
#
end
}
}
ruoyi-generator/src/main/resources/vm/java/sub-domain.java.vm
0 → 100644
View file @
14a85989
package
${
packageName
}.
domain
;
#
foreach
($
import
in
$
subImportList
)
import
${
import
};
#
end
import
org
.
apache
.
commons
.
lang3
.
builder
.
ToStringBuilder
;
import
org
.
apache
.
commons
.
lang3
.
builder
.
ToStringStyle
;
import
com
.
ruoyi
.
common
.
annotation
.
Excel
;
import
com
.
ruoyi
.
common
.
core
.
domain
.
BaseEntity
;
/**
*
${
subTable
.
functionName
}
对象
${
subTableName
}
*
*
@
author
${
author
}
*
@
date
${
datetime
}
*/
public
class
${
subClassName
}
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
#
foreach
($
column
in
$
subTable
.
columns
)
#
if
(
!$table.isSuperColumn($column.javaField))
/**
$
column
.
columnComment
*/
#
if
($
column
.
list
)
#
set
($
parentheseIndex
=$
column
.
columnComment
.
indexOf
(
"("
))
#
if
($
parentheseIndex
!= -1)
#
set
($
comment
=$
column
.
columnComment
.
substring
(
0
,
$
parentheseIndex
))
#
else
#
set
($
comment
=$
column
.
columnComment
)
#
end
#
if
($
parentheseIndex
!= -1)
@
Excel
(
name
=
"${comment}"
,
readConverterExp
=
"$column.readConverterExp()"
)
#
elseif
($
column
.
javaType
==
'Date'
)
@
JsonFormat
(
pattern
=
"yyyy-MM-dd"
)
@
Excel
(
name
=
"${comment}"
,
width
=
30
,
dateFormat
=
"yyyy-MM-dd"
)
#
else
@
Excel
(
name
=
"${comment}"
)
#
end
#
end
private
$
column
.
javaType
$
column
.
javaField
;
#
end
#
end
#
foreach
($
column
in
$
subTable
.
columns
)
#
if
(
!$table.isSuperColumn($column.javaField))
#
if
($
column
.
javaField
.
length
()
>
2
&&
$
column
.
javaField
.
substring
(
1
,
2
).
matches
(
"[A-Z]"
))
#
set
($
AttrName
=$
column
.
javaField
)
#
else
#
set
($
AttrName
=$
column
.
javaField
.
substring
(
0
,
1
).
toUpperCase
()
+
${
column
.
javaField
.
substring
(
1
)})
#
end
public
void
set
${
AttrName
}($
column
.
javaType
$
column
.
javaField
)
{
this
.$
column
.
javaField
=
$
column
.
javaField
;
}
public
$
column
.
javaType
get
${
AttrName
}()
{
return
$
column
.
javaField
;
}
#
end
#
end
@
Override
public
String
toString
()
{
return
new
ToStringBuilder
(
this
,
ToStringStyle
.
MULTI_LINE_STYLE
)
#
foreach
($
column
in
$
subTable
.
columns
)
#
if
($
column
.
javaField
.
length
()
>
2
&&
$
column
.
javaField
.
substring
(
1
,
2
).
matches
(
"[A-Z]"
))
#
set
($
AttrName
=$
column
.
javaField
)
#
else
#
set
($
AttrName
=$
column
.
javaField
.
substring
(
0
,
1
).
toUpperCase
()
+
${
column
.
javaField
.
substring
(
1
)})
#
end
.
append
(
"${column.javaField}"
,
get
${
AttrName
}())
#
end
.
toString
();
}
}
ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm
View file @
14a85989
...
@@ -73,7 +73,7 @@
...
@@ -73,7 +73,7 @@
<el-col :span="1.5">
<el-col :span="1.5">
<el-button
<el-button
type="primary"
type="primary"
plain
plain
icon="el-icon-plus"
icon="el-icon-plus"
size="mini"
size="mini"
@click="handleAdd"
@click="handleAdd"
...
...
ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
View file @
14a85989
...
@@ -73,7 +73,7 @@
...
@@ -73,7 +73,7 @@
<el-col :span="1.5">
<el-col :span="1.5">
<el-button
<el-button
type="primary"
type="primary"
plain
plain
icon="el-icon-plus"
icon="el-icon-plus"
size="mini"
size="mini"
@click="handleAdd"
@click="handleAdd"
...
@@ -83,7 +83,7 @@
...
@@ -83,7 +83,7 @@
<el-col :span="1.5">
<el-col :span="1.5">
<el-button
<el-button
type="success"
type="success"
plain
plain
icon="el-icon-edit"
icon="el-icon-edit"
size="mini"
size="mini"
:disabled="single"
:disabled="single"
...
@@ -94,7 +94,7 @@
...
@@ -94,7 +94,7 @@
<el-col :span="1.5">
<el-col :span="1.5">
<el-button
<el-button
type="danger"
type="danger"
plain
plain
icon="el-icon-delete"
icon="el-icon-delete"
size="mini"
size="mini"
:disabled="multiple"
:disabled="multiple"
...
@@ -105,7 +105,7 @@
...
@@ -105,7 +105,7 @@
<el-col :span="1.5">
<el-col :span="1.5">
<el-button
<el-button
type="warning"
type="warning"
plain
plain
icon="el-icon-download"
icon="el-icon-download"
size="mini"
size="mini"
@click="handleExport"
@click="handleExport"
...
@@ -265,6 +265,38 @@
...
@@ -265,6 +265,38 @@
#end
#end
#end
#end
#end
#end
#end
#if($table.sub)
<el-divider content-position="center">${subTable.functionName}信息</el-divider>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd${subClassName}">添加</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDelete${subClassName}">删除</el-button>
</el-col>
</el-row>
<el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="序号" align="center" prop="index" width="50"/>
#foreach($column in $subTable.columns)
#set($javaField=$column.javaField)
#set($parentheseIndex=$column.columnComment.indexOf("("))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($column.pk || $javaField == ${subTableFkclassName})
#elseif($column.list && "" != $javaField)
<el-table-column label="$comment" prop="${javaField}">
<template slot-scope="scope">
<el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
</template>
</el-table-column>
#end
#end
</el-table>
#end
#end
</el-form>
</el-form>
<div slot="footer" class="dialog-footer">
<div slot="footer" class="dialog-footer">
...
@@ -324,6 +356,10 @@ export default {
...
@@ -324,6 +356,10 @@ export default {
loading: true,
loading: true,
// 选中数组
// 选中数组
ids: [],
ids: [],
#if($table.sub)
// 子表选中数据
checked${subClassName}: [],
#end
// 非单个禁用
// 非单个禁用
single: true,
single: true,
// 非多个禁用
// 非多个禁用
...
@@ -334,6 +370,10 @@ export default {
...
@@ -334,6 +370,10 @@ export default {
total: 0,
total: 0,
// ${functionName}表格数据
// ${functionName}表格数据
${businessName}List: [],
${businessName}List: [],
#if($table.sub)
// ${subTable.functionName}表格数据
${subclassName}List: [],
#end
// 弹出层标题
// 弹出层标题
title: "",
title: "",
// 是否显示弹出层
// 是否显示弹出层
...
@@ -456,6 +496,9 @@ export default {
...
@@ -456,6 +496,9 @@ export default {
#end
#end
#end
#end
};
};
#if($table.sub)
this.${subclassName}List = [];
#end
this.resetForm("form");
this.resetForm("form");
},
},
/** 搜索按钮操作 */
/** 搜索按钮操作 */
...
@@ -496,6 +539,9 @@ export default {
...
@@ -496,6 +539,9 @@ export default {
#if($column.htmlType == "checkbox")
#if($column.htmlType == "checkbox")
this.form.$column.javaField = this.form.${column.javaField}.split(",");
this.form.$column.javaField = this.form.${column.javaField}.split(",");
#end
#end
#end
#if($table.sub)
this.${subclassName}List = response.data.${subclassName}List;
#end
#end
this.open = true;
this.open = true;
this.title = "修改${functionName}";
this.title = "修改${functionName}";
...
@@ -509,6 +555,9 @@ export default {
...
@@ -509,6 +555,9 @@ export default {
#if($column.htmlType == "checkbox")
#if($column.htmlType == "checkbox")
this.form.$column.javaField = this.form.${column.javaField}.join(",");
this.form.$column.javaField = this.form.${column.javaField}.join(",");
#end
#end
#end
#if($table.sub)
this.form.${subclassName}List = this.${subclassName}List;
#end
#end
if (this.form.${pkColumn.javaField} != null) {
if (this.form.${pkColumn.javaField} != null) {
update${BusinessName}(this.form).then(response => {
update${BusinessName}(this.form).then(response => {
...
@@ -540,6 +589,40 @@ export default {
...
@@ -540,6 +589,40 @@ export default {
this.msgSuccess("删除成功");
this.msgSuccess("删除成功");
})
})
},
},
#if($table.sub)
/** ${subTable.functionName}序号 */
row${subClassName}Index({ row, rowIndex }) {
row.index = rowIndex + 1;
},
/** ${subTable.functionName}添加按钮操作 */
handleAdd${subClassName}() {
let obj = {};
#foreach($column in $subTable.columns)
#if($column.pk || $column.javaField == ${subTableFkclassName})
#elseif($column.list && "" != $javaField)
obj.$column.javaField = "";
#end
#end
this.${subclassName}List.push(obj);
},
/** ${subTable.functionName}删除按钮操作 */
handleDelete${subClassName}() {
if (this.checked${subClassName}.length == 0) {
this.$alert("请先选择要删除的${subTable.functionName}数据", "提示", { confirmButtonText: "确定", });
} else {
this.${subclassName}List.splice(this.checked${subClassName}[0].index - 1, 1);
}
},
/** 单选框选中数据 */
handle${subClassName}SelectionChange(selection) {
if (selection.length > 1) {
this.$refs.${subclassName}.clearSelection();
this.$refs.${subclassName}.toggleRowSelection(selection.pop());
} else {
this.checked${subClassName} = selection;
}
},
#end
/** 导出按钮操作 */
/** 导出按钮操作 */
handleExport() {
handleExport() {
const queryParams = this.queryParams;
const queryParams = this.queryParams;
...
...
ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm
View file @
14a85989
...
@@ -9,6 +9,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -9,6 +9,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"${column.javaField}"
column=
"${column.columnName}"
/>
<result
property=
"${column.javaField}"
column=
"${column.columnName}"
/>
#end
#end
</resultMap>
</resultMap>
#if($table.sub)
<resultMap
id=
"${ClassName}${subClassName}Result"
type=
"${ClassName}"
extends=
"${ClassName}Result"
>
<collection
property=
"${subclassName}List"
notNullColumn=
"${subTable.pkColumn.columnName}"
javaType=
"java.util.List"
resultMap=
"${subClassName}Result"
/>
</resultMap>
<resultMap
type=
"${subClassName}"
id=
"${subClassName}Result"
>
#foreach ($column in $subTable.columns)
<result
property=
"${column.javaField}"
column=
"${column.columnName}"
/>
#end
</resultMap>
#end
<sql
id=
"select${ClassName}Vo"
>
<sql
id=
"select${ClassName}Vo"
>
select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
...
@@ -46,9 +58,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -46,9 +58,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</where>
</select>
</select>
<select
id=
"select${ClassName}ById"
parameterType=
"${pkColumn.javaType}"
resultMap=
"${ClassName}Result"
>
<select
id=
"select${ClassName}ById"
parameterType=
"${pkColumn.javaType}"
resultMap=
"#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end"
>
#if($table.crud || $table.tree)
<include
refid=
"select${ClassName}Vo"
/>
<include
refid=
"select${ClassName}Vo"
/>
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
#elseif($table.sub)
select#foreach($column in $columns) a.$column.columnName#if($velocityCount != $columns.size()),#end#end,
#foreach($column in $subTable.columns) b.$column.columnName#if($velocityCount != $subTable.columns.size()),#end#end
from ${tableName} a
left join ${subTableName} b on b.${subTableFkName} = a.${pkColumn.columnName}
where a.${pkColumn.columnName} = #{${pkColumn.javaField}}
#end
</select>
</select>
<insert
id=
"insert${ClassName}"
parameterType=
"${ClassName}"
#if($pkColumn.increment)
useGeneratedKeys=
"true"
keyProperty=
"$pkColumn.javaField"
#end
>
<insert
id=
"insert${ClassName}"
parameterType=
"${ClassName}"
#if($pkColumn.increment)
useGeneratedKeys=
"true"
keyProperty=
"$pkColumn.javaField"
#end
>
...
@@ -91,5 +112,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -91,5 +112,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{${pkColumn.javaField}}
#{${pkColumn.javaField}}
</foreach>
</foreach>
</delete>
</delete>
#if($table.sub)
<delete
id=
"delete${subClassName}By${subTableFkClassName}s"
parameterType=
"String"
>
delete from ${subTableName} where ${subTableFkName} in
<foreach
item=
"${subTableFkclassName}"
collection=
"array"
open=
"("
separator=
","
close=
")"
>
#{${subTableFkclassName}}
</foreach>
</delete>
<delete
id=
"delete${subClassName}By${subTableFkClassName}"
parameterType=
"Long"
>
delete from ${subTableName} where ${subTableFkName} = #{${subTableFkclassName}}
</delete>
<insert
id=
"batch${subClassName}"
>
insert into ${subTableName}(#foreach($column in $subTable.columns) $column.columnName#if($velocityCount != $subTable.columns.size()),#end#end) values
<foreach
item=
"item"
index=
"index"
collection=
"list"
separator=
","
>
(#foreach($column in $subTable.columns) #{item.$column.javaField}#if($velocityCount != $subTable.columns.size()),#end#end)
</foreach>
</insert>
#end
</mapper>
</mapper>
\ No newline at end of file
ruoyi-ui/src/views/tool/gen/editTable.vue
View file @
14a85989
...
@@ -113,7 +113,7 @@
...
@@ -113,7 +113,7 @@
</el-table>
</el-table>
</el-tab-pane>
</el-tab-pane>
<el-tab-pane
label=
"生成信息"
name=
"genInfo"
>
<el-tab-pane
label=
"生成信息"
name=
"genInfo"
>
<gen-info-form
ref=
"genInfo"
:info=
"info"
:menus=
"menus"
/>
<gen-info-form
ref=
"genInfo"
:info=
"info"
:
tables=
"tables"
:
menus=
"menus"
/>
</el-tab-pane>
</el-tab-pane>
</el-tabs>
</el-tabs>
<el-form
label-width=
"100px"
>
<el-form
label-width=
"100px"
>
...
@@ -144,6 +144,8 @@ export default {
...
@@ -144,6 +144,8 @@ export default {
activeName
:
"
cloum
"
,
activeName
:
"
cloum
"
,
// 表格的高度
// 表格的高度
tableHeight
:
document
.
documentElement
.
scrollHeight
-
245
+
"
px
"
,
tableHeight
:
document
.
documentElement
.
scrollHeight
-
245
+
"
px
"
,
// 表信息
tables
:
[],
// 表列信息
// 表列信息
cloumns
:
[],
cloumns
:
[],
// 字典信息
// 字典信息
...
@@ -161,6 +163,7 @@ export default {
...
@@ -161,6 +163,7 @@ export default {
getGenTable
(
tableId
).
then
(
res
=>
{
getGenTable
(
tableId
).
then
(
res
=>
{
this
.
cloumns
=
res
.
data
.
rows
;
this
.
cloumns
=
res
.
data
.
rows
;
this
.
info
=
res
.
data
.
info
;
this
.
info
=
res
.
data
.
info
;
this
.
tables
=
res
.
data
.
tables
;
});
});
/** 查询字典下拉列表 */
/** 查询字典下拉列表 */
getDictOptionselect
().
then
(
response
=>
{
getDictOptionselect
().
then
(
response
=>
{
...
...
ruoyi-ui/src/views/tool/gen/genInfoForm.vue
View file @
14a85989
...
@@ -4,9 +4,10 @@
...
@@ -4,9 +4,10 @@
<el-col
:span=
"12"
>
<el-col
:span=
"12"
>
<el-form-item
prop=
"tplCategory"
>
<el-form-item
prop=
"tplCategory"
>
<span
slot=
"label"
>
生成模板
</span>
<span
slot=
"label"
>
生成模板
</span>
<el-select
v-model=
"info.tplCategory"
>
<el-select
v-model=
"info.tplCategory"
@
change=
"tplSelectChange"
>
<el-option
label=
"单表(增删改查)"
value=
"crud"
/>
<el-option
label=
"单表(增删改查)"
value=
"crud"
/>
<el-option
label=
"树表(增删改查)"
value=
"tree"
/>
<el-option
label=
"树表(增删改查)"
value=
"tree"
/>
<el-option
label=
"主子表(增删改查)"
value=
"sub"
/>
</el-select>
</el-select>
</el-form-item>
</el-form-item>
</el-col>
</el-col>
...
@@ -126,8 +127,8 @@
...
@@ -126,8 +127,8 @@
</span>
</span>
<el-select
v-model=
"info.treeCode"
placeholder=
"请选择"
>
<el-select
v-model=
"info.treeCode"
placeholder=
"请选择"
>
<el-option
<el-option
v-for=
"
column
in info.columns"
v-for=
"
(column, index)
in info.columns"
:key=
"
column.columnName
"
:key=
"
index
"
:label=
"column.columnName + ':' + column.columnComment"
:label=
"column.columnName + ':' + column.columnComment"
:value=
"column.columnName"
:value=
"column.columnName"
></el-option>
></el-option>
...
@@ -144,8 +145,8 @@
...
@@ -144,8 +145,8 @@
</span>
</span>
<el-select
v-model=
"info.treeParentCode"
placeholder=
"请选择"
>
<el-select
v-model=
"info.treeParentCode"
placeholder=
"请选择"
>
<el-option
<el-option
v-for=
"
column
in info.columns"
v-for=
"
(column, index)
in info.columns"
:key=
"
column.columnName
"
:key=
"
index
"
:label=
"column.columnName + ':' + column.columnComment"
:label=
"column.columnName + ':' + column.columnComment"
:value=
"column.columnName"
:value=
"column.columnName"
></el-option>
></el-option>
...
@@ -162,8 +163,47 @@
...
@@ -162,8 +163,47 @@
</span>
</span>
<el-select
v-model=
"info.treeName"
placeholder=
"请选择"
>
<el-select
v-model=
"info.treeName"
placeholder=
"请选择"
>
<el-option
<el-option
v-for=
"column in info.columns"
v-for=
"(column, index) in info.columns"
:key=
"column.columnName"
:key=
"index"
:label=
"column.columnName + ':' + column.columnComment"
:value=
"column.columnName"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row
v-show=
"info.tplCategory == 'sub'"
>
<h4
class=
"form-header"
>
关联信息
</h4>
<el-col
:span=
"12"
>
<el-form-item>
<span
slot=
"label"
>
关联子表的表名
<el-tooltip
content=
"关联子表的表名, 如:sys_user"
placement=
"top"
>
<i
class=
"el-icon-question"
></i>
</el-tooltip>
</span>
<el-select
v-model=
"info.subTableName"
placeholder=
"请选择"
@
change=
"subSelectChange"
>
<el-option
v-for=
"(table, index) in tables"
:key=
"index"
:label=
"table.tableName + ':' + table.tableComment"
:value=
"table.tableName"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col
:span=
"12"
>
<el-form-item>
<span
slot=
"label"
>
子表关联的外键名
<el-tooltip
content=
"子表关联的外键名, 如:user_id"
placement=
"top"
>
<i
class=
"el-icon-question"
></i>
</el-tooltip>
</span>
<el-select
v-model=
"info.subTableFkName"
placeholder=
"请选择"
>
<el-option
v-for=
"(column, index) in subColumns"
:key=
"index"
:label=
"column.columnName + ':' + column.columnComment"
:label=
"column.columnName + ':' + column.columnComment"
:value=
"column.columnName"
:value=
"column.columnName"
></el-option>
></el-option>
...
@@ -185,6 +225,10 @@ export default {
...
@@ -185,6 +225,10 @@ export default {
type
:
Object
,
type
:
Object
,
default
:
null
default
:
null
},
},
tables
:
{
type
:
Array
,
default
:
null
},
menus
:
{
menus
:
{
type
:
Array
,
type
:
Array
,
default
:
[]
default
:
[]
...
@@ -192,6 +236,7 @@ export default {
...
@@ -192,6 +236,7 @@ export default {
},
},
data
()
{
data
()
{
return
{
return
{
subColumns
:
[],
rules
:
{
rules
:
{
tplCategory
:
[
tplCategory
:
[
{
required
:
true
,
message
:
"
请选择生成模板
"
,
trigger
:
"
blur
"
}
{
required
:
true
,
message
:
"
请选择生成模板
"
,
trigger
:
"
blur
"
}
...
@@ -212,6 +257,11 @@ export default {
...
@@ -212,6 +257,11 @@ export default {
};
};
},
},
created
()
{},
created
()
{},
watch
:
{
'
info.subTableName
'
:
function
(
val
)
{
this
.
setSubTableColumns
(
val
);
}
},
methods
:
{
methods
:
{
/** 转换菜单数据结构 */
/** 转换菜单数据结构 */
normalizer
(
node
)
{
normalizer
(
node
)
{
...
@@ -223,6 +273,27 @@ export default {
...
@@ -223,6 +273,27 @@ export default {
label
:
node
.
menuName
,
label
:
node
.
menuName
,
children
:
node
.
children
children
:
node
.
children
};
};
},
/** 选择子表名触发 */
subSelectChange
(
value
)
{
this
.
info
.
subTableFkName
=
''
;
},
/** 选择生成模板触发 */
tplSelectChange
(
value
)
{
if
(
value
!==
'
sub
'
)
{
this
.
info
.
subTableName
=
''
;
this
.
info
.
subTableFkName
=
''
;
}
},
/** 设置关联外键 */
setSubTableColumns
(
value
)
{
for
(
var
item
in
this
.
tables
)
{
const
name
=
this
.
tables
[
item
].
tableName
;
if
(
value
===
name
)
{
this
.
subColumns
=
this
.
tables
[
item
].
columns
;
break
;
}
}
}
}
}
}
};
};
...
...
ruoyi-ui/src/views/tool/gen/index.vue
View file @
14a85989
...
@@ -84,7 +84,7 @@
...
@@ -84,7 +84,7 @@
</el-row>
</el-row>
<el-table
v-loading=
"loading"
:data=
"tableList"
@
selection-change=
"handleSelectionChange"
>
<el-table
v-loading=
"loading"
:data=
"tableList"
@
selection-change=
"handleSelectionChange"
>
<el-table-column
type=
"selection"
width=
"55"
></el-table-column>
<el-table-column
type=
"selection"
align=
"center"
width=
"55"
></el-table-column>
<el-table-column
label=
"序号"
type=
"index"
width=
"50"
align=
"center"
>
<el-table-column
label=
"序号"
type=
"index"
width=
"50"
align=
"center"
>
<template
slot-scope=
"scope"
>
<template
slot-scope=
"scope"
>
<span>
{{
(
queryParams
.
pageNum
-
1
)
*
queryParams
.
pageSize
+
scope
.
$index
+
1
}}
</span>
<span>
{{
(
queryParams
.
pageNum
-
1
)
*
queryParams
.
pageSize
+
scope
.
$index
+
1
}}
</span>
...
...
sql/ry_202
0112
8.sql
→
sql/ry_202
1010
8.sql
View file @
14a85989
...
@@ -633,6 +633,8 @@ create table gen_table (
...
@@ -633,6 +633,8 @@ create table gen_table (
table_id
bigint
(
20
)
not
null
auto_increment
comment
'编号'
,
table_id
bigint
(
20
)
not
null
auto_increment
comment
'编号'
,
table_name
varchar
(
200
)
default
''
comment
'表名称'
,
table_name
varchar
(
200
)
default
''
comment
'表名称'
,
table_comment
varchar
(
500
)
default
''
comment
'表描述'
,
table_comment
varchar
(
500
)
default
''
comment
'表描述'
,
sub_table_name
varchar
(
64
)
default
null
comment
'关联子表的表名'
,
sub_table_fk_name
varchar
(
64
)
default
null
comment
'子表关联的外键名'
,
class_name
varchar
(
100
)
default
''
comment
'实体类名称'
,
class_name
varchar
(
100
)
default
''
comment
'实体类名称'
,
tpl_category
varchar
(
200
)
default
'crud'
comment
'使用的模板(crud单表操作 tree树表操作)'
,
tpl_category
varchar
(
200
)
default
'crud'
comment
'使用的模板(crud单表操作 tree树表操作)'
,
package_name
varchar
(
100
)
comment
'生成包路径'
,
package_name
varchar
(
100
)
comment
'生成包路径'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment