Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
renren-generator
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴迪
renren-generator
Commits
c5f63b89
Commit
c5f63b89
authored
Jul 17, 2023
by
吴迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加data
parent
ac239744
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
240 additions
and
25 deletions
+240
-25
GenUtils.java
src/main/java/io/renren/utils/GenUtils.java
+22
-10
addui.vue.vm
src/main/resources/template/addui.vue.vm
+83
-0
index.vue.vm
src/main/resources/template/index.vue.vm
+14
-14
menu.sql.vm
src/main/resources/template/menu.sql.vm
+10
-1
updateui.vue.vm
src/main/resources/template/updateui.vue.vm
+111
-0
No files found.
src/main/java/io/renren/utils/GenUtils.java
View file @
c5f63b89
...
@@ -48,7 +48,8 @@ public class GenUtils {
...
@@ -48,7 +48,8 @@ public class GenUtils {
templates
.
add
(
"template/Dao.java.vm"
);
templates
.
add
(
"template/Dao.java.vm"
);
templates
.
add
(
"template/index.vue.vm"
);
templates
.
add
(
"template/index.vue.vm"
);
templates
.
add
(
"template/add-or-update.vue.vm"
);
templates
.
add
(
"template/addui.vue.vm"
);
templates
.
add
(
"template/updateui.vue.vm"
);
if
(
MongoManager
.
isMongo
())
{
if
(
MongoManager
.
isMongo
())
{
// mongo不需要mapper、sql 实体类需要替换
// mongo不需要mapper、sql 实体类需要替换
templates
.
remove
(
0
);
templates
.
remove
(
0
);
...
@@ -277,7 +278,7 @@ public class GenUtils {
...
@@ -277,7 +278,7 @@ public class GenUtils {
public
static
String
tableToJava
(
String
tableName
,
String
[]
tablePrefixArray
)
{
public
static
String
tableToJava
(
String
tableName
,
String
[]
tablePrefixArray
)
{
if
(
null
!=
tablePrefixArray
&&
tablePrefixArray
.
length
>
0
)
{
if
(
null
!=
tablePrefixArray
&&
tablePrefixArray
.
length
>
0
)
{
for
(
String
tablePrefix
:
tablePrefixArray
)
{
for
(
String
tablePrefix
:
tablePrefixArray
)
{
if
(
tableName
.
startsWith
(
tablePrefix
))
{
if
(
tableName
.
startsWith
(
tablePrefix
))
{
tableName
=
tableName
.
replaceFirst
(
tablePrefix
,
""
);
tableName
=
tableName
.
replaceFirst
(
tablePrefix
,
""
);
}
}
}
}
...
@@ -305,13 +306,13 @@ public class GenUtils {
...
@@ -305,13 +306,13 @@ public class GenUtils {
packagePath
+=
packageName
.
replace
(
"."
,
File
.
separator
)
+
File
.
separator
+
moduleName
+
File
.
separator
;
packagePath
+=
packageName
.
replace
(
"."
,
File
.
separator
)
+
File
.
separator
+
moduleName
+
File
.
separator
;
}
}
if
(
template
.
contains
(
"MongoChildrenEntity.java.vm"
))
{
if
(
template
.
contains
(
"MongoChildrenEntity.java.vm"
))
{
return
packagePath
+
"entity"
+
File
.
separator
+
"inner"
+
File
.
separator
+
currentTableName
+
File
.
separator
+
splitInnerName
(
className
)
+
"InnerEntity.java"
;
return
packagePath
+
"entity"
+
File
.
separator
+
"inner"
+
File
.
separator
+
currentTableName
+
File
.
separator
+
splitInnerName
(
className
)
+
"InnerEntity.java"
;
}
}
if
(
template
.
contains
(
"Entity.java.vm"
)
||
template
.
contains
(
"MongoEntity.java.vm"
))
{
if
(
template
.
contains
(
"Entity.java.vm"
)
||
template
.
contains
(
"MongoEntity.java.vm"
))
{
return
packagePath
+
"entity"
+
File
.
separator
+
className
+
"Entity.java"
;
return
packagePath
+
"entity"
+
File
.
separator
+
className
+
"Entity.java"
;
}
}
if
(
template
.
contains
(
"Form.java.vm"
)
)
{
if
(
template
.
contains
(
"Form.java.vm"
))
{
return
packagePath
+
"form"
+
File
.
separator
+
className
+
"Form.java"
;
return
packagePath
+
"form"
+
File
.
separator
+
className
+
"Form.java"
;
}
}
...
@@ -341,19 +342,30 @@ public class GenUtils {
...
@@ -341,19 +342,30 @@ public class GenUtils {
if
(
template
.
contains
(
"index.vue.vm"
))
{
if
(
template
.
contains
(
"index.vue.vm"
))
{
return
"main"
+
File
.
separator
+
"resources"
+
File
.
separator
+
"src"
+
File
.
separator
+
"views"
+
File
.
separator
+
"modules"
+
return
"main"
+
File
.
separator
+
"resources"
+
File
.
separator
+
"src"
+
File
.
separator
+
"views"
+
File
.
separator
+
"modules"
+
File
.
separator
+
moduleName
+
File
.
separator
+
className
.
toLowerCase
()
+
".vue"
;
File
.
separator
+
moduleName
+
File
.
separator
+
className
.
toLowerCase
()
+
File
.
separator
+
className
.
toLowerCase
()
+
".vue"
;
}
}
//
//if (template.contains("add-or-update.vue.vm")) {
// return "main" + File.separator + "resources" + File.separator + "src" + File.separator + "views" + File.separator + "modules" +
// File.separator + moduleName + File.separator + className.toLowerCase() + "-add-or-update.vue";
//}
if
(
template
.
contains
(
"add
-or-update
.vue.vm"
))
{
if
(
template
.
contains
(
"add
ui
.vue.vm"
))
{
return
"main"
+
File
.
separator
+
"resources"
+
File
.
separator
+
"src"
+
File
.
separator
+
"views"
+
File
.
separator
+
"modules"
+
return
"main"
+
File
.
separator
+
"resources"
+
File
.
separator
+
"src"
+
File
.
separator
+
"views"
+
File
.
separator
+
"modules"
+
File
.
separator
+
moduleName
+
File
.
separator
+
className
.
toLowerCase
()
+
"-add-or-update
.vue"
;
File
.
separator
+
moduleName
+
File
.
separator
+
className
.
toLowerCase
()
+
File
.
separator
+
className
.
toLowerCase
()
+
"addui
.vue"
;
}
}
if
(
template
.
contains
(
"updateui.vue.vm"
))
{
return
"main"
+
File
.
separator
+
"resources"
+
File
.
separator
+
"src"
+
File
.
separator
+
"views"
+
File
.
separator
+
"modules"
+
File
.
separator
+
moduleName
+
File
.
separator
+
className
.
toLowerCase
()
+
File
.
separator
+
className
.
toLowerCase
()
+
"updateui.vue"
;
}
return
null
;
return
null
;
}
}
private
static
String
splitInnerName
(
String
name
){
private
static
String
splitInnerName
(
String
name
)
{
name
=
name
.
replaceAll
(
"\\."
,
"_"
);
name
=
name
.
replaceAll
(
"\\."
,
"_"
);
return
name
;
return
name
;
}
}
}
}
src/main/resources/template/addui.vue.vm
0 → 100644
View file @
c5f63b89
<template>
<div>
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
#foreach($column in $columns)
#if($column.columnName != $pk.columnName)
<el-form-item label="${column.comments}" prop="${column.attrname}">
<el-input v-model="dataForm.${column.attrname}" placeholder="${column.comments}"></el-input>
</el-form-item>
#end
#end
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
<el-button @click="visible = false">取消</el-button>
</span>
</div>
</template>
<script>
export default {
data () {
return {
dataForm: {
#foreach($column in $columns)
#if($column.columnName == $pk.columnName)
${column.attrname}: 0,
#else
${column.attrname}: ''#if($velocityCount != $columns.size()),#end
#end
#end
},
dataRule: {
#foreach($column in $columns)
#if($column.columnName != $pk.columnName)
${column.attrname}: [
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
]#if($velocityCount != $columns.size()),#end
#end
#end
}
}
},
methods: {
// 表单提交
dataFormSubmit () {
#[[this.$refs['dataForm'].validate((valid) => {]]#
if (valid) {
this.$http({
url: #[[this.$http.adornUrl]]#(`/${moduleName}/${pathName}/${!this.dataForm.${pk.attrname} ? 'save' : 'update'}`),
method: 'post',
#[[data: this.$http.adornData({]]#
#foreach($column in $columns)
#if($column.columnName == $pk.columnName)
'${column.attrname}': this.dataForm.${column.attrname} || undefined,
#else
'${column.attrname}': this.dataForm.${column.attrname}#if($velocityCount != $columns.size()),#end
#end
#end
})
}).then(({data}) => {
if (data && data.code === 0) {
#[[this.$message({]]#
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
#[[this.$emit('refreshDataList')]]#
}
})
} else {
#[[this.$message.error(data.msg)]]#
}
})
}
})
}
}
}
</script>
src/main/resources/template/index.vue.vm
View file @
c5f63b89
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
</el-form-item>
</el-form-item>
<el-form-item>
<el-form-item>
<el-button @click="getDataList()">查询</el-button>
<el-button @click="getDataList()">查询</el-button>
<el-button v-if="isAuth('${moduleName}:${pathName}:save')" type="primary" @click="add
OrUpdate
Handle()">新增</el-button>
<el-button v-if="isAuth('${moduleName}:${pathName}:save')" type="primary" @click="addHandle()">新增</el-button>
<el-button v-if="isAuth('${moduleName}:${pathName}:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
<el-button v-if="isAuth('${moduleName}:${pathName}:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
width="150"
width="150"
label="操作">
label="操作">
<template slot-scope="scope">
<template slot-scope="scope">
<el-button type="text" size="small" @click="
addOrU
pdateHandle(scope.row.${pk.attrname})">修改</el-button>
<el-button type="text" size="small" @click="
u
pdateHandle(scope.row.${pk.attrname})">修改</el-button>
<el-button type="text" size="small" @click="deleteHandle(scope.row.${pk.attrname})">删除</el-button>
<el-button type="text" size="small" @click="deleteHandle(scope.row.${pk.attrname})">删除</el-button>
</template>
</template>
</el-table-column>
</el-table-column>
...
@@ -51,13 +51,10 @@
...
@@ -51,13 +51,10 @@
:total="totalPage"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
</el-pagination>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
</div>
</div>
</template>
</template>
<script>
<script>
import AddOrUpdate from './${pathName}-add-or-update'
export default {
export default {
data () {
data () {
return {
return {
...
@@ -73,9 +70,6 @@
...
@@ -73,9 +70,6 @@
addOrUpdateVisible: false
addOrUpdateVisible: false
}
}
},
},
components: {
AddOrUpdate
},
activated () {
activated () {
this.getDataList()
this.getDataList()
},
},
...
@@ -117,15 +111,21 @@
...
@@ -117,15 +111,21 @@
selectionChangeHandle (val) {
selectionChangeHandle (val) {
this.dataListSelections = val
this.dataListSelections = val
},
},
// 新增 / 修改
// 新增
addOrUpdateHandle (id) {
addHandle () {
this.addOrUpdateVisible = true
#[[this.$nextTick(() => {]]#
#[[this.$nextTick(() => {]]#
#[[this.$router.push]]#({ name: 'manage-${pathName}-${pathName}addui' })
this.$refs.addOrUpdate.init(id)
#[[})]]#
})
},
// 修改
updateHandle (id) {
#[[this.$nextTick(() => {]]#
#[[this.$router.push]]#({ name: 'manage-${pathName}-${pathName}updateui', params: { id: id } })
#[[})]]#
},
},
// 删除
// 删除
deleteHandle (id) {
deleteHandle (id) {
// 提示要修改成name,每个表的都不一样,所以做不了通用的,暂时使用id
var ids = id ? [id] : this.dataListSelections.map(item => {
var ids = id ? [id] : this.dataListSelections.map(item => {
return item.${pk.attrname}
return item.${pk.attrname}
})
})
...
...
src/main/resources/template/menu.sql.vm
View file @
c5f63b89
-- 菜单SQL
-- 菜单SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('0', '${comments}', '${moduleName}/${pathName}', NULL, '1', 'config', '6');
VALUES ('0', '${comments}', '${moduleName}/${pathName}
/${pathName}
', NULL, '1', 'config', '6');
-- 按钮父菜单ID
-- 按钮父菜单ID
set @parentId = @@identity;
set @parentId = @@identity;
...
@@ -14,3 +14,12 @@ INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `or
...
@@ -14,3 +14,12 @@ INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `or
SELECT @parentId, '修改', null, '${moduleName}:${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`)
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '删除', null, '${moduleName}:${pathName}:delete', '2', null, '6';
SELECT @parentId, '删除', null, '${moduleName}:${pathName}:delete', '2', null, '6';
-- 新增的${moduleName}ui菜单
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('53', '${comments}-新增', '${moduleName}/${pathName}/${pathName}addui', '${moduleName}:${pathName}:save', '1', 'config', '6');
-- 修改的${moduleName}ui菜单
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('53', '${comments}-修改', '${moduleName}/${pathName}/${pathName}updateui', '${moduleName}:${pathName}:update', '1', 'config', '6');
src/main/resources/template/updateui.vue.vm
0 → 100644
View file @
c5f63b89
<template>
<div>
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
#foreach($column in $columns)
#if($column.columnName != $pk.columnName)
<el-form-item label="${column.comments}" prop="${column.attrname}">
<el-input v-model="dataForm.${column.attrname}" placeholder="${column.comments}"></el-input>
</el-form-item>
#end
#end
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
<el-button @click="visible = false">取消</el-button>
</span>
</div>
</template>
<script>
export default {
data () {
return {
visible: false,
dataForm: {
#foreach($column in $columns)
#if($column.columnName == $pk.columnName)
${column.attrname}: 0,
#else
${column.attrname}: ''#if($velocityCount != $columns.size()),#end
#end
#end
},
dataRule: {
#foreach($column in $columns)
#if($column.columnName != $pk.columnName)
${column.attrname}: [
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
]#if($velocityCount != $columns.size()),#end
#end
#end
}
}
},
mounted () {
this.$nextTick(() => {
this.init(this.$route.params.id)
})
},
methods: {
init (id) {
this.dataForm.${pk.attrname} = id || 0
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.${pk.attrname}) {
this.$http({
url: #[[this.$http.adornUrl]]#(`/${moduleName}/${pathName}/info/#[[$]]#{this.dataForm.${pk.attrname}}`),
method: 'get',
#[[params: this.$http.adornParams()]]#
}).then(({data}) => {
if (data && data.code === 0) {
#foreach($column in $columns)
#if($column.columnName != $pk.columnName)
this.dataForm.${column.attrname} = data.data.${column.attrname}
#end
#end
}
})
}
})
},
// 表单提交
dataFormSubmit () {
#[[this.$refs['dataForm'].validate((valid) => {]]#
if (valid) {
this.$http({
url: #[[this.$http.adornUrl]]#(`/${moduleName}/${pathName}/${!this.dataForm.${pk.attrname} ? 'save' : 'update'}`),
method: 'post',
#[[data: this.$http.adornData({]]#
#foreach($column in $columns)
#if($column.columnName == $pk.columnName)
'${column.attrname}': this.dataForm.${column.attrname} || undefined,
#else
'${column.attrname}': this.dataForm.${column.attrname}#if($velocityCount != $columns.size()),#end
#end
#end
})
}).then(({data}) => {
if (data && data.code === 0) {
#[[this.$message({]]#
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
#[[this.$emit('refreshDataList')]]#
}
})
} else {
#[[this.$message.error(data.msg)]]#
}
})
}
})
}
}
}
</script>
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