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
955e382e
Commit
955e382e
authored
Mar 22, 2018
by
Mark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持renren-fast-vue代码生成
parent
662d87c6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
330 additions
and
3 deletions
+330
-3
GenUtils.java
src/main/java/io/renren/utils/GenUtils.java
+24
-3
add-or-update.vue.vm
src/main/resources/template/elementui/add-or-update.vue.vm
+104
-0
index.js.vm
src/main/resources/template/elementui/index.js.vm
+49
-0
index.vue.vm
src/main/resources/template/elementui/index.vue.vm
+153
-0
No files found.
src/main/java/io/renren/utils/GenUtils.java
View file @
955e382e
...
...
@@ -36,9 +36,15 @@ public class GenUtils {
templates
.
add
(
"template/Service.java.vm"
);
templates
.
add
(
"template/ServiceImpl.java.vm"
);
templates
.
add
(
"template/Controller.java.vm"
);
templates
.
add
(
"template/menu.sql.vm"
);
templates
.
add
(
"template/adminlte/list.html.vm"
);
templates
.
add
(
"template/adminlte/list.js.vm"
);
templates
.
add
(
"template/menu.sql.vm"
);
templates
.
add
(
"template/elementui/index.vue.vm"
);
templates
.
add
(
"template/elementui/add-or-update.vue.vm"
);
templates
.
add
(
"template/elementui/index.js.vm"
);
return
templates
;
}
...
...
@@ -199,6 +205,10 @@ public class GenUtils {
return
"main"
+
File
.
separator
+
"resources"
+
File
.
separator
+
"mapper"
+
File
.
separator
+
moduleName
+
File
.
separator
+
className
+
"Dao.xml"
;
}
if
(
template
.
contains
(
"menu.sql.vm"
))
{
return
className
.
toLowerCase
()
+
"_menu.sql"
;
}
if
(
template
.
contains
(
"list.html.vm"
))
{
return
"main"
+
File
.
separator
+
"resources"
+
File
.
separator
+
"adminlte"
+
File
.
separator
+
"modules"
+
File
.
separator
+
moduleName
+
File
.
separator
+
className
.
toLowerCase
()
+
".html"
;
...
...
@@ -209,8 +219,19 @@ public class GenUtils {
+
"modules"
+
File
.
separator
+
moduleName
+
File
.
separator
+
className
.
toLowerCase
()
+
".js"
;
}
if
(
template
.
contains
(
"menu.sql.vm"
))
{
return
className
.
toLowerCase
()
+
"_menu.sql"
;
if
(
template
.
contains
(
"index.vue.vm"
))
{
return
"main"
+
File
.
separator
+
"resources"
+
File
.
separator
+
"elementui"
+
File
.
separator
+
"src"
+
File
.
separator
+
"views"
+
File
.
separator
+
className
.
toLowerCase
()
+
File
.
separator
+
"index.vue"
;
}
if
(
template
.
contains
(
"add-or-update.vue.vm"
))
{
return
"main"
+
File
.
separator
+
"resources"
+
File
.
separator
+
"elementui"
+
File
.
separator
+
"src"
+
File
.
separator
+
"views"
+
File
.
separator
+
className
.
toLowerCase
()
+
File
.
separator
+
"add-or-update.vue"
;
}
if
(
template
.
contains
(
"index.js.vm"
))
{
return
"main"
+
File
.
separator
+
"resources"
+
File
.
separator
+
"elementui"
+
File
.
separator
+
"src"
+
File
.
separator
+
"api"
+
File
.
separator
+
"modules"
+
File
.
separator
+
className
.
toLowerCase
()
+
".js"
;
}
return
null
;
...
...
src/main/resources/template/elementui/add-or-update.vue.vm
0 → 100644
View file @
955e382e
<template>
<el-dialog
:title="!dataForm.id ? '新增' : '修改'"
:close-on-click-modal="false"
:visible.sync="visible">
<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 @click="visible = false">取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
</span>
</el-dialog>
</template>
<script>
import API from '@/api'
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
}
}
},
methods: {
init (id) {
this.dataForm.${pk.attrname} = id || 0
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.${pk.attrname}) {
API.${pathName}.info(this.dataForm.${pk.attrname}).then(({data}) => {
if (data && data.code === 0) {
#foreach($column in $columns)
#if($column.columnName != $pk.columnName)
this.dataForm.${column.attrname} = data.${pathName}.${column.attrname}
#end
#end
}
})
}
})
},
// 表单提交
dataFormSubmit () {
#[[this.$refs['dataForm'].validate((valid) => {]]#
if (valid) {
var params = {
#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
}
var tick = !this.dataForm.${pk.attrname} ? API.${pathName}.add(params) : API.${pathName}.update(params)
tick.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/elementui/index.js.vm
0 → 100644
View file @
955e382e
import request from '../request'
import requestUrl from '../requestUrl'
import requestParam from '../requestParam'
import isInteger from 'lodash/isInteger'
// 获取列表
export function list (params) {
return request({
url: requestUrl('/${moduleName}/${pathName}/list'),
method: 'get',
params: requestParam(params, 'get')
})
}
// 获取信息
export function info (id) {
return request({
url: requestUrl('/${moduleName}/${pathName}/info' + (isInteger(id) ? `/${id}` : '')),
method: 'get',
params: requestParam({}, 'get')
})
}
// 添加
export function add (params) {
return request({
url: requestUrl('/${moduleName}/${pathName}/save'),
method: 'post',
data: requestParam(params)
})
}
// 修改
export function update (params) {
return request({
url: requestUrl('/${moduleName}/${pathName}/update'),
method: 'post',
data: requestParam(params)
})
}
// 删除
export function del (params) {
return request({
url: requestUrl('/${moduleName}/${pathName}/delete'),
method: 'post',
data: requestParam(params, 'post', false)
})
}
src/main/resources/template/elementui/index.vue.vm
0 → 100644
View file @
955e382e
<template>
<div class="mod-config">
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
<el-form-item>
<el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button @click="getDataList()">查询</el-button>
<el-button v-if="isAuth('${moduleName}:${pathName}:save')" type="primary" @click="addOrUpdateHandle()">新增</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>
<el-table
:data="dataList"
border
v-loading="dataListLoading"
@selection-change="selectionChangeHandle"
style="width: 100%;">
<el-table-column
type="selection"
header-align="center"
align="center"
width="50">
</el-table-column>
#foreach($column in $columns)
<el-table-column
prop="${column.attrname}"
header-align="center"
align="center"
label="${column.comments}">
</el-table-column>
#end
<el-table-column
fixed="right"
header-align="center"
align="center"
width="150"
label="操作">
<template slot-scope="scope">
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.${pk.attrname})">修改</el-button>
<el-button type="text" size="small" @click="deleteHandle(scope.row.${pk.attrname})">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
</div>
</template>
<script>
import API from '@/api'
import AddOrUpdate from './add-or-update'
export default {
data () {
return {
dataForm: {
key: ''
},
dataList: [],
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false,
dataListSelections: [],
addOrUpdateVisible: false
}
},
components: {
AddOrUpdate
},
activated () {
this.getDataList()
},
methods: {
// 获取数据列表
getDataList () {
this.dataListLoading = true
var params = {
page: this.pageIndex,
limit: this.pageSize,
key: this.dataForm.key
}
API.${pathName}.list(params).then(({data}) => {
if (data && data.code === 0) {
this.dataList = data.page.list
this.totalPage = data.page.totalCount
} else {
this.dataList = []
this.totalPage = 0
}
this.dataListLoading = false
})
},
// 每页数
sizeChangeHandle (val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
// 当前页
currentChangeHandle (val) {
this.pageIndex = val
this.getDataList()
},
// 多选
selectionChangeHandle (val) {
this.dataListSelections = val
},
// 新增 / 修改
addOrUpdateHandle (id) {
this.addOrUpdateVisible = true
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id)
})
},
// 删除
deleteHandle (id) {
var ids = id ? [id] : this.dataListSelections.map(item => {
return item.${pk.attrname}
})
#[[this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {]]#
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
API.${pathName}.del(ids).then(({data}) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.getDataList()
}
})
} 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