This commit is contained in:
20932067@zju.edu.cn 2021-01-26 19:06:36 +08:00
parent b5cc83b651
commit d6b08685d2
16 changed files with 735 additions and 582 deletions

View File

@ -12,11 +12,10 @@ export function listApiclass(query) {
// 获取模块管理选项列表 // 获取模块管理选项列表
export function queryListApiclass() { export function queryListApiclass() {
return request({ return request({
url: '/tool/module/querylist', url: '/tool/apiclass/querylist',
method: 'get', method: 'get',
}) })
} }
// 查询接口类名详细 // 查询接口类名详细
export function getApiclass(id) { export function getApiclass(id) {
return request({ return request({

View File

@ -0,0 +1,53 @@
import request from '@/utils/request'
// 查询接口信息列表
export function listIntertable(query) {
return request({
url: '/generator/intertable/list',
method: 'get',
params: query
})
}
// 查询接口信息详细
export function getIntertable(id) {
return request({
url: '/generator/intertable/' + id,
method: 'get'
})
}
// 新增接口信息
export function addIntertable(data) {
return request({
url: '/generator/intertable',
method: 'post',
data: data
})
}
// 修改接口信息
export function updateIntertable(data) {
return request({
url: '/generator/intertable',
method: 'put',
data: data
})
}
// 删除接口信息
export function delIntertable(id) {
return request({
url: '/generator/intertable/' + id,
method: 'delete'
})
}
// 导出接口信息
export function exportIntertable(query) {
return request({
url: '/generator/intertable/export',
method: 'get',
params: query
})
}

View File

@ -19,6 +19,7 @@ export function queryListModule() {
}) })
} }
// 查询模块管理详细 // 查询模块管理详细
export function getModule(id) { export function getModule(id) {
return request({ return request({

View File

@ -50,7 +50,7 @@ service.interceptors.response.use(res => {
return Promise.reject(new Error(msg)) return Promise.reject(new Error(msg))
}else if (code == 199){ }else if (code == 199){
Message({ Message({
message: msg, message: "查询结果为空!",
type: 'info' type: 'info'
}) })
return res.data return res.data

View File

@ -4,126 +4,73 @@
<el-tab-pane label="基本信息" name="basic"> <el-tab-pane label="基本信息" name="basic">
<apiclass-info-form ref="apiclassInfo" :info="info"/> <apiclass-info-form ref="apiclassInfo" :info="info"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="字段信息" name="cloum"> <el-tab-pane label="接口信息" name="cloum">
<el-row class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['tool:module:export']"
>新增
</el-button>
</el-col>
</el-row>
<el-table ref="dragTable" :data="cloumns" row-key="columnId" :max-height="tableHeight"> <el-table ref="dragTable" :data="cloumns" row-key="columnId" :max-height="tableHeight">
<el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag"/> <el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag"/>
<el-table-column <el-table-column label="接口名称" min-width="10%">
label="字段列名"
prop="columnName"
min-width="10%"
:show-overflow-tooltip="true"
/>
<el-table-column label="字段描述" min-width="10%">
<template slot-scope="scope" > <template slot-scope="scope" >
<el-input v-model="scope.row.columnComment"></el-input> <el-input v-model="scope.row.itName"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column label="接口描述" min-width="10%">
label="物理类型"
prop="columnType"
min-width="10%"
:show-overflow-tooltip="true"
/>
<el-table-column label="Java类型" min-width="11%">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.javaType"> <el-input v-model="scope.row.itDescribe"></el-input>
<el-option label="Long" value="Long"/> </template>
<el-option label="String" value="String"/> </el-table-column>
<el-option label="Integer" value="Integer"/> <el-table-column label="请求路径" min-width="10%">
<el-option label="Double" value="Double"/> <template slot-scope="scope">
<el-option label="BigDecimal" value="BigDecimal"/> <el-input v-model="scope.row.requrl"></el-input>
<el-option label="Date" value="Date"/> </template>
</el-table-column>
<el-table-column label="许可" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isPermission"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="生成" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isGenerate"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="请求类型" min-width="12%">
<template slot-scope="scope">
<el-select v-model="scope.row.method">
<el-option label="Get" value="Get"/>
<el-option label="Post" value="Post"/>
<el-option label="Put" value="Put"/>
<el-option label="Delete" value="Delete"/>
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="java属性" min-width="10%"> <el-table-column label="操作" align="center" min-width="5%">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.javaField"></el-input> <el-button
</template> size="mini"
</el-table-column> type="text"
icon="el-icon-delete"
<el-table-column label="插入" min-width="5%"> @click="handleDelete(scope.$index,scope.row)"
<template slot-scope="scope"> >删除
<el-checkbox true-label="1" v-model="scope.row.isInsert"></el-checkbox> </el-button>
</template>
</el-table-column>
<el-table-column label="编辑" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" v-model="scope.row.isEdit"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="列表" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" v-model="scope.row.isList"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="查询" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" v-model="scope.row.isQuery"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="查询方式" min-width="10%">
<template slot-scope="scope">
<el-select v-model="scope.row.queryType">
<el-option label="=" value="EQ"/>
<el-option label="!=" value="NE"/>
<el-option label=">" value="GT"/>
<el-option label=">=" value="GTE"/>
<el-option label="<" value="LT"/>
<el-option label="<=" value="LTE"/>
<el-option label="LIKE" value="LIKE"/>
<el-option label="BETWEEN" value="BETWEEN"/>
</el-select>
</template>
</el-table-column>
<el-table-column label="必填" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" v-model="scope.row.isRequired"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="是否正则" min-width="10%">
<template slot-scope="scope">
<el-select v-model="scope.row.isRegular">
<el-option v-for="item in regularOptions" :key="item.id"
:label="item.name"
:value="item.id"/>
</el-select>
</template>
</el-table-column>
<el-table-column label="显示类型" min-width="12%">
<template slot-scope="scope">
<el-select v-model="scope.row.htmlType">
<el-option label="文本框" value="input"/>
<el-option label="文本域" value="textarea"/>
<el-option label="下拉框" value="select"/>
<el-option label="单选框" value="radio"/>
<el-option label="复选框" value="checkbox"/>
<el-option label="日期控件" value="datetime"/>
<el-option label="图片上传" value="imageUpload"/>
<el-option label="文件上传" value="fileUpload"/>
<el-option label="富文本控件" value="editor"/>
</el-select>
</template>
</el-table-column>
<el-table-column label="字典类型" min-width="12%">
<template slot-scope="scope">
<el-select v-model="scope.row.dictType" clearable filterable placeholder="请选择">
<el-option
v-for="dict in dictOptions"
:key="dict.dictType"
:label="dict.dictName"
:value="dict.dictType">
<span style="float: left">{{ dict.dictName }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ dict.dictType }}</span>
</el-option>
</el-select>
</template> </template>
</el-table-column> </el-table-column>
</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" :tables="tables" :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">
<el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;"> <el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;">
@ -136,50 +83,105 @@
<script> <script>
import ApiclassInfoForm from "./apiclassInfoForm"; import ApiclassInfoForm from "./apiclassInfoForm";
import {getApiclass} from "@/api/tool/apiclass"; import {listIntertable,updateIntertable} from "@/api/tool/interTable";
import {Message} from "element-ui";
export default { export default {
name: "ApiclassEdit", name: "ApiclassEdit",
components: {ApiclassInfoForm} components: {ApiclassInfoForm},
,
data() { data() {
return { return {
info:[], // name
activeName: "cloum",
//
tableHeight: document.documentElement.scrollHeight - 245 + "px",
//
tables: [],
//
cloumns: [],
//
dictOptions: [],
//
menus: [],
regularOptions: [],
//
info: {}
}; };
}, },
created() { created() {
const apiclassId = this.$route.params && this.$route.params.apiclassId; const apiclassId = this.$route.params && this.$route.params.apiclassId;
if (apiclassId) { if (apiclassId) {
getApiclass(apiclassId).then(response => { let data = {
this.info = response.data; cId: apiclassId,
}); type: 2,
}
listIntertable(data).then(response => {
this.cloumns = response.data.rows
this.info = response.data.info
})
} }
console.log(apiclassId) console.log(apiclassId)
}, },
methods: { methods: {
/** 删除按钮 */
handleDelete(index, row) {
this.cloumns.splice(index, 1);
},
/** 新增按钮 */
handleAdd() {
let row = {
id: null,
cId: this.info.id,
mId: this.info.mId,
isGenerate: '1',
isPermission: '1',
itDescribe: '',
itName: '',
method: 'Get',
requrl: '',
type: 2,
}
this.cloumns.push(row)
},
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
const apiclassForm = this.$refs.apiclassInfo.$refs.apiclassInfoForm; const apiclassForm = this.$refs.apiclassInfo.$refs.apiclassInfoForm;
console.log(apiclassForm.model)
// const genForm = this.$refs.genInfo.$refs.genInfoForm;
Promise.all([apiclassForm].map(this.getFormPromise)).then(res => { Promise.all([apiclassForm].map(this.getFormPromise)).then(res => {
console.log(res)
const validateResult = res.every(item => !!item); const validateResult = res.every(item => !!item);
for (let i=0;i<this.cloumns.length;i++){
if (this.cloumns[i].itDescribe == ''){
Message({
message: "序号"+(i+1)+"接口描述不能为空!",
type: 'error'
})
return
}else if (this.cloumns[i].itName == ''){
Message({
message: "序号"+(i+1)+"接口名称不能为空!",
type: 'error'
})
return
}else if (this.cloumns[i].requrl == ''){
Message({
message: "序号"+(i+1)+"请求路径不能为空!",
type: 'error'
})
return
}
}
if (validateResult) { if (validateResult) {
// const genTable = Object.assign({}, basicForm.model, genForm.model); console.log(apiclassForm.model)
// genTable.columns = this.cloumns; const interTableDto = {
// genTable.params = { apiclass: apiclassForm.model,
// treeCode: genTable.treeCode, interTables: this.cloumns,
// treeName: genTable.treeName, };
// treeParentCode: genTable.treeParentCode, console.log(interTableDto)
// parentMenuId: genTable.parentMenuId updateIntertable(interTableDto).then(res => {
// }; this.msgSuccess(res.msg);
// updateGenTable(genTable).then(res => { if (res.code === 200) {
// this.msgSuccess(res.msg); this.close();
// if (res.code === 200) { }
// this.close(); });
// }
// });
} else { } else {
this.msgError("表单校验未通过,请重新检查提交内容"); this.msgError("表单校验未通过,请重新检查提交内容");
} }

View File

@ -5,125 +5,84 @@
<module-info-form ref="moduleInfo" :info="info"/> <module-info-form ref="moduleInfo" :info="info"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="字段信息" name="cloum"> <el-tab-pane label="字段信息" name="cloum">
<el-row class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['tool:module:export']"
>新增
</el-button>
</el-col>
</el-row>
<el-table ref="dragTable" :data="cloumns" row-key="columnId" :max-height="tableHeight"> <el-table ref="dragTable" :data="cloumns" row-key="columnId" :max-height="tableHeight">
<el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag"/> <el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag"/>
<el-table-column <el-table-column label="接口类" min-width="12%">
label="字段列名"
prop="columnName"
min-width="10%"
:show-overflow-tooltip="true"
/>
<el-table-column label="字段描述" min-width="10%">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.columnComment"></el-input> <el-select v-model="scope.row.cId" placeholder="请选择类">
</template> <el-option
</el-table-column> v-for="item in apiclassOptions"
<el-table-column :key="item.id"
label="物理类型" :label="item.cName"
prop="columnType"
min-width="10%"
:show-overflow-tooltip="true"
/>
<el-table-column label="Java类型" min-width="11%">
<template slot-scope="scope">
<el-select v-model="scope.row.javaType">
<el-option label="Long" value="Long"/>
<el-option label="String" value="String"/>
<el-option label="Integer" value="Integer"/>
<el-option label="Double" value="Double"/>
<el-option label="BigDecimal" value="BigDecimal"/>
<el-option label="Date" value="Date"/>
</el-select>
</template>
</el-table-column>
<el-table-column label="java属性" min-width="10%">
<template slot-scope="scope">
<el-input v-model="scope.row.javaField"></el-input>
</template>
</el-table-column>
<el-table-column label="插入" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" v-model="scope.row.isInsert"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="编辑" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" v-model="scope.row.isEdit"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="列表" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" v-model="scope.row.isList"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="查询" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" v-model="scope.row.isQuery"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="查询方式" min-width="10%">
<template slot-scope="scope">
<el-select v-model="scope.row.queryType">
<el-option label="=" value="EQ"/>
<el-option label="!=" value="NE"/>
<el-option label=">" value="GT"/>
<el-option label=">=" value="GTE"/>
<el-option label="<" value="LT"/>
<el-option label="<=" value="LTE"/>
<el-option label="LIKE" value="LIKE"/>
<el-option label="BETWEEN" value="BETWEEN"/>
</el-select>
</template>
</el-table-column>
<el-table-column label="必填" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" v-model="scope.row.isRequired"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="是否正则" min-width="10%">
<template slot-scope="scope">
<el-select v-model="scope.row.isRegular">
<el-option v-for="item in regularOptions" :key="item.id"
:label="item.name"
:value="item.id"/> :value="item.id"/>
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="显示类型" min-width="12%"> <el-table-column label="接口名称" min-width="10%">
<template slot-scope="scope" > <template slot-scope="scope" >
<el-select v-model="scope.row.htmlType"> <el-input v-model="scope.row.itName"></el-input>
<el-option label="文本框" value="input"/> </template>
<el-option label="文本域" value="textarea"/> </el-table-column>
<el-option label="下拉框" value="select"/> <el-table-column label="接口描述" min-width="10%">
<el-option label="单选框" value="radio"/> <template slot-scope="scope">
<el-option label="复选框" value="checkbox"/> <el-input v-model="scope.row.itDescribe"></el-input>
<el-option label="日期控件" value="datetime"/> </template>
<el-option label="图片上传" value="imageUpload"/> </el-table-column>
<el-option label="文件上传" value="fileUpload"/> <el-table-column label="请求路径" min-width="10%">
<el-option label="富文本控件" value="editor"/> <template slot-scope="scope">
<el-input v-model="scope.row.requrl"></el-input>
</template>
</el-table-column>
<el-table-column label="许可" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isPermission"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="生成" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isGenerate"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="请求类型" min-width="12%">
<template slot-scope="scope">
<el-select v-model="scope.row.method">
<el-option label="Get" value="Get"/>
<el-option label="Post" value="Post"/>
<el-option label="Put" value="Put"/>
<el-option label="Delete" value="Delete"/>
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="字典类型" min-width="12%"> <el-table-column label="操作" align="center" min-width="5%">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.dictType" clearable filterable placeholder="请选择"> <el-button
<el-option size="mini"
v-for="dict in dictOptions" type="text"
:key="dict.dictType" icon="el-icon-delete"
:label="dict.dictName" @click="handleDelete(scope.$index,scope.row)"
:value="dict.dictType"> >删除
<span style="float: left">{{ dict.dictName }}</span> </el-button>
<span style="float: right; color: #8492a6; font-size: 13px">{{ dict.dictType }}</span>
</el-option>
</el-select>
</template> </template>
</el-table-column> </el-table-column>
</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" :tables="tables" :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">
<el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;"> <el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;">
@ -135,23 +94,48 @@
</template> </template>
<script> <script>
import {getModule} from "@/api/tool/module"; import {queryListApiclass} from "@/api/tool/apiclass";
import ModuleInfoForm from "@/views/tool/module/moduleInfoForm"; import ModuleInfoForm from "@/views/tool/module/moduleInfoForm";
import {listIntertable,updateIntertable} from "@/api/tool/interTable";
export default { export default {
name: "ModuleEdit", name: "ModuleEdit",
components: {ModuleInfoForm}, components: {ModuleInfoForm},
data(){ data(){
return{ return{
info:[], // name
activeName: "cloum",
//
tableHeight: document.documentElement.scrollHeight - 245 + "px",
//
tables: [],
//
cloumns: [],
//
dictOptions: [],
//
apiclassOptions: [],
//
menus: [],
regularOptions: [],
//
info: {}
}; };
}, },
created() { created() {
const moduleId = this.$route.params && this.$route.params.moduleId; const moduleId = this.$route.params && this.$route.params.moduleId;
if (moduleId){ if (moduleId){
getModule(moduleId).then(response => { let data = {
this.info = response.data; mId : moduleId,
}); type : 1,
}
listIntertable(data).then(response => {
this.cloumns = response.data.rows
this.info = response.data.info
})
queryListApiclass().then(res => {
this.apiclassOptions = res.data
console.log(res)
})
} }
}, },
methods:{ methods:{
@ -161,24 +145,35 @@
Promise.all([moduleForm].map(this.getFormPromise)).then(res => { Promise.all([moduleForm].map(this.getFormPromise)).then(res => {
const validateResult = res.every(item => !!item); const validateResult = res.every(item => !!item);
if (validateResult) { if (validateResult) {
// const genTable = Object.assign({}, basicForm.model, genForm.model); const interTableDto = {
// genTable.columns = this.cloumns; module : moduleForm.model,
// genTable.params = { interTables : this.cloumns,
// treeCode: genTable.treeCode, };
// treeName: genTable.treeName, updateIntertable(interTableDto).then(res => {
// treeParentCode: genTable.treeParentCode, this.msgSuccess(res.msg);
// parentMenuId: genTable.parentMenuId if (res.code === 200) {
// }; this.close();
// updateGenTable(genTable).then(res => { }
// this.msgSuccess(res.msg); });
// if (res.code === 200) {
// this.close();
// }
// });
} else { } else {
this.msgError("表单校验未通过,请重新检查提交内容"); this.msgError("表单校验未通过,请重新检查提交内容");
} }
}); });
}, /** 新增按钮 */
handleAdd() {
let row = {
id: null,
cId: null,
mId: this.info.id,
isGenerate: '1',
isPermission: '1',
itDescribe: '',
itName: '',
method: 'Get',
requrl: '',
type: 1,
}
this.cloumns.push(row)
}, },
getFormPromise(form) { getFormPromise(form) {
return new Promise(resolve => { return new Promise(resolve => {

View File

@ -2,12 +2,12 @@
<el-form ref="moduleInfoForm" :model="info" :rules="rules" label-width="150px"> <el-form ref="moduleInfoForm" :model="info" :rules="rules" label-width="150px">
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="模块名称" prop="cName"> <el-form-item label="模块名称" prop="mDescribe">
<el-input placeholder="请输入类名" v-model="info.mDescribe"/> <el-input placeholder="请输入类名" v-model="info.mDescribe"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="模块描述" prop="cName"> <el-form-item label="模块描述" prop="mName">
<el-input placeholder="请输入类名" v-model="info.mName"/> <el-input placeholder="请输入类名" v-model="info.mName"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -33,28 +33,11 @@
return { return {
moduleList:[], moduleList:[],
rules: { rules: {
packageName: [ mName: [
{required: true, message: "包名不能为空", trigger: "blur"}, { required: true, message: "模块名称不能为空}", trigger: "blur" },
], ],
mId: [ mDescribe: [
{required: true, message: "模块不能为空", trigger: "blur"}, { required: true, message: "模块描述不能为空}", trigger: "blur" },
],
cName: [
{required: true, message: "类名不能为空", trigger: "blur"},
],
cDescribe: [
{required: true, message: "类描述不能为空", trigger: "blur"},
],
author: [
{required: true, message: "作者不能为空", trigger: "blur"},
],
email: [
{required: true, message: "电子邮件不能为空", trigger: "blur"},
{
pattern: /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
message: '电子邮件格式有误',
trigger: "blur"
},
], ],
} }
}; };

View File

@ -1,20 +1,22 @@
package com.hchyun.generator.controller; package com.hchyun.generator.controller;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.regex.Pattern; import java.util.Map;
import com.hchyun.common.constant.ReturnConstants; import com.hchyun.common.constant.ReturnConstants;
import com.hchyun.common.core.controller.HcyBaseController; import com.hchyun.common.core.controller.HcyBaseController;
import com.hchyun.common.utils.ServerResult; import com.hchyun.common.utils.ServerResult;
import io.swagger.annotations.Api; import com.hchyun.generator.dto.InterTableDto;
import io.swagger.annotations.ApiImplicitParam; import com.hchyun.generator.entity.Apiclass;
import io.swagger.annotations.ApiOperation; import com.hchyun.generator.service.ApiclassService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
@ -29,7 +31,6 @@ import com.hchyun.common.enums.BusinessType;
import com.hchyun.generator.entity.InterTable; import com.hchyun.generator.entity.InterTable;
import com.hchyun.generator.service.InterTableService; import com.hchyun.generator.service.InterTableService;
import com.hchyun.common.utils.poi.ExcelUtil; import com.hchyun.common.utils.poi.ExcelUtil;
import com.hchyun.common.core.page.TableDataInfo;
/** /**
* 接口信息Controller * 接口信息Controller
@ -37,7 +38,6 @@ import com.hchyun.common.core.page.TableDataInfo;
* @author hchyun * @author hchyun
* @date 2021-01-25 * @date 2021-01-25
*/ */
@Api(value = "接口信息管理",tags = "接口信息管理")
@RestController @RestController
@RequestMapping("/generator/intertable") @RequestMapping("/generator/intertable")
public class InterTableController extends HcyBaseController { public class InterTableController extends HcyBaseController {
@ -45,19 +45,19 @@ public class InterTableController extends HcyBaseController {
@Autowired @Autowired
private InterTableService interTableService; private InterTableService interTableService;
@Autowired
private ApiclassService apiclassService;
/** /**
* 查询接口信息列表 * 查询接口信息列表
*/ */
@ApiOperation("查询接口信息列表")
@PreAuthorize("@ss.hasPermi('generator:intertable:list')") @PreAuthorize("@ss.hasPermi('generator:intertable:list')")
@GetMapping("/list") @GetMapping("/list")
public Serializable list(InterTable interTable) { public Serializable list(InterTable interTable) {
try { try {
startPage(); ServerResult<Map<String, Object>> serverResult = interTableService.selectInterTableList(interTable);
ServerResult<List<InterTable>> serverResult = interTableService.selectInterTableList(interTable);
if (serverResult.isStart()) { if (serverResult.isStart()) {
return getDataTable(serverResult.getData()); return AjaxResult.success(serverResult.getData());
} else { } else {
return AjaxResult.info(serverResult.getMsg()); return AjaxResult.info(serverResult.getMsg());
} }
@ -67,33 +67,30 @@ public class InterTableController extends HcyBaseController {
} }
} }
/** // /**
* 导出接口信息列表 // * 导出接口信息列表
*/ // */
@ApiOperation("导出接口信息列表") // @PreAuthorize("@ss.hasPermi('generator:intertable:export')")
@PreAuthorize("@ss.hasPermi('generator:intertable:export')") // @Log(title = "接口信息", businessType = BusinessType.EXPORT)
@Log(title = "接口信息", businessType = BusinessType.EXPORT) // @GetMapping("/export")
@GetMapping("/export") // public AjaxResult export(InterTable interTable) {
public AjaxResult export(InterTable interTable) { // try {
try { // ServerResult<List<InterTable>> serverResult = interTableService.selectInterTableList(interTable);
ServerResult<List<InterTable>> serverResult = interTableService.selectInterTableList(interTable); // ExcelUtil<InterTable> util = new ExcelUtil<InterTable>(InterTable. class);
ExcelUtil<InterTable> util = new ExcelUtil<InterTable>(InterTable. class); // if (serverResult.isStart()) {
if (serverResult.isStart()) { // return util.exportExcel(serverResult.getData(), "intertable");
return util.exportExcel(serverResult.getData(), "intertable"); // } else {
} else { // return AjaxResult.error(serverResult.getMsg());
return AjaxResult.error(serverResult.getMsg()); // }
} // } catch (RuntimeException e) {
} catch (RuntimeException e) { // logger.error(e.getMessage());
logger.error(e.getMessage()); // return AjaxResult.error(ReturnConstants.SYS_ERROR);
return AjaxResult.error(ReturnConstants.SYS_ERROR); // }
} // }
}
/** /**
* 获取接口信息详细信息 * 获取接口信息详细信息
*/ */
@ApiOperation("获取接口信息详细信息")
@ApiImplicitParam(name = "id" , value = "接口信息id" , required = true, dataType = "Long" , paramType = "path")
@PreAuthorize("@ss.hasPermi('generator:intertable:query')") @PreAuthorize("@ss.hasPermi('generator:intertable:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) { public AjaxResult getInfo(@PathVariable("id") Long id) {
@ -113,8 +110,6 @@ public class InterTableController extends HcyBaseController {
/** /**
* 新增接口信息 * 新增接口信息
*/ */
@ApiOperation("新增接口信息")
@ApiImplicitParam(name = "interTable" , value = "新增接口信息信息" , dataType = "InterTable")
@PreAuthorize("@ss.hasPermi('generator:intertable:add')") @PreAuthorize("@ss.hasPermi('generator:intertable:add')")
@Log(title = "接口信息", businessType = BusinessType.INSERT) @Log(title = "接口信息", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
@ -135,15 +130,12 @@ public class InterTableController extends HcyBaseController {
/** /**
* 修改接口信息 * 修改接口信息
*/ */
@ApiOperation("修改接口信息")
@ApiImplicitParam(name = "interTable" , value = "修改接口信息信息" , dataType = "InterTable")
@PreAuthorize("@ss.hasPermi('generator:intertable:edit')") @PreAuthorize("@ss.hasPermi('generator:intertable:edit')")
@Log(title = "接口信息", businessType = BusinessType.UPDATE) @Log(title = "接口信息", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody InterTable interTable) { public AjaxResult edit(@Validated @RequestBody InterTableDto interTableDto) {
try { try {
ServerResult<Integer> serverResult = interTableService.updateInterTable(interTableDto);
ServerResult<Integer> serverResult = interTableService.updateInterTable(interTable);
if (serverResult.isStart()) { if (serverResult.isStart()) {
return AjaxResult.success(); return AjaxResult.success();
} else { } else {
@ -158,8 +150,6 @@ public class InterTableController extends HcyBaseController {
/** /**
* 删除接口信息 * 删除接口信息
*/ */
@ApiOperation("删除接口信息")
@ApiImplicitParam(name = "ids" , value = "接口信息ids" , required = true, dataType = "Long" , paramType = "path")
@PreAuthorize("@ss.hasPermi('generator:intertable:remove')") @PreAuthorize("@ss.hasPermi('generator:intertable:remove')")
@Log(title = "接口信息", businessType = BusinessType.DELETE) @Log(title = "接口信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")

View File

@ -35,6 +35,28 @@ public interface InterTableDao
*/ */
int insertInterTable(InterTable interTable); int insertInterTable(InterTable interTable);
/**
* 批量新增接口信息
*
* @param interTables
* @return
*/
int insertInterTables(List<InterTable> interTables);
/**
* 通过类id删除接口
* @param cId
* @return
*/
int deleteInterTableByClassId(Long cId);
/**
* 通过模块id删除接口
* @param mId
* @return
*/
int deleteInterTableByModuleId(Long mId);
/** /**
* 修改接口信息 * 修改接口信息
* *
@ -43,6 +65,8 @@ public interface InterTableDao
*/ */
int updateInterTable(InterTable interTable); int updateInterTable(InterTable interTable);
/** /**
* 删除接口信息 * 删除接口信息
* *

View File

@ -0,0 +1,40 @@
package com.hchyun.generator.dto;
import com.hchyun.generator.entity.Apiclass;
import com.hchyun.generator.entity.InterTable;
import com.hchyun.generator.entity.Module;
import java.util.List;
public class InterTableDto {
private Apiclass apiclass;
private Module module;
private List<InterTable> interTables;
public Module getModule() {
return module;
}
public void setModule(Module module) {
this.module = module;
}
public Apiclass getApiclass() {
return apiclass;
}
public void setApiclass(Apiclass apiclass) {
this.apiclass = apiclass;
}
public List<InterTable> getInterTables() {
return interTables;
}
public void setInterTables(List<InterTable> interTables) {
this.interTables = interTables;
}
}

View File

@ -3,7 +3,6 @@ package com.hchyun.generator.entity;
import com.hchyun.common.annotation.Excel; import com.hchyun.common.annotation.Excel;
import com.hchyun.common.core.entity.BaseEntity; import com.hchyun.common.core.entity.BaseEntity;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
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;
@ -14,120 +13,144 @@ import org.apache.commons.lang3.builder.ToStringStyle;
* @date 2021-01-25 * @date 2021-01-25
*/ */
@ApiModel("接口信息") @ApiModel("接口信息")
public class InterTable extends BaseEntity public class InterTable extends BaseEntity {
{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** id */ /**
@ApiModelProperty("id") * id
*/
private Long id; private Long id;
/** 模块id */ /**
* 模块id
*/
@Excel(name = "模块id") @Excel(name = "模块id")
@ApiModelProperty("模块id")
private Long mId; private Long mId;
/** 类id */ /**
* 类id
*/
@Excel(name = "类id") @Excel(name = "类id")
@ApiModelProperty("类id")
private Long cId; private Long cId;
/** 描述 */ /**
* 接口名称
*/
@Excel(name = "接口名称")
private String itName;
/**
* 描述
*/
@Excel(name = "描述") @Excel(name = "描述")
@ApiModelProperty("描述")
private String itDescribe; private String itDescribe;
/** 是否设置许可 */ /**
* 是否设置许可
*/
@Excel(name = "是否设置许可") @Excel(name = "是否设置许可")
@ApiModelProperty("是否设置许可") private String isPermission;
private Integer isPermission;
/** 请求路径 */ /**
* 请求路径
*/
@Excel(name = "请求路径") @Excel(name = "请求路径")
@ApiModelProperty("请求路径")
private String requrl; private String requrl;
/** 请求方式 */ /**
* 请求方式
*/
@Excel(name = "请求方式") @Excel(name = "请求方式")
@ApiModelProperty("请求方式")
private String method; private String method;
/** 是否生成 */ /**
* 是否生成
*/
@Excel(name = "是否生成") @Excel(name = "是否生成")
@ApiModelProperty("是否生成") private String isGenerate;
private Integer isGenerate; /**
* 类型
*/
private Integer type;
public void setId(Long id) public Integer getType() {
{ return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getItName() {
return itName;
}
public void setItName(String itName) {
this.itName = itName;
}
public void setId(Long id) {
this.id = id; this.id = id;
} }
public Long getId() public Long getId() {
{
return id; return id;
} }
public void setmId(Long mId)
{ public void setmId(Long mId) {
this.mId = mId; this.mId = mId;
} }
public Long getmId() public Long getmId() {
{
return mId; return mId;
} }
public void setcId(Long cId)
{ public void setcId(Long cId) {
this.cId = cId; this.cId = cId;
} }
public Long getcId() public Long getcId() {
{
return cId; return cId;
} }
public void setItDescribe(String itDescribe)
{ public void setItDescribe(String itDescribe) {
this.itDescribe = itDescribe; this.itDescribe = itDescribe;
} }
public String getItDescribe() public String getItDescribe() {
{
return itDescribe; return itDescribe;
} }
public void setIsPermission(Integer isPermission)
{
this.isPermission = isPermission;
}
public Integer getIsPermission() public void setRequrl(String requrl) {
{
return isPermission;
}
public void setRequrl(String requrl)
{
this.requrl = requrl; this.requrl = requrl;
} }
public String getRequrl() public String getRequrl() {
{
return requrl; return requrl;
} }
public void setMethod(String method)
{ public void setMethod(String method) {
this.method = method; this.method = method;
} }
public String getMethod() public String getIsPermission() {
{ return isPermission;
return method;
} }
public void setIsGenerate(Integer isGenerate)
{ public void setIsPermission(String isPermission) {
this.isPermission = isPermission;
}
public String getIsGenerate() {
return isGenerate;
}
public void setIsGenerate(String isGenerate) {
this.isGenerate = isGenerate; this.isGenerate = isGenerate;
} }
public Integer getIsGenerate() public String getMethod() {
{ return method;
return isGenerate;
} }
@Override @Override
@ -137,10 +160,8 @@ public class InterTable extends BaseEntity
.append("mId", getmId()) .append("mId", getmId())
.append("cId", getcId()) .append("cId", getcId())
.append("itDescribe", getItDescribe()) .append("itDescribe", getItDescribe())
.append("isPermission", getIsPermission())
.append("requrl", getRequrl()) .append("requrl", getRequrl())
.append("method", getMethod()) .append("method", getMethod())
.append("isGenerate", getIsGenerate())
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("createBy", getCreateBy()) .append("createBy", getCreateBy())
.append("updateTime", getUpdateTime()) .append("updateTime", getUpdateTime())

View File

@ -1,8 +1,10 @@
package com.hchyun.generator.service; package com.hchyun.generator.service;
import java.util.List; import java.util.List;
import java.util.Map;
import com.hchyun.common.utils.ServerResult; import com.hchyun.common.utils.ServerResult;
import com.hchyun.generator.dto.InterTableDto;
import com.hchyun.generator.entity.InterTable; import com.hchyun.generator.entity.InterTable;
/** /**
@ -27,7 +29,7 @@ public interface InterTableService
* @param interTable 接口信息 * @param interTable 接口信息
* @return 接口信息集合 * @return 接口信息集合
*/ */
ServerResult<List<InterTable>> selectInterTableList(InterTable interTable); ServerResult<Map<String,Object>> selectInterTableList(InterTable interTable);
/** /**
* 新增接口信息 * 新增接口信息
@ -40,10 +42,10 @@ public interface InterTableService
/** /**
* 修改接口信息 * 修改接口信息
* *
* @param interTable 接口信息 * @param interTableDto 接口信息
* @return 结果 * @return 结果
*/ */
ServerResult<Integer> updateInterTable(InterTable interTable); ServerResult<Integer> updateInterTable(InterTableDto interTableDto);
/** /**
* 批量删除接口信息 * 批量删除接口信息

View File

@ -1,10 +1,17 @@
package com.hchyun.generator.service.impl; package com.hchyun.generator.service.impl;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import com.hchyun.common.constant.ReturnConstants; import com.hchyun.common.constant.ReturnConstants;
import com.hchyun.common.utils.SecurityUtils; import com.hchyun.common.utils.SecurityUtils;
import com.hchyun.common.utils.ServerResult; import com.hchyun.common.utils.ServerResult;
import com.hchyun.generator.dao.ApiclassDao;
import com.hchyun.generator.dao.ModuleDao;
import com.hchyun.generator.dto.InterTableDto;
import com.hchyun.generator.entity.Apiclass;
import com.hchyun.generator.entity.Module;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -12,6 +19,7 @@ import org.springframework.stereotype.Service;
import com.hchyun.generator.dao.InterTableDao; import com.hchyun.generator.dao.InterTableDao;
import com.hchyun.generator.entity.InterTable; import com.hchyun.generator.entity.InterTable;
import com.hchyun.generator.service.InterTableService; import com.hchyun.generator.service.InterTableService;
import org.springframework.transaction.annotation.Transactional;
/** /**
* 接口信息Service业务层处理 * 接口信息Service业务层处理
@ -25,6 +33,10 @@ public class InterTableServiceImpl implements InterTableService {
@Autowired @Autowired
private InterTableDao interTableDao; private InterTableDao interTableDao;
@Autowired
private ApiclassDao apiclassDao;
@Autowired
private ModuleDao moduleDao;
/** /**
* 查询接口信息 * 查询接口信息
@ -54,17 +66,22 @@ public class InterTableServiceImpl implements InterTableService {
* @return 接口信息 * @return 接口信息
*/ */
@Override @Override
public ServerResult<List<InterTable>> selectInterTableList(InterTable interTable) { public ServerResult<Map<String, Object>> selectInterTableList(InterTable interTable) {
try { try {
List<InterTable> interTableList = interTableDao.selectInterTableList(interTable); Map<String,Object> modeMap = new HashMap<String, Object>();
if (interTableList.size()>0){ if (interTable.getType()==1){
return new ServerResult<List<InterTable>>(true,interTableList); Module module = moduleDao.selectModuleById(interTable.getmId());
}else { modeMap.put("info",module);
return new ServerResult<List<InterTable>>(false,ReturnConstants.RESULT_EMPTY); }else if (interTable.getType() == 2){
Apiclass apiclass = apiclassDao.selectApiclassById(interTable.getcId());
modeMap.put("info",apiclass);
} }
List<InterTable> interTableList = interTableDao.selectInterTableList(interTable);
modeMap.put("rows",interTableList);
return new ServerResult<Map<String, Object>>(true, modeMap);
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
return new ServerResult<List<InterTable>>(false,ReturnConstants.DB_EX); return new ServerResult<Map<String, Object>>(false, ReturnConstants.DB_EX);
} }
} }
@ -93,16 +110,30 @@ public class InterTableServiceImpl implements InterTableService {
/** /**
* 修改接口信息 * 修改接口信息
* *
* @param interTable 接口信息 * @param interTableDto 接口信息
* @return 结果 * @return 结果
*/ */
@Override @Override
public ServerResult<Integer> updateInterTable(InterTable interTable) { @Transactional
public ServerResult<Integer> updateInterTable(InterTableDto interTableDto) {
try { try {
interTable.setUpdateBy(SecurityUtils.getUserId()); List<InterTable> interTables = interTableDto.getInterTables();
Integer renewal = interTableDao.updateInterTable(interTable); Integer renewal = 0;
if (renewal >0){ if (interTableDto.getModule() == null){
return new ServerResult<Integer>(true,renewal); Apiclass apiclass = interTableDto.getApiclass();
renewal = apiclassDao.updateApiclass(apiclass);
interTableDao.deleteInterTableByClassId(apiclass.getId());
}else if (interTableDto.getApiclass() == null){
Module module = interTableDto.getModule();
renewal = moduleDao.updateModule(module);
interTableDao.deleteInterTableByModuleId(module.getId());
}
for (int i=0;i<interTables.size();i++){
interTables.get(i).setCreateBy(SecurityUtils.getUserId());
}
Integer renewalTables = interTableDao.insertInterTables(interTables);
if (renewalTables > 0&& renewal>0) {
return new ServerResult<Integer>(true, renewalTables);
} else { } else {
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL); return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
} }

View File

@ -0,0 +1,14 @@
package com.hchyun.generator.util;
import com.hchyun.generator.dto.InterTableDto;
import com.hchyun.generator.entity.GenTable;
import org.apache.velocity.VelocityContext;
public class InterApiUtils {
public static VelocityContext prepareContext(InterTableDto interTableDto) {
return new VelocityContext();
}
}

View File

@ -18,15 +18,20 @@ import com.hchyun.generator.entity.GenTableColumn;
* *
* @author hchyun * @author hchyun
*/ */
public class VelocityUtils public class VelocityUtils {
{ /**
/** 项目空间路径 */ * 项目空间路径
*/
private static final String PROJECT_PATH = "main/java"; private static final String PROJECT_PATH = "main/java";
/** mybatis空间路径 */ /**
* mybatis空间路径
*/
private static final String MYBATIS_PATH = "main/resources/mapper"; private static final String MYBATIS_PATH = "main/resources/mapper";
/** 默认上级菜单,系统工具 */ /**
* 默认上级菜单系统工具
*/
private static final String DEFAULT_PARENT_MENU_ID = "3"; private static final String DEFAULT_PARENT_MENU_ID = "3";
/** /**
@ -34,8 +39,7 @@ public class VelocityUtils
* *
* @return 模板列表 * @return 模板列表
*/ */
public static VelocityContext prepareContext(GenTable genTable) public static VelocityContext prepareContext(GenTable genTable) {
{
String moduleName = genTable.getModuleName(); String moduleName = genTable.getModuleName();
String businessName = genTable.getBusinessName(); String businessName = genTable.getBusinessName();
String packageName = genTable.getPackageName(); String packageName = genTable.getPackageName();
@ -63,27 +67,23 @@ public class VelocityUtils
velocityContext.put("columns", genTable.getColumns()); velocityContext.put("columns", genTable.getColumns());
velocityContext.put("table", genTable); velocityContext.put("table", genTable);
setMenuVelocityContext(velocityContext, genTable); setMenuVelocityContext(velocityContext, genTable);
if (GenConstants.TPL_TREE.equals(tplCategory)) if (GenConstants.TPL_TREE.equals(tplCategory)) {
{
setTreeVelocityContext(velocityContext, genTable); setTreeVelocityContext(velocityContext, genTable);
} }
if (GenConstants.TPL_SUB.equals(tplCategory)) if (GenConstants.TPL_SUB.equals(tplCategory)) {
{
setSubVelocityContext(velocityContext, genTable); setSubVelocityContext(velocityContext, genTable);
} }
return velocityContext; return velocityContext;
} }
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) {
{
String options = genTable.getOptions(); String options = genTable.getOptions();
JSONObject paramsObj = JSONObject.parseObject(options); JSONObject paramsObj = JSONObject.parseObject(options);
String parentMenuId = getParentMenuId(paramsObj); String parentMenuId = getParentMenuId(paramsObj);
context.put("parentMenuId", parentMenuId); context.put("parentMenuId", parentMenuId);
} }
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) {
{
String options = genTable.getOptions(); String options = genTable.getOptions();
JSONObject paramsObj = JSONObject.parseObject(options); JSONObject paramsObj = JSONObject.parseObject(options);
String treeCode = getTreecode(paramsObj); String treeCode = getTreecode(paramsObj);
@ -94,18 +94,15 @@ public class VelocityUtils
context.put("treeParentCode", treeParentCode); context.put("treeParentCode", treeParentCode);
context.put("treeName", treeName); context.put("treeName", treeName);
context.put("expandColumn", getExpandColumn(genTable)); context.put("expandColumn", getExpandColumn(genTable));
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
{
context.put("tree_parent_code", paramsObj.getString(GenConstants.TREE_PARENT_CODE)); context.put("tree_parent_code", paramsObj.getString(GenConstants.TREE_PARENT_CODE));
} }
if (paramsObj.containsKey(GenConstants.TREE_NAME)) if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
{
context.put("tree_name", paramsObj.getString(GenConstants.TREE_NAME)); context.put("tree_name", paramsObj.getString(GenConstants.TREE_NAME));
} }
} }
public static void setSubVelocityContext(VelocityContext context, GenTable genTable) public static void setSubVelocityContext(VelocityContext context, GenTable genTable) {
{
GenTable subTable = genTable.getSubTable(); GenTable subTable = genTable.getSubTable();
String subTableName = genTable.getSubTableName(); String subTableName = genTable.getSubTableName();
String subTableFkName = genTable.getSubTableFkName(); String subTableFkName = genTable.getSubTableFkName();
@ -127,8 +124,7 @@ public class VelocityUtils
* *
* @return 模板列表 * @return 模板列表
*/ */
public static List<String> getTemplateList(String tplCategory) public static List<String> getTemplateList(String tplCategory) {
{
List<String> templates = new ArrayList<String>(); List<String> templates = new ArrayList<String>();
templates.add("vm/java/entity.java.vm"); templates.add("vm/java/entity.java.vm");
templates.add("vm/java/dao.java.vm"); templates.add("vm/java/dao.java.vm");
@ -138,16 +134,11 @@ public class VelocityUtils
templates.add("vm/xml/mapper.xml.vm"); templates.add("vm/xml/mapper.xml.vm");
templates.add("vm/sql/sql.vm"); templates.add("vm/sql/sql.vm");
templates.add("vm/js/api.js.vm"); templates.add("vm/js/api.js.vm");
if (GenConstants.TPL_CRUD.equals(tplCategory)) if (GenConstants.TPL_CRUD.equals(tplCategory)) {
{
templates.add("vm/vue/index.vue.vm"); templates.add("vm/vue/index.vue.vm");
} } else if (GenConstants.TPL_TREE.equals(tplCategory)) {
else if (GenConstants.TPL_TREE.equals(tplCategory))
{
templates.add("vm/vue/index-tree.vue.vm"); templates.add("vm/vue/index-tree.vue.vm");
} } else if (GenConstants.TPL_SUB.equals(tplCategory)) {
else if (GenConstants.TPL_SUB.equals(tplCategory))
{
templates.add("vm/vue/index.vue.vm"); templates.add("vm/vue/index.vue.vm");
templates.add("vm/java/sub-entity.java.vm"); templates.add("vm/java/sub-entity.java.vm");
} }
@ -157,8 +148,7 @@ public class VelocityUtils
/** /**
* 获取文件名 * 获取文件名
*/ */
public static String getFileName(String template, GenTable genTable) public static String getFileName(String template, GenTable genTable) {
{
// 文件名称 // 文件名称
String fileName = ""; String fileName = "";
// 包路径 // 包路径
@ -174,48 +164,28 @@ public class VelocityUtils
String mybatisPath = MYBATIS_PATH + "/" + moduleName; String mybatisPath = MYBATIS_PATH + "/" + moduleName;
String vuePath = "vue"; String vuePath = "vue";
if (template.contains("entity.java.vm")) if (template.contains("entity.java.vm")) {
{
fileName = StringUtils.format("{}/entity/{}.java", javaPath, className); fileName = StringUtils.format("{}/entity/{}.java", javaPath, className);
} }
if (template.contains("sub-entity.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) if (template.contains("sub-entity.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) {
{
fileName = StringUtils.format("{}/entity/{}.java", javaPath, genTable.getSubTable().getClassName()); fileName = StringUtils.format("{}/entity/{}.java", javaPath, genTable.getSubTable().getClassName());
} } else if (template.contains("dao.java.vm")) {
else if (template.contains("dao.java.vm"))
{
fileName = StringUtils.format("{}/dao/{}Dao.java", javaPath, className); fileName = StringUtils.format("{}/dao/{}Dao.java", javaPath, className);
} } else if (template.contains("service.java.vm")) {
else if (template.contains("service.java.vm"))
{
fileName = StringUtils.format("{}/service/{}Service.java", javaPath, className); fileName = StringUtils.format("{}/service/{}Service.java", javaPath, className);
} } else if (template.contains("serviceImpl.java.vm")) {
else if (template.contains("serviceImpl.java.vm"))
{
fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className); fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
} } else if (template.contains("controller.java.vm")) {
else if (template.contains("controller.java.vm"))
{
fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className); fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
} } else if (template.contains("mapper.xml.vm")) {
else if (template.contains("mapper.xml.vm"))
{
fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className); fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
} } else if (template.contains("sql.vm")) {
else if (template.contains("sql.vm"))
{
fileName = businessName + "Menu.sql"; fileName = businessName + "Menu.sql";
} } else if (template.contains("api.js.vm")) {
else if (template.contains("api.js.vm"))
{
fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName); fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
} } else if (template.contains("index.vue.vm")) {
else if (template.contains("index.vue.vm"))
{
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName); fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
} } else if (template.contains("index-tree.vue.vm")) {
else if (template.contains("index-tree.vue.vm"))
{
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName); fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
} }
return fileName; return fileName;
@ -227,8 +197,7 @@ public class VelocityUtils
* @param packageName 包名称 * @param packageName 包名称
* @return 包前缀名称 * @return 包前缀名称
*/ */
public static String getPackagePrefix(String packageName) public static String getPackagePrefix(String packageName) {
{
int lastIndex = packageName.lastIndexOf("."); int lastIndex = packageName.lastIndexOf(".");
String basePackage = StringUtils.substring(packageName, 0, lastIndex); String basePackage = StringUtils.substring(packageName, 0, lastIndex);
return basePackage; return basePackage;
@ -240,24 +209,18 @@ public class VelocityUtils
* @param genTable 业务表对象 * @param genTable 业务表对象
* @return 返回需要导入的包列表 * @return 返回需要导入的包列表
*/ */
public static HashSet<String> getImportList(GenTable genTable) public static HashSet<String> getImportList(GenTable genTable) {
{
List<GenTableColumn> columns = genTable.getColumns(); List<GenTableColumn> columns = genTable.getColumns();
GenTable subGenTable = genTable.getSubTable(); GenTable subGenTable = genTable.getSubTable();
HashSet<String> importList = new HashSet<String>(); HashSet<String> importList = new HashSet<String>();
if (StringUtils.isNotNull(subGenTable)) if (StringUtils.isNotNull(subGenTable)) {
{
importList.add("java.util.List"); 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()))
{
importList.add("java.util.Date"); importList.add("java.util.Date");
importList.add("com.fasterxml.jackson.annotation.JsonFormat"); importList.add("com.fasterxml.jackson.annotation.JsonFormat");
} } else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType())) {
else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType()))
{
importList.add("java.math.BigDecimal"); importList.add("java.math.BigDecimal");
} }
} }
@ -271,8 +234,7 @@ public class VelocityUtils
* @param businessName 业务名称 * @param businessName 业务名称
* @return 返回权限前缀 * @return 返回权限前缀
*/ */
public static String getPermissionPrefix(String moduleName, String businessName) public static String getPermissionPrefix(String moduleName, String businessName) {
{
return StringUtils.format("{}:{}", moduleName, businessName); return StringUtils.format("{}:{}", moduleName, businessName);
} }
@ -282,10 +244,8 @@ public class VelocityUtils
* @param paramsObj 生成其他选项 * @param paramsObj 生成其他选项
* @return 上级菜单ID字段 * @return 上级菜单ID字段
*/ */
public static String getParentMenuId(JSONObject paramsObj) public static String getParentMenuId(JSONObject paramsObj) {
{ if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)) {
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID))
{
return paramsObj.getString(GenConstants.PARENT_MENU_ID); return paramsObj.getString(GenConstants.PARENT_MENU_ID);
} }
return DEFAULT_PARENT_MENU_ID; return DEFAULT_PARENT_MENU_ID;
@ -297,10 +257,8 @@ public class VelocityUtils
* @param paramsObj 生成其他选项 * @param paramsObj 生成其他选项
* @return 树编码 * @return 树编码
*/ */
public static String getTreecode(JSONObject paramsObj) public static String getTreecode(JSONObject paramsObj) {
{ if (paramsObj.containsKey(GenConstants.TREE_CODE)) {
if (paramsObj.containsKey(GenConstants.TREE_CODE))
{
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE)); return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
} }
return StringUtils.EMPTY; return StringUtils.EMPTY;
@ -312,10 +270,8 @@ public class VelocityUtils
* @param paramsObj 生成其他选项 * @param paramsObj 生成其他选项
* @return 树父编码 * @return 树父编码
*/ */
public static String getTreeParentCode(JSONObject paramsObj) public static String getTreeParentCode(JSONObject paramsObj) {
{ if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE))
{
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE)); return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
} }
return StringUtils.EMPTY; return StringUtils.EMPTY;
@ -327,10 +283,8 @@ public class VelocityUtils
* @param paramsObj 生成其他选项 * @param paramsObj 生成其他选项
* @return 树名称 * @return 树名称
*/ */
public static String getTreeName(JSONObject paramsObj) public static String getTreeName(JSONObject paramsObj) {
{ if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
if (paramsObj.containsKey(GenConstants.TREE_NAME))
{
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME)); return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
} }
return StringUtils.EMPTY; return StringUtils.EMPTY;
@ -342,20 +296,16 @@ public class VelocityUtils
* @param genTable 业务表对象 * @param genTable 业务表对象
* @return 展开按钮列序号 * @return 展开按钮列序号
*/ */
public static int getExpandColumn(GenTable genTable) public static int getExpandColumn(GenTable genTable) {
{
String options = genTable.getOptions(); String options = genTable.getOptions();
JSONObject paramsObj = JSONObject.parseObject(options); JSONObject paramsObj = JSONObject.parseObject(options);
String treeName = paramsObj.getString(GenConstants.TREE_NAME); String treeName = paramsObj.getString(GenConstants.TREE_NAME);
int num = 0; int num = 0;
for (GenTableColumn column : genTable.getColumns()) for (GenTableColumn column : genTable.getColumns()) {
{ if (column.isList()) {
if (column.isList())
{
num++; num++;
String columnName = column.getColumnName(); String columnName = column.getColumnName();
if (columnName.equals(treeName)) if (columnName.equals(treeName)) {
{
break; break;
} }
} }

View File

@ -4,33 +4,65 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hchyun.generator.dao.InterTableDao"> <mapper namespace="com.hchyun.generator.dao.InterTableDao">
<resultMap type="InterTable" id="InterTableResult"> <resultMap type="com.hchyun.generator.entity.InterTable" id="InterTableResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="mId" column="m_id" /> <result property="mId" column="m_id" />
<result property="cId" column="c_id" /> <result property="cId" column="c_id" />
<result property="itName" column="it_name" />
<result property="itDescribe" column="it_describe" /> <result property="itDescribe" column="it_describe" />
<result property="isPermission" column="is_permission" /> <result property="isPermission" column="is_permission" />
<result property="requrl" column="requrl" /> <result property="requrl" column="requrl" />
<result property="method" column="method" /> <result property="method" column="method" />
<result property="type" column="type" />
<result property="isGenerate" column="is_generate" /> <result property="isGenerate" column="is_generate" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
</resultMap>
<resultMap id="InterTableDtoResult" type="com.hchyun.generator.dto.InterTableDto">
<collection property="module" notNullColumn="id" javaType="com.hchyun.generator.entity.Module" resultMap="ModuleResult" />
<collection property="apiclass" notNullColumn="id" javaType="com.hchyun.generator.entity.Apiclass" resultMap="ApiclassResult"/>
<collection property="interTables" notNullColumn="id" javaType="java.util.List" resultMap="InterTableResult" />
</resultMap>
<resultMap type="com.hchyun.generator.entity.Module" id="ModuleResult">
<result property="id" column="id" />
<result property="mName" column="m_name" />
<result property="mDescribe" column="m_describe" />
</resultMap>
<resultMap type="com.hchyun.generator.entity.Apiclass" id="ApiclassResult">
<result property="id" column="id" />
<result property="mId" column="m_id" />
<result property="cName" column="c_name" />
<result property="cDescribe" column="c_describe" />
<result property="packageName" column="package_name" />
<result property="author" column="author" />
<result property="email" column="email" />
<result property="remark" column="remark" />
<result property="prefix" column="prefix" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
</resultMap> </resultMap>
<sql id="selectInterTableVo"> <sql id="selectInterTableVo">
select id, m_id, c_id, it_describe, is_permission, requrl, method, is_generate, create_time, create_by, update_time, update_by from sys_inter_table select id, m_id, c_id, it_name, it_describe, is_permission, requrl, method, is_generate, type, create_time, create_by from sys_inter_table
</sql> </sql>
<select id="selectInterTableDtoList" parameterType="com.hchyun.generator.dto.InterTableDto" resultMap="InterTableDtoResult">
select *
from sys_module m
left join sys_apiclass a on
</select>
<select id="selectInterTableList" parameterType="InterTable" resultMap="InterTableResult"> <select id="selectInterTableList" parameterType="InterTable" resultMap="InterTableResult">
<include refid="selectInterTableVo"/> <include refid="selectInterTableVo"/>
<where> <where>
<if test="mId != null "> and m_id = #{mId}</if> <if test="mId != null "> and m_id = #{mId}</if>
<if test="cId != null "> and c_id = #{cId}</if> <if test="cId != null "> and c_id = #{cId}</if>
<if test="itDescribe != null and itDescribe != ''"> and it_describe = #{itDescribe}</if> <if test="itName != null and itName != ''"> and it_name like concat('%', #{itName}, '%')</if>
<if test="itDescribe != null and itDescribe != ''"> and it_describe like concat('%', #{itDescribe}, '%')</if>
<if test="isPermission != null "> and is_permission = #{isPermission}</if> <if test="isPermission != null "> and is_permission = #{isPermission}</if>
<if test="requrl != null and requrl != ''"> and requrl = #{requrl}</if> <if test="type != null "> and type = #{type}</if>
<if test="requrl != null and requrl != ''"> and requrl like concat('%', #{requrl}, '%')</if>
<if test="method != null and method != ''"> and method = #{method}</if> <if test="method != null and method != ''"> and method = #{method}</if>
<if test="isGenerate != null "> and is_generate = #{isGenerate}</if> <if test="isGenerate != null "> and is_generate = #{isGenerate}</if>
</where> </where>
@ -41,29 +73,44 @@
where id = #{id} where id = #{id}
</select> </select>
<insert id="insertInterTables" parameterType="java.util.List">
insert into sys_inter_table (m_id, c_id, it_name, it_describe, is_permission, requrl, method, is_generate, type, create_by) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.mId},#{item.cId},#{item.itName},#{item.itDescribe},#{item.isPermission},#{item.requrl},#{item.method},#{item.isGenerate},#{item.type},#{item.createBy})
</foreach>
</insert>
<delete id="deleteInterTableByClassId" parameterType="Long">
delete from sys_inter_table where c_id = #{cId}
</delete>
<delete id="deleteInterTableByModuleId" parameterType="Long">
delete from sys_inter_table where c_id = #{cId}
</delete>
<insert id="insertInterTable" parameterType="InterTable" useGeneratedKeys="true" keyProperty="id"> <insert id="insertInterTable" parameterType="InterTable" useGeneratedKeys="true" keyProperty="id">
insert into sys_inter_table insert into sys_inter_table
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="mId != null">m_id,</if> <if test="mId != null">m_id,</if>
<if test="cId != null">c_id,</if> <if test="cId != null">c_id,</if>
<if test="itName != null">it_name,</if>
<if test="itDescribe != null">it_describe,</if> <if test="itDescribe != null">it_describe,</if>
<if test="isPermission != null">is_permission,</if> <if test="isPermission != null">is_permission,</if>
<if test="requrl != null">requrl,</if> <if test="requrl != null">requrl,</if>
<if test="method != null">method,</if> <if test="method != null">method,</if>
<if test="type != null">type,</if>
<if test="isGenerate != null">is_generate,</if> <if test="isGenerate != null">is_generate,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="mId != null">#{mId},</if> <if test="mId != null">#{mId},</if>
<if test="cId != null">#{cId},</if> <if test="cId != null">#{cId},</if>
<if test="itName != null">#{itName},</if>
<if test="itDescribe != null">#{itDescribe},</if> <if test="itDescribe != null">#{itDescribe},</if>
<if test="isPermission != null">#{isPermission},</if> <if test="isPermission != null">#{isPermission},</if>
<if test="requrl != null">#{requrl},</if> <if test="requrl != null">#{requrl},</if>
<if test="method != null">#{method},</if> <if test="method != null">#{method},</if>
<if test="type != null">#{type},</if>
<if test="isGenerate != null">#{isGenerate},</if> <if test="isGenerate != null">#{isGenerate},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim> </trim>
</insert> </insert>
@ -72,13 +119,14 @@
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="mId != null">m_id = #{mId},</if> <if test="mId != null">m_id = #{mId},</if>
<if test="cId != null">c_id = #{cId},</if> <if test="cId != null">c_id = #{cId},</if>
<if test="itName != null">it_name = #{itName},</if>
<if test="itDescribe != null">it_describe = #{itDescribe},</if> <if test="itDescribe != null">it_describe = #{itDescribe},</if>
<if test="isPermission != null">is_permission = #{isPermission},</if> <if test="isPermission != null">is_permission = #{isPermission},</if>
<if test="requrl != null">requrl = #{requrl},</if> <if test="requrl != null">requrl = #{requrl},</if>
<if test="method != null">method = #{method},</if> <if test="method != null">method = #{method},</if>
<if test="type != null">type = #{type},</if>
<if test="isGenerate != null">is_generate = #{isGenerate},</if> <if test="isGenerate != null">is_generate = #{isGenerate},</if>
<if test="createBy != null">create_by = #{createBy},</if> <if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>