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() {
return request({
url: '/tool/module/querylist',
url: '/tool/apiclass/querylist',
method: 'get',
})
}
// 查询接口类名详细
export function getApiclass(id) {
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) {
return request({

View File

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

View File

@ -4,126 +4,73 @@
<el-tab-pane label="基本信息" name="basic">
<apiclass-info-form ref="apiclassInfo" :info="info"/>
</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-column label="序号" type="index" min-width="5%" class-name="allowDrag"/>
<el-table-column
label="字段列名"
prop="columnName"
min-width="10%"
:show-overflow-tooltip="true"
/>
<el-table-column label="字段描述" min-width="10%">
<template slot-scope="scope">
<el-input v-model="scope.row.columnComment"></el-input>
<el-table-column label="接口名称" min-width="10%">
<template slot-scope="scope" >
<el-input v-model="scope.row.itName"></el-input>
</template>
</el-table-column>
<el-table-column
label="物理类型"
prop="columnType"
min-width="10%"
:show-overflow-tooltip="true"
/>
<el-table-column label="Java类型" min-width="11%">
<el-table-column label="接口描述" min-width="10%">
<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-input v-model="scope.row.itDescribe"></el-input>
</template>
</el-table-column>
<el-table-column label="请求路径" min-width="10%">
<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>
</template>
</el-table-column>
<el-table-column label="java属性" min-width="10%">
<el-table-column label="操作" align="center" min-width="5%">
<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"/>
</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>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.$index,scope.row)"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="生成信息" name="genInfo">
<gen-info-form ref="genInfo" :info="info" :tables="tables" :menus="menus"/>
</el-tab-pane>
<!-- <el-tab-pane label="生成信息" name="genInfo">-->
<!-- <gen-info-form ref="genInfo" :info="info" :tables="tables" :menus="menus"/>-->
<!-- </el-tab-pane>-->
</el-tabs>
<el-form label-width="100px">
<el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;">
@ -135,70 +82,125 @@
</template>
<script>
import ApiclassInfoForm from "./apiclassInfoForm";
import {getApiclass} from "@/api/tool/apiclass";
export default {
name: "ApiclassEdit",
components: {ApiclassInfoForm}
,
data(){
return{
info:[],
import ApiclassInfoForm from "./apiclassInfoForm";
import {listIntertable,updateIntertable} from "@/api/tool/interTable";
import {Message} from "element-ui";
};
},
created() {
const apiclassId = this.$route.params && this.$route.params.apiclassId;
if (apiclassId){
getApiclass(apiclassId).then(response => {
this.info = response.data;
});
export default {
name: "ApiclassEdit",
components: {ApiclassInfoForm},
data() {
return {
// name
activeName: "cloum",
//
tableHeight: document.documentElement.scrollHeight - 245 + "px",
//
tables: [],
//
cloumns: [],
//
dictOptions: [],
//
menus: [],
regularOptions: [],
//
info: {}
};
},
created() {
const apiclassId = this.$route.params && this.$route.params.apiclassId;
if (apiclassId) {
let data = {
cId: apiclassId,
type: 2,
}
console.log(apiclassId)
listIntertable(data).then(response => {
this.cloumns = response.data.rows
this.info = response.data.info
})
}
console.log(apiclassId)
},
methods: {
/** 删除按钮 */
handleDelete(index, row) {
this.cloumns.splice(index, 1);
},
methods:{
/** 提交按钮 */
submitForm() {
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 => {
console.log(res)
const validateResult = res.every(item => !!item);
if (validateResult) {
// const genTable = Object.assign({}, basicForm.model, genForm.model);
// genTable.columns = this.cloumns;
// genTable.params = {
// treeCode: genTable.treeCode,
// treeName: genTable.treeName,
// treeParentCode: genTable.treeParentCode,
// parentMenuId: genTable.parentMenuId
// };
// updateGenTable(genTable).then(res => {
// this.msgSuccess(res.msg);
// if (res.code === 200) {
// this.close();
// }
// });
} else {
this.msgError("表单校验未通过,请重新检查提交内容");
/** 新增按钮 */
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() {
const apiclassForm = this.$refs.apiclassInfo.$refs.apiclassInfoForm;
Promise.all([apiclassForm].map(this.getFormPromise)).then(res => {
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
}
});
},
getFormPromise(form) {
return new Promise(resolve => {
form.validate(res => {
resolve(res);
}
if (validateResult) {
console.log(apiclassForm.model)
const interTableDto = {
apiclass: apiclassForm.model,
interTables: this.cloumns,
};
console.log(interTableDto)
updateIntertable(interTableDto).then(res => {
this.msgSuccess(res.msg);
if (res.code === 200) {
this.close();
}
});
});
},
/** 关闭按钮 */
close() {
this.$store.dispatch("tagsView/delView", this.$route);
this.$router.push({ path: "/tool/apiclass", query: { t: Date.now()}})
}
} else {
this.msgError("表单校验未通过,请重新检查提交内容");
}
});
},
}
getFormPromise(form) {
return new Promise(resolve => {
form.validate(res => {
resolve(res);
});
});
},
/** 关闭按钮 */
close() {
this.$store.dispatch("tagsView/delView", this.$route);
this.$router.push({path: "/tool/apiclass", query: {t: Date.now()}})
}
},
}
</script>
<style scoped>

View File

@ -5,125 +5,84 @@
<module-info-form ref="moduleInfo" :info="info"/>
</el-tab-pane>
<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-column label="序号" type="index" min-width="5%" class-name="allowDrag"/>
<el-table-column
label="字段列名"
prop="columnName"
min-width="10%"
:show-overflow-tooltip="true"
/>
<el-table-column label="字段描述" min-width="10%">
<el-table-column label="接口类" min-width="12%">
<template slot-scope="scope">
<el-input v-model="scope.row.columnComment"></el-input>
</template>
</el-table-column>
<el-table-column
label="物理类型"
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"/>
</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-select v-model="scope.row.cId" 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>
v-for="item in apiclassOptions"
:key="item.id"
:label="item.cName"
:value="item.id"/>
</el-select>
</template>
</el-table-column>
<el-table-column label="接口名称" min-width="10%">
<template slot-scope="scope" >
<el-input v-model="scope.row.itName"></el-input>
</template>
</el-table-column>
<el-table-column label="接口描述" min-width="10%">
<template slot-scope="scope">
<el-input v-model="scope.row.itDescribe"></el-input>
</template>
</el-table-column>
<el-table-column label="请求路径" min-width="10%">
<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>
</template>
</el-table-column>
<el-table-column label="操作" align="center" min-width="5%">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.$index,scope.row)"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="生成信息" name="genInfo">
<gen-info-form ref="genInfo" :info="info" :tables="tables" :menus="menus"/>
</el-tab-pane>
<!-- <el-tab-pane label="生成信息" name="genInfo">-->
<!-- <gen-info-form ref="genInfo" :info="info" :tables="tables" :menus="menus"/>-->
<!-- </el-tab-pane>-->
</el-tabs>
<el-form label-width="100px">
<el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;">
@ -135,23 +94,48 @@
</template>
<script>
import {getModule} from "@/api/tool/module";
import {queryListApiclass} from "@/api/tool/apiclass";
import ModuleInfoForm from "@/views/tool/module/moduleInfoForm";
import {listIntertable,updateIntertable} from "@/api/tool/interTable";
export default {
name: "ModuleEdit",
components: {ModuleInfoForm},
data(){
return{
info:[],
// name
activeName: "cloum",
//
tableHeight: document.documentElement.scrollHeight - 245 + "px",
//
tables: [],
//
cloumns: [],
//
dictOptions: [],
//
apiclassOptions: [],
//
menus: [],
regularOptions: [],
//
info: {}
};
},
created() {
const moduleId = this.$route.params && this.$route.params.moduleId;
if (moduleId){
getModule(moduleId).then(response => {
this.info = response.data;
});
let 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:{
@ -161,24 +145,35 @@
Promise.all([moduleForm].map(this.getFormPromise)).then(res => {
const validateResult = res.every(item => !!item);
if (validateResult) {
// const genTable = Object.assign({}, basicForm.model, genForm.model);
// genTable.columns = this.cloumns;
// genTable.params = {
// treeCode: genTable.treeCode,
// treeName: genTable.treeName,
// treeParentCode: genTable.treeParentCode,
// parentMenuId: genTable.parentMenuId
// };
// updateGenTable(genTable).then(res => {
// this.msgSuccess(res.msg);
// if (res.code === 200) {
// this.close();
// }
// });
const interTableDto = {
module : moduleForm.model,
interTables : this.cloumns,
};
updateIntertable(interTableDto).then(res => {
this.msgSuccess(res.msg);
if (res.code === 200) {
this.close();
}
});
} else {
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) {
return new Promise(resolve => {

View File

@ -2,12 +2,12 @@
<el-form ref="moduleInfoForm" :model="info" :rules="rules" label-width="150px">
<el-row>
<el-col :span="12">
<el-form-item label="模块名称" prop="cName">
<el-form-item label="模块名称" prop="mDescribe">
<el-input placeholder="请输入类名" v-model="info.mDescribe"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="模块描述" prop="cName">
<el-form-item label="模块描述" prop="mName">
<el-input placeholder="请输入类名" v-model="info.mName"/>
</el-form-item>
</el-col>
@ -33,28 +33,11 @@
return {
moduleList:[],
rules: {
packageName: [
{required: true, message: "包名不能为空", trigger: "blur"},
mName: [
{ required: true, message: "模块名称不能为空}", trigger: "blur" },
],
mId: [
{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"
},
mDescribe: [
{ required: true, message: "模块描述不能为空}", trigger: "blur" },
],
}
};

View File

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

View File

@ -35,6 +35,28 @@ public interface InterTableDao
*/
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);
/**
* 删除接口信息
*

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

View File

@ -1,8 +1,10 @@
package com.hchyun.generator.service;
import java.util.List;
import java.util.Map;
import com.hchyun.common.utils.ServerResult;
import com.hchyun.generator.dto.InterTableDto;
import com.hchyun.generator.entity.InterTable;
/**
@ -27,7 +29,7 @@ public interface InterTableService
* @param interTable 接口信息
* @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 结果
*/
ServerResult<Integer> updateInterTable(InterTable interTable);
ServerResult<Integer> updateInterTable(InterTableDto interTableDto);
/**
* 批量删除接口信息

View File

@ -1,10 +1,17 @@
package com.hchyun.generator.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.hchyun.common.constant.ReturnConstants;
import com.hchyun.common.utils.SecurityUtils;
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.LoggerFactory;
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.entity.InterTable;
import com.hchyun.generator.service.InterTableService;
import org.springframework.transaction.annotation.Transactional;
/**
* 接口信息Service业务层处理
@ -25,6 +33,10 @@ public class InterTableServiceImpl implements InterTableService {
@Autowired
private InterTableDao interTableDao;
@Autowired
private ApiclassDao apiclassDao;
@Autowired
private ModuleDao moduleDao;
/**
* 查询接口信息
@ -36,14 +48,14 @@ public class InterTableServiceImpl implements InterTableService {
public ServerResult<InterTable> selectInterTableById(Long id) {
try {
InterTable interTable = interTableDao.selectInterTableById(id);
if (interTable != null){
return new ServerResult<InterTable>(true,interTable);
}else {
if (interTable != null) {
return new ServerResult<InterTable>(true, interTable);
} else {
return new ServerResult<InterTable>(false, ReturnConstants.RESULT_EMPTY);
}
}catch (RuntimeException e){
} catch (RuntimeException e) {
logger.error(e.getMessage());
return new ServerResult<InterTable>(false,ReturnConstants.DB_EX);
return new ServerResult<InterTable>(false, ReturnConstants.DB_EX);
}
}
@ -54,17 +66,22 @@ public class InterTableServiceImpl implements InterTableService {
* @return 接口信息
*/
@Override
public ServerResult<List<InterTable>> selectInterTableList(InterTable interTable) {
public ServerResult<Map<String, Object>> selectInterTableList(InterTable interTable) {
try {
List<InterTable> interTableList = interTableDao.selectInterTableList(interTable);
if (interTableList.size()>0){
return new ServerResult<List<InterTable>>(true,interTableList);
}else {
return new ServerResult<List<InterTable>>(false,ReturnConstants.RESULT_EMPTY);
Map<String,Object> modeMap = new HashMap<String, Object>();
if (interTable.getType()==1){
Module module = moduleDao.selectModuleById(interTable.getmId());
modeMap.put("info",module);
}else if (interTable.getType() == 2){
Apiclass apiclass = apiclassDao.selectApiclassById(interTable.getcId());
modeMap.put("info",apiclass);
}
}catch (RuntimeException e){
List<InterTable> interTableList = interTableDao.selectInterTableList(interTable);
modeMap.put("rows",interTableList);
return new ServerResult<Map<String, Object>>(true, modeMap);
} catch (RuntimeException e) {
logger.error(e.getMessage());
return new ServerResult<List<InterTable>>(false,ReturnConstants.DB_EX);
return new ServerResult<Map<String, Object>>(false, ReturnConstants.DB_EX);
}
}
@ -79,36 +96,50 @@ public class InterTableServiceImpl implements InterTableService {
try {
interTable.setCreateBy(SecurityUtils.getUserId());
Integer renewal = interTableDao.insertInterTable(interTable);
if (renewal >0){
return new ServerResult<Integer>(true,renewal);
}else {
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
if (renewal > 0) {
return new ServerResult<Integer>(true, renewal);
} else {
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
}
}catch (RuntimeException e){
} catch (RuntimeException e) {
logger.error(e.getMessage());
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
return new ServerResult<Integer>(false, ReturnConstants.DB_EX);
}
}
/**
* 修改接口信息
*
* @param interTable 接口信息
* @param interTableDto 接口信息
* @return 结果
*/
@Override
public ServerResult<Integer> updateInterTable(InterTable interTable) {
@Transactional
public ServerResult<Integer> updateInterTable(InterTableDto interTableDto) {
try {
interTable.setUpdateBy(SecurityUtils.getUserId());
Integer renewal = interTableDao.updateInterTable(interTable);
if (renewal >0){
return new ServerResult<Integer>(true,renewal);
}else {
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
List<InterTable> interTables = interTableDto.getInterTables();
Integer renewal = 0;
if (interTableDto.getModule() == null){
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());
}
}catch (RuntimeException e){
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 {
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
return new ServerResult<Integer>(false, ReturnConstants.DB_EX);
}
}
@ -122,14 +153,14 @@ public class InterTableServiceImpl implements InterTableService {
public ServerResult<Integer> deleteInterTableByIds(Long[] ids) {
try {
Integer renewal = interTableDao.deleteInterTableByIds(ids);
if (renewal >0){
return new ServerResult<Integer>(true,renewal);
}else {
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
if (renewal > 0) {
return new ServerResult<Integer>(true, renewal);
} else {
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
}
}catch (RuntimeException e){
} catch (RuntimeException e) {
logger.error(e.getMessage());
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
return new ServerResult<Integer>(false, ReturnConstants.DB_EX);
}
}
@ -143,14 +174,14 @@ public class InterTableServiceImpl implements InterTableService {
public ServerResult<Integer> deleteInterTableById(Long id) {
try {
Integer renewal = interTableDao.deleteInterTableById(id);
if (renewal >0){
return new ServerResult<Integer>(true,renewal);
}else {
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
if (renewal > 0) {
return new ServerResult<Integer>(true, renewal);
} else {
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
}
}catch (RuntimeException e){
} catch (RuntimeException e) {
logger.error(e.getMessage());
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
return new ServerResult<Integer>(false, ReturnConstants.DB_EX);
}
}
}

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

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

View File

@ -4,33 +4,65 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<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="mId" column="m_id" />
<result property="cId" column="c_id" />
<result property="itName" column="it_name" />
<result property="itDescribe" column="it_describe" />
<result property="isPermission" column="is_permission" />
<result property="requrl" column="requrl" />
<result property="method" column="method" />
<result property="type" column="type" />
<result property="isGenerate" column="is_generate" />
<result property="createTime" column="create_time" />
<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="updateBy" column="update_by" />
</resultMap>
<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>
<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">
<include refid="selectInterTableVo"/>
<where>
<if test="mId != null "> and m_id = #{mId}</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="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="isGenerate != null "> and is_generate = #{isGenerate}</if>
</where>
@ -41,29 +73,44 @@
where id = #{id}
</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 into sys_inter_table
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="mId != null">m_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="isPermission != null">is_permission,</if>
<if test="requrl != null">requrl,</if>
<if test="method != null">method,</if>
<if test="type != null">type,</if>
<if test="isGenerate != null">is_generate,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="mId != null">#{mId},</if>
<if test="cId != null">#{cId},</if>
<if test="itName != null">#{itName},</if>
<if test="itDescribe != null">#{itDescribe},</if>
<if test="isPermission != null">#{isPermission},</if>
<if test="requrl != null">#{requrl},</if>
<if test="method != null">#{method},</if>
<if test="type != null">#{type},</if>
<if test="isGenerate != null">#{isGenerate},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim>
</insert>
@ -72,13 +119,14 @@
<trim prefix="SET" suffixOverrides=",">
<if test="mId != null">m_id = #{mId},</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="isPermission != null">is_permission = #{isPermission},</if>
<if test="requrl != null">requrl = #{requrl},</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="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where id = #{id}
</update>