多表联查完成
This commit is contained in:
parent
14453f2c10
commit
963b92a7ee
|
|
@ -0,0 +1,54 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
|
||||
// 查询测试a列表
|
||||
export function listA(data) {
|
||||
return request({
|
||||
url: '/test/a/list',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 导出测试a
|
||||
export function exportA(data) {
|
||||
return request({
|
||||
url: '/test/a/export',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 查询测试a详细
|
||||
export function getA(aid) {
|
||||
return request({
|
||||
url: '/test/a/' + aid,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增测试a
|
||||
export function addA(data) {
|
||||
return request({
|
||||
url: '/test/a',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改测试a
|
||||
export function updateA(data) {
|
||||
return request({
|
||||
url: '/test/a',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除测试a
|
||||
export function delA(aid) {
|
||||
return request({
|
||||
url: '/test/a/' + aid,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
import request from "@/utils/request";
|
||||
|
||||
/**
|
||||
* 获取表信息
|
||||
* @returns {AxiosPromise}
|
||||
*/
|
||||
export function getTableInfos() {
|
||||
return request({
|
||||
url: '/ass/tableinfos',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取关联表表的字段信息
|
||||
* @param tableName 关联表表名
|
||||
* @param tableId 关联表id
|
||||
* @returns {AxiosPromise}
|
||||
*/
|
||||
export function getAssColumns(tableName,tableId){
|
||||
return request({
|
||||
url: '/ass/'+tableName+'/'+tableId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function getAssColumnsByTableId(tableId){
|
||||
return request({
|
||||
url:'/ass/'+tableId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
|
@ -0,0 +1,379 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="a表信息" prop="infoa">
|
||||
<el-input
|
||||
v-model="queryParams.infoa"
|
||||
placeholder="请输入a表信息"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="a表信息">
|
||||
<el-date-picker
|
||||
v-model="daterangeCreateTime"
|
||||
size="small"
|
||||
style="width: 240px"
|
||||
value-format="yyyy-MM-dd"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="b创建时间">
|
||||
<el-date-picker
|
||||
v-model="relBCreateTime"
|
||||
size="small"
|
||||
style="width: 240px"
|
||||
value-format="yyyy-MM-dd"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="信息b" prop="infob">
|
||||
<el-input
|
||||
v-model="queryParams.relB.infob"
|
||||
placeholder="请输入信息b"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="c表信息" prop="infoc">
|
||||
<el-input
|
||||
v-model="queryParams.relC.infoc"
|
||||
placeholder="请输入c表信息"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="c创建时间">
|
||||
<el-date-picker
|
||||
v-model="relCCreateTime"
|
||||
size="small"
|
||||
style="width: 240px"
|
||||
value-format="yyyy-MM-dd"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['test:a:add']"
|
||||
>新增
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['test:a:edit']"
|
||||
>修改
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['test:a:remove']"
|
||||
>删除
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['test:a:export']"
|
||||
>导出
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="aList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center"/>
|
||||
<el-table-column label="id表a" align="center" prop="aid"/>
|
||||
<el-table-column label="a表信息" align="center" prop="infoa"/>
|
||||
<el-table-column label="a表信息" align="center" prop="createTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="b创建时间" align="center" prop="relB.createTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.relB.createTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="信息b" align="center" prop="relB.infob"/>
|
||||
<el-table-column label="关联id" align="center" prop="relB.uniconId"/>
|
||||
<el-table-column label="b表id" align="center" prop="relB.bid"/>
|
||||
<el-table-column label="c表信息" align="center" prop="relC.infoc"/>
|
||||
<el-table-column label="关联ID" align="center" prop="relC.uniconId"/>
|
||||
<el-table-column label="c表id" align="center" prop="relC.cid"/>
|
||||
<el-table-column label="c创建时间" align="center" prop="relC.createTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.relC.createTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['test:a:edit']"
|
||||
>修改
|
||||
</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['test:a:remove']"
|
||||
>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageInfo.pageNum"
|
||||
:limit.sync="queryParams.pageInfo.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改测试a对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="a表信息" prop="infoa">
|
||||
<el-input v-model="form.infoa" placeholder="请输入a表信息"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {listA, getA, delA, addA, updateA, exportA} from "@/api/test/a";
|
||||
|
||||
export default {
|
||||
name: "A",
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 测试a表格数据
|
||||
aList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// a表信息时间范围
|
||||
daterangeCreateTime: [],
|
||||
|
||||
// b创建时间时间范围
|
||||
relBCreateTime: [],
|
||||
// c创建时间时间范围
|
||||
relCCreateTime: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageInfo:{
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
params: {},
|
||||
infoa: null,
|
||||
relB: {
|
||||
infob: null,
|
||||
params: {
|
||||
}
|
||||
},
|
||||
relC: {
|
||||
infoc: null,
|
||||
params: {
|
||||
}
|
||||
}
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询测试a列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
this.queryParams.params={}
|
||||
this.queryParams.relB.params={}
|
||||
this.queryParams.relC.params={}
|
||||
if (null != this.daterangeCreateTime && '' !== this.daterangeCreateTime) {
|
||||
this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0];
|
||||
this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
|
||||
}
|
||||
if (null != this.relBCreateTime && '' !== this.relBCreateTime) {
|
||||
this.queryParams.relB.params["beginCreateTime"] = this.relBCreateTime[0];
|
||||
this.queryParams.relB.params["endCreateTime"] = this.relBCreateTime[1];
|
||||
}
|
||||
if (null != this.relCCreateTime && '' !== this.relCCreateTime) {
|
||||
this.queryParams.relC.params["beginCreateTime"] = this.relCCreateTime[0];
|
||||
this.queryParams.relC.params["endCreateTime"] = this.relCCreateTime[1];
|
||||
}
|
||||
listA(this.queryParams).then(response => {
|
||||
this.aList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
aid: null,
|
||||
infoa: null,
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.daterangeCreateTime = [];
|
||||
this.relBCreateTime = [];
|
||||
this.relCCreateTime = [];
|
||||
this.queryParams.params={}
|
||||
this.queryParams.relB.params={}
|
||||
this.queryParams.relC.params={}
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.aid)
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加测试a";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const aid = row.aid || this.ids
|
||||
getA(aid).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改测试a";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.aid != null) {
|
||||
updateA(this.form).then(response => {
|
||||
this.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addA(this.form).then(response => {
|
||||
this.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const aids = row.aid || this.ids;
|
||||
this.$confirm('是否确认删除测试a编号为"' + aids + '"的数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function () {
|
||||
return delA(aids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.msgSuccess("删除成功");
|
||||
})
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const queryParams = this.queryParams;
|
||||
this.$confirm('是否确认导出所有测试a数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function () {
|
||||
return exportA(queryParams);
|
||||
}).then(response => {
|
||||
this.download(response.msg);
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
@ -152,8 +152,7 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
// 选中选项卡的 name
|
||||
// activeName: "cloum",
|
||||
activeName: "genInfo",
|
||||
activeName: "cloum",
|
||||
// 表格的高度
|
||||
tableHeight: document.documentElement.scrollHeight - 245 + "px",
|
||||
// 表信息
|
||||
|
|
@ -206,9 +205,7 @@ export default {
|
|||
submitForm() {
|
||||
const basicForm = this.$refs.basicInfo.$refs.basicInfoForm;
|
||||
const genForm = this.$refs.genInfo.$refs.genInfoForm;
|
||||
const assCloumnTable = this.$refs.genInfo.$refs.assCloumnTable;
|
||||
const relTables = this.$refs.genInfo.relTables;
|
||||
console.log(relTables)
|
||||
for (let i=0;i<relTables.length;i++){
|
||||
if (relTables[i].tableName===null){
|
||||
Message({
|
||||
|
|
@ -239,16 +236,11 @@ export default {
|
|||
return
|
||||
}
|
||||
}
|
||||
let assColumns = null;
|
||||
if (assCloumnTable!==undefined){
|
||||
assColumns = assCloumnTable.data
|
||||
}
|
||||
Promise.all([basicForm, genForm].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.assColumns = assColumns;
|
||||
genTable.relTables = relTables
|
||||
genTable.params = {
|
||||
treeCode: genTable.treeCode,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
<el-option label="单表(增删改查)" value="crud"/>
|
||||
<el-option label="树表(增删改查)" value="tree"/>
|
||||
<el-option label="多表关联(增删改查)" value="rel"/>
|
||||
<el-option label="关联表(增删改查)" value="ass"/>
|
||||
<el-option label="主子表(增删改查)" value="sub"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
|
@ -214,164 +213,6 @@
|
|||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<!--关联查询-->
|
||||
<div v-if="info.tplCategory == 'ass'">
|
||||
<el-row>
|
||||
<h4 class="form-header">关联关系</h4>
|
||||
<el-col :span="6">
|
||||
<el-form-item>
|
||||
<span slot="label">
|
||||
主表id
|
||||
<el-tooltip content="主表id, 如:acc_id" placement="top">
|
||||
<i class="el-icon-question"></i>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
<el-select v-model="info.assTableColumn" placeholder="请选择表名">
|
||||
<el-option
|
||||
v-for="(column , index) in info.columns"
|
||||
:key="index"
|
||||
:label="column.columnName+':'+column.columnComment"
|
||||
:value="column.columnName"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item>
|
||||
<span slot="label">
|
||||
关联表表名
|
||||
<el-tooltip content="关联子表的表名, 如:sys_user" placement="top">
|
||||
<i class="el-icon-question"></i>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
<el-select v-model="info.assTableName" @change="assSelectChang" placeholder="请选择表名">
|
||||
<el-option
|
||||
v-for="(table , index) in tableInfo"
|
||||
:key="index"
|
||||
:label="table.table_name + ':'+table.table_comment"
|
||||
:value="table.table_name"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item>
|
||||
<span slot="label">
|
||||
关联表表名
|
||||
<el-tooltip content="关联子表的关联字段, 如:user_id" placement="top">
|
||||
<i class="el-icon-question"></i>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
<el-select v-model="info.assTableFkColumn" @change="assSelectChang" placeholder="请选择表名">
|
||||
<el-option
|
||||
v-for="(cloumn , index) in assCloumns"
|
||||
:key="index"
|
||||
:label="cloumn.columnName + ':'+cloumn.columnComment"
|
||||
:value="cloumn.columnName"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item>
|
||||
<span slot="label">
|
||||
关联查询方式
|
||||
<el-tooltip content="关联子表的查询方式, 如:inner join" placement="top">
|
||||
<i class="el-icon-question"></i>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
<el-select v-model="info.assQueryType" placeholder="请选择查询方式">
|
||||
<el-option label="inner join" value="inner"/>
|
||||
<el-option label="left join" value="left"/>
|
||||
<el-option label="right join" value="right"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-table ref="assCloumnTable" :data="assCloumns" 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>
|
||||
</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.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="12%">
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.htmlType">
|
||||
<el-option label="文本框" value="input"/>
|
||||
<el-option label="下拉框" value="select"/>
|
||||
<el-option label="单选框" value="radio"/>
|
||||
<el-option label="复选框" value="checkbox"/>
|
||||
<el-option label="日期控件" value="datetime"/>
|
||||
</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>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<!--多表关联配置-->
|
||||
<div v-if="info.tplCategory == 'rel'">
|
||||
<el-row class="form-header">
|
||||
|
|
@ -582,7 +423,6 @@
|
|||
<script>
|
||||
import Treeselect from "@riophae/vue-treeselect";
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
import {getAssColumns, getAssColumnsByTableId} from "@/api/tool/associated"
|
||||
import {getRelId, getRelColumns, getTableInfos, getTableColumns, getRelColumnInfos} from '@/api/tool/relApi'
|
||||
|
||||
export default {
|
||||
|
|
@ -611,7 +451,6 @@ export default {
|
|||
subColumns: [],
|
||||
// 表格的高度
|
||||
tableHeight: document.documentElement.scrollHeight - 245 + "px",
|
||||
assCloumns: [],
|
||||
tableId: null,
|
||||
relTables: [],
|
||||
tableInfo: [],
|
||||
|
|
@ -641,78 +480,92 @@ export default {
|
|||
getTableInfos().then(res => {
|
||||
this.tableInfo = res.data
|
||||
})
|
||||
getRelColumnInfos(this.tableId).then(res => {
|
||||
if (res.data.length === 0) {
|
||||
getRelId().then(res => {
|
||||
let relTable = {
|
||||
id: res.data,
|
||||
tableId: this.tableId,
|
||||
tableName:null,
|
||||
relName: null,
|
||||
relComment: null,
|
||||
relColumn: null,
|
||||
tableColumn: null,
|
||||
queryType: 'left',
|
||||
sort: 1,
|
||||
tableColumns: [],
|
||||
relColumns: [],
|
||||
}
|
||||
this.relTables.push(relTable);
|
||||
})
|
||||
} else {
|
||||
let data = res.data
|
||||
for (let i=0;i<data.length;i++){
|
||||
let table = {
|
||||
tableName: data[i].relName,
|
||||
}
|
||||
getTableColumns(data[i].tableName).then(res => {
|
||||
data[i].tableColumns = res.data
|
||||
})
|
||||
this.tableList.push(table)
|
||||
}
|
||||
this.relTables=data
|
||||
}
|
||||
})
|
||||
},
|
||||
watch: {
|
||||
'info.subTableName': function (val) {
|
||||
this.setSubTableColumns(val);
|
||||
},
|
||||
'info': function (val) {
|
||||
if (val.tplCategory === 'ass') {
|
||||
getAssColumnsByTableId(this.tableId).then(res => {
|
||||
this.assCloumns = res.data
|
||||
})
|
||||
} else if (val.tplCategory === 'rel') {
|
||||
if (val.tplCategory === 'rel') {
|
||||
let table = {
|
||||
tableName: val.tableName
|
||||
}
|
||||
this.tableList.unshift(table)
|
||||
getRelColumnInfos(this.tableId).then(res => {
|
||||
if (res.data.length === 0) {
|
||||
getRelId().then(res => {
|
||||
let relTable = {
|
||||
id: res.data,
|
||||
tableId: this.tableId,
|
||||
tableName: null,
|
||||
relName: null,
|
||||
relComment: null,
|
||||
relColumn: null,
|
||||
tableColumn: null,
|
||||
queryType: 'left',
|
||||
sort: 1,
|
||||
tableColumns: [],
|
||||
relColumns: [],
|
||||
}
|
||||
this.relTables.push(relTable);
|
||||
})
|
||||
} else {
|
||||
this.relTables = []
|
||||
for (let i = 0; i < res.data.length; i++) {
|
||||
let table = {
|
||||
tableName: res.data[i].relName,
|
||||
}
|
||||
let tableData = res.data[i]
|
||||
getTableColumns(tableData.tableName).then(res => {
|
||||
tableData.tableColumns = res.data
|
||||
})
|
||||
this.relTables.push(tableData)
|
||||
this.tableList.push(table)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/** 关联父表改变 */
|
||||
tableChange(tableName, index) {
|
||||
this.relTables[index].tableColumns = []
|
||||
getTableColumns(tableName).then(res => {
|
||||
this.relTables[index].tableColumns = res.data
|
||||
this.$forceUpdate()
|
||||
})
|
||||
},
|
||||
/** 删除关子联表 */
|
||||
removeRelTable(index) {
|
||||
this.tableList.splice(index + 1, 1)
|
||||
let tableDate = this.relTables[index]
|
||||
if (tableDate.relName !== null || tableDate.relName !== '') {
|
||||
for (let i=0;i<this.tableList.length;i++){
|
||||
if (tableDate.relName === this.tableList[i].tableName){
|
||||
this.tableList.splice(i,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.relTables.splice(index, 1)
|
||||
},
|
||||
/** 关联子表改变 */
|
||||
relNameChang(index, relName) {
|
||||
getRelColumns(relName, this.relTables[index].id).then(res => {
|
||||
let start = true;
|
||||
for (let i = 0; i < this.tableList.length; i++) {
|
||||
if (relName === this.tableList[i].tableName) {
|
||||
start = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if (start) {
|
||||
let table = {
|
||||
tableName: relName,
|
||||
}
|
||||
this.tableList.push(table)
|
||||
}
|
||||
getRelColumns(relName, this.relTables[index].id).then(res => {
|
||||
for (let i = 0; i < this.tableInfo.length; i++) {
|
||||
if (this.tableInfo[i].table_name === relName){
|
||||
if (this.tableInfo[i].table_name === relName) {
|
||||
this.relTables[index].relComment = this.tableInfo[i].table_comment
|
||||
break
|
||||
}
|
||||
|
|
@ -726,7 +579,7 @@ export default {
|
|||
let relTable = {
|
||||
id: res.data,
|
||||
tableId: this.tableId,
|
||||
tableName:null,
|
||||
tableName: null,
|
||||
relName: null,
|
||||
relComment: null,
|
||||
relColumn: null,
|
||||
|
|
@ -739,12 +592,6 @@ export default {
|
|||
this.relTables.push(relTable)
|
||||
})
|
||||
},
|
||||
/** 关联表该表 */
|
||||
assSelectChang() {
|
||||
getAssColumns(this.info.assTableName, this.info.tableId).then(res => {
|
||||
this.assCloumns = res.data
|
||||
})
|
||||
},
|
||||
/** 转换菜单数据结构 */
|
||||
normalizer(node) {
|
||||
if (node.children && !node.children.length) {
|
||||
|
|
@ -762,7 +609,7 @@ export default {
|
|||
},
|
||||
/** 选择生成模板触发 */
|
||||
tplSelectChange(value) {
|
||||
if (value === 'rel'){
|
||||
if (value === 'rel') {
|
||||
this.tableList = []
|
||||
let table = {
|
||||
tableName: this.info.tableName,
|
||||
|
|
@ -772,7 +619,7 @@ export default {
|
|||
let relTable = {
|
||||
id: res.data,
|
||||
tableId: this.tableId,
|
||||
tableName:null,
|
||||
tableName: null,
|
||||
relName: null,
|
||||
relComment: null,
|
||||
relColumn: null,
|
||||
|
|
@ -784,12 +631,12 @@ export default {
|
|||
}
|
||||
this.relTables.push(relTable);
|
||||
})
|
||||
}else if (value !== 'sub') {
|
||||
} else if (value !== 'sub') {
|
||||
this.info.subTableName = '';
|
||||
this.info.subTableFkName = '';
|
||||
this.relTables=[]
|
||||
}else {
|
||||
this.relTables=[]
|
||||
this.relTables = []
|
||||
} else {
|
||||
this.relTables = []
|
||||
}
|
||||
},
|
||||
/** 设置关联外键 */
|
||||
|
|
|
|||
|
|
@ -17,12 +17,6 @@ import com.hchyun.common.annotation.Excel;
|
|||
*/
|
||||
public class BaseEntity implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* 搜索值
|
||||
*/
|
||||
private String searchValue;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
|
|
@ -64,19 +58,13 @@ public class BaseEntity implements Serializable {
|
|||
@JsonIgnore
|
||||
private String endTime;
|
||||
|
||||
|
||||
private Map<String, Object> pageInfo;
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
private Map<String, Object> params;
|
||||
|
||||
public String getSearchValue() {
|
||||
return searchValue;
|
||||
}
|
||||
|
||||
public void setSearchValue(String searchValue) {
|
||||
this.searchValue = searchValue;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
|
@ -133,6 +121,18 @@ public class BaseEntity implements Serializable {
|
|||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> getPageInfo() {
|
||||
if (pageInfo == null){
|
||||
pageInfo = new HashMap<>();
|
||||
}
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
public void setPageInfo(Map<String, Object> pageInfo) {
|
||||
this.pageInfo = pageInfo;
|
||||
}
|
||||
|
||||
public Map<String, Object> getParams() {
|
||||
if (params == null) {
|
||||
params = new HashMap<>();
|
||||
|
|
|
|||
|
|
@ -1,78 +0,0 @@
|
|||
package com.hchyun.generator.controller;
|
||||
|
||||
import com.hchyun.generator.entity.AssColumn;
|
||||
import com.hchyun.generator.service.AssociatedService;
|
||||
import com.hchyun.generator.utils.GenReturnConstants;
|
||||
import com.hchyun.generator.utils.GenServerResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* todo
|
||||
*
|
||||
* @Author 18209
|
||||
* @Date 2021/2/5 17:38
|
||||
* @Version 1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ass")
|
||||
public class AssociatedController {
|
||||
private Logger logger = LoggerFactory.getLogger(AssociatedController.class);
|
||||
|
||||
@Autowired
|
||||
private AssociatedService associatedService;
|
||||
|
||||
|
||||
@GetMapping("/{tableId}")
|
||||
private AjaxResult assColumnsByTable(@PathVariable("tableId") Long tableId) {
|
||||
try {
|
||||
GenServerResult<List<AssColumn>> genServerResult = associatedService.assColumnsByTable(tableId);
|
||||
if (genServerResult.isStart()) {
|
||||
return AjaxResult.success(genServerResult.getData());
|
||||
} else {
|
||||
return AjaxResult.error(genServerResult.getMsg());
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/tableinfos")
|
||||
public AjaxResult tableInfos() {
|
||||
try {
|
||||
GenServerResult<List<Map<String, Object>>> genServerResult = associatedService.tableInfos();
|
||||
if (genServerResult.isStart()) {
|
||||
return AjaxResult.success(genServerResult.getData());
|
||||
} else {
|
||||
return AjaxResult.error(genServerResult.getMsg());
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(GenReturnConstants.SYS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/{tableName}/{tableId}")
|
||||
public AjaxResult assColumns(@PathVariable("tableName") String tableName, @PathVariable("tableId") Long tableId) {
|
||||
try {
|
||||
GenServerResult<List<AssColumn>> genServerResult = associatedService.assColumns(tableName, tableId);
|
||||
if (genServerResult.isStart()) {
|
||||
return AjaxResult.success(genServerResult.getData());
|
||||
} else {
|
||||
return AjaxResult.error(genServerResult.getMsg());
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(GenReturnConstants.SYS_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
package com.hchyun.generator.dao;
|
||||
|
||||
import com.hchyun.generator.entity.AssColumn;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author 18209
|
||||
* @Date 2021/2/5 17:41
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface AssociatedDao {
|
||||
|
||||
/**
|
||||
* 获取表信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> tableInfos();
|
||||
|
||||
/**
|
||||
* 获取表字段信息
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
List<AssColumn> selectTableColumn(String tableName);
|
||||
|
||||
/**
|
||||
* 通过tableId删除字段信息
|
||||
*
|
||||
* @param tableId
|
||||
* @return
|
||||
*/
|
||||
Integer deleteTableColumn(Long tableId);
|
||||
|
||||
/**
|
||||
* 批量增加字段信息
|
||||
*
|
||||
* @param assColumns
|
||||
* @return
|
||||
*/
|
||||
Integer insertColumns(List<AssColumn> assColumns);
|
||||
|
||||
/**
|
||||
* 通过tableId获取字段信息
|
||||
*
|
||||
* @param tableId
|
||||
* @return
|
||||
*/
|
||||
List<AssColumn> selectTableColumnByTableId(Long tableId);
|
||||
}
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
package com.hchyun.generator.entity;
|
||||
|
||||
|
||||
public class AssColumn {
|
||||
|
||||
private long id;
|
||||
private long tableId;
|
||||
private String columnName;
|
||||
private String columnComment;
|
||||
private String columnType;
|
||||
private String javaType;
|
||||
private String javaField;
|
||||
private String isList;
|
||||
private String isQuery;
|
||||
private String queryType;
|
||||
private String htmlType;
|
||||
private String dictType;
|
||||
private Integer sort;
|
||||
private long createBy;
|
||||
private long updateBy;
|
||||
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public long getTableId() {
|
||||
return tableId;
|
||||
}
|
||||
|
||||
public void setTableId(long tableId) {
|
||||
this.tableId = tableId;
|
||||
}
|
||||
|
||||
|
||||
public String getColumnName() {
|
||||
return columnName;
|
||||
}
|
||||
|
||||
public void setColumnName(String columnName) {
|
||||
this.columnName = columnName;
|
||||
}
|
||||
|
||||
|
||||
public String getColumnComment() {
|
||||
return columnComment;
|
||||
}
|
||||
|
||||
public void setColumnComment(String columnComment) {
|
||||
this.columnComment = columnComment;
|
||||
}
|
||||
|
||||
|
||||
public String getColumnType() {
|
||||
return columnType;
|
||||
}
|
||||
|
||||
public void setColumnType(String columnType) {
|
||||
this.columnType = columnType;
|
||||
}
|
||||
|
||||
|
||||
public String getJavaType() {
|
||||
return javaType;
|
||||
}
|
||||
|
||||
public void setJavaType(String javaType) {
|
||||
this.javaType = javaType;
|
||||
}
|
||||
|
||||
|
||||
public String getJavaField() {
|
||||
return javaField;
|
||||
}
|
||||
|
||||
public void setJavaField(String javaField) {
|
||||
this.javaField = javaField;
|
||||
}
|
||||
|
||||
|
||||
public String getIsList() {
|
||||
return isList;
|
||||
}
|
||||
|
||||
public void setIsList(String isList) {
|
||||
this.isList = isList;
|
||||
}
|
||||
|
||||
|
||||
public String getIsQuery() {
|
||||
return isQuery;
|
||||
}
|
||||
|
||||
public void setIsQuery(String isQuery) {
|
||||
this.isQuery = isQuery;
|
||||
}
|
||||
|
||||
|
||||
public String getQueryType() {
|
||||
return queryType;
|
||||
}
|
||||
|
||||
public void setQueryType(String queryType) {
|
||||
this.queryType = queryType;
|
||||
}
|
||||
|
||||
|
||||
public String getHtmlType() {
|
||||
return htmlType;
|
||||
}
|
||||
|
||||
public void setHtmlType(String htmlType) {
|
||||
this.htmlType = htmlType;
|
||||
}
|
||||
|
||||
|
||||
public String getDictType() {
|
||||
return dictType;
|
||||
}
|
||||
|
||||
public void setDictType(String dictType) {
|
||||
this.dictType = dictType;
|
||||
}
|
||||
|
||||
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public long getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(long createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public long getUpdateBy() {
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(long updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -16,12 +16,6 @@ import java.util.Map;
|
|||
*/
|
||||
public class GenBaseEntity implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* 搜索值
|
||||
*/
|
||||
private String searchValue;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
|
|
@ -68,14 +62,6 @@ public class GenBaseEntity implements Serializable {
|
|||
*/
|
||||
private Map<String, Object> params;
|
||||
|
||||
public String getSearchValue() {
|
||||
return searchValue;
|
||||
}
|
||||
|
||||
public void setSearchValue(String searchValue) {
|
||||
this.searchValue = searchValue;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,8 +110,6 @@ public class GenTable extends GenBaseEntity {
|
|||
@Valid
|
||||
private List<GenTableColumn> columns;
|
||||
|
||||
@Valid
|
||||
private List<AssColumn> assColumns;
|
||||
@Valid
|
||||
private List<RelTable> relTables;
|
||||
|
||||
|
|
@ -184,14 +182,6 @@ public class GenTable extends GenBaseEntity {
|
|||
this.assQueryType = assQueryType;
|
||||
}
|
||||
|
||||
public List<AssColumn> getAssColumns() {
|
||||
return assColumns;
|
||||
}
|
||||
|
||||
public void setAssColumns(List<AssColumn> assColumns) {
|
||||
this.assColumns = assColumns;
|
||||
}
|
||||
|
||||
public String getAssTableName() {
|
||||
return assTableName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,144 +2,150 @@ package com.hchyun.generator.entity;
|
|||
|
||||
public class RelColumn {
|
||||
|
||||
//表id
|
||||
private long id;
|
||||
//父表id
|
||||
private long relId;
|
||||
//列名称
|
||||
private String columnName;
|
||||
//列描述
|
||||
private String columnComment;
|
||||
//列类型
|
||||
private String columnType;
|
||||
//java类型
|
||||
private String javaType;
|
||||
//java字段名
|
||||
private String javaField;
|
||||
//是否列表显示(1是)
|
||||
private String isList;
|
||||
//是否可查询(1可)
|
||||
private String isQuery;
|
||||
//查询方式(等于,不等于,小于,大于,区间)
|
||||
private String queryType;
|
||||
//控件显示类型
|
||||
private String htmlType;
|
||||
//字典类型
|
||||
private String dictType;
|
||||
//排序
|
||||
private Integer sort;
|
||||
//创建时间
|
||||
private long createBy;
|
||||
//表id
|
||||
private long id;
|
||||
//父表id
|
||||
private long relId;
|
||||
//列名称
|
||||
private String columnName;
|
||||
//列描述
|
||||
private String columnComment;
|
||||
//列类型
|
||||
private String columnType;
|
||||
//java类型
|
||||
private String javaType;
|
||||
//java字段名
|
||||
private String javaField;
|
||||
//是否列表显示(1是)
|
||||
private String isList;
|
||||
//是否可查询(1可)
|
||||
private String isQuery;
|
||||
//查询方式(等于,不等于,小于,大于,区间)
|
||||
private String queryType;
|
||||
//控件显示类型
|
||||
private String htmlType;
|
||||
//字典类型
|
||||
private String dictType;
|
||||
//排序
|
||||
private Integer sort;
|
||||
//创建时间
|
||||
private long createBy;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public long getRelId() {
|
||||
return relId;
|
||||
}
|
||||
public long getRelId() {
|
||||
return relId;
|
||||
}
|
||||
|
||||
public void setRelId(long relId) {
|
||||
this.relId = relId;
|
||||
}
|
||||
public void setRelId(long relId) {
|
||||
this.relId = relId;
|
||||
}
|
||||
|
||||
public String getColumnName() {
|
||||
return columnName;
|
||||
}
|
||||
public String getColumnName() {
|
||||
return columnName;
|
||||
}
|
||||
|
||||
public void setColumnName(String columnName) {
|
||||
this.columnName = columnName;
|
||||
}
|
||||
public void setColumnName(String columnName) {
|
||||
this.columnName = columnName;
|
||||
}
|
||||
|
||||
public String getColumnComment() {
|
||||
return columnComment;
|
||||
}
|
||||
public String getColumnComment() {
|
||||
return columnComment;
|
||||
}
|
||||
|
||||
public void setColumnComment(String columnComment) {
|
||||
this.columnComment = columnComment;
|
||||
}
|
||||
public void setColumnComment(String columnComment) {
|
||||
this.columnComment = columnComment;
|
||||
}
|
||||
|
||||
public String getColumnType() {
|
||||
return columnType;
|
||||
}
|
||||
public String getColumnType() {
|
||||
return columnType;
|
||||
}
|
||||
|
||||
public void setColumnType(String columnType) {
|
||||
this.columnType = columnType;
|
||||
}
|
||||
public void setColumnType(String columnType) {
|
||||
this.columnType = columnType;
|
||||
}
|
||||
|
||||
public String getJavaType() {
|
||||
return javaType;
|
||||
}
|
||||
public String getJavaType() {
|
||||
return javaType;
|
||||
}
|
||||
|
||||
public void setJavaType(String javaType) {
|
||||
this.javaType = javaType;
|
||||
}
|
||||
public void setJavaType(String javaType) {
|
||||
this.javaType = javaType;
|
||||
}
|
||||
|
||||
public String getJavaField() {
|
||||
return javaField;
|
||||
}
|
||||
public String getJavaField() {
|
||||
return javaField;
|
||||
}
|
||||
|
||||
public void setJavaField(String javaField) {
|
||||
this.javaField = javaField;
|
||||
}
|
||||
public void setJavaField(String javaField) {
|
||||
this.javaField = javaField;
|
||||
}
|
||||
|
||||
public String getIsList() {
|
||||
return isList;
|
||||
}
|
||||
public String getIsList() {
|
||||
return isList;
|
||||
}
|
||||
|
||||
public void setIsList(String isList) {
|
||||
this.isList = isList;
|
||||
}
|
||||
public void setIsList(String isList) {
|
||||
this.isList = isList;
|
||||
}
|
||||
|
||||
public String getIsQuery() {
|
||||
return isQuery;
|
||||
}
|
||||
public String getIsQuery() {
|
||||
return isQuery;
|
||||
}
|
||||
|
||||
public void setIsQuery(String isQuery) {
|
||||
this.isQuery = isQuery;
|
||||
}
|
||||
public void setIsQuery(String isQuery) {
|
||||
this.isQuery = isQuery;
|
||||
}
|
||||
|
||||
public String getQueryType() {
|
||||
return queryType;
|
||||
}
|
||||
public String getQueryType() {
|
||||
return queryType;
|
||||
}
|
||||
|
||||
public void setQueryType(String queryType) {
|
||||
this.queryType = queryType;
|
||||
}
|
||||
public void setQueryType(String queryType) {
|
||||
this.queryType = queryType;
|
||||
}
|
||||
|
||||
public String getHtmlType() {
|
||||
return htmlType;
|
||||
}
|
||||
public String getHtmlType() {
|
||||
return htmlType;
|
||||
}
|
||||
|
||||
public void setHtmlType(String htmlType) {
|
||||
this.htmlType = htmlType;
|
||||
}
|
||||
public void setHtmlType(String htmlType) {
|
||||
this.htmlType = htmlType;
|
||||
}
|
||||
|
||||
public String getDictType() {
|
||||
return dictType;
|
||||
}
|
||||
public String getDictType() {
|
||||
if (dictType == null) {
|
||||
dictType = "";
|
||||
}
|
||||
return dictType;
|
||||
}
|
||||
|
||||
public void setDictType(String dictType) {
|
||||
this.dictType = dictType;
|
||||
}
|
||||
public void setDictType(String dictType) {
|
||||
if (dictType == null) {
|
||||
dictType = "";
|
||||
}
|
||||
this.dictType = dictType;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public long getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
public long getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(long createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
public void setCreateBy(long createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
package com.hchyun.generator.service;
|
||||
|
||||
import com.hchyun.generator.entity.AssColumn;
|
||||
import com.hchyun.generator.utils.GenServerResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author 18209
|
||||
* @Date 2021/2/5 17:56
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface AssociatedService {
|
||||
/**
|
||||
* 获取到数据库表信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
GenServerResult<List<Map<String, Object>>> tableInfos();
|
||||
|
||||
/**
|
||||
* 获取到关联边字段信息
|
||||
*
|
||||
* @param tableName 关联表表名
|
||||
* @param tableId 关联关系id
|
||||
* @return
|
||||
*/
|
||||
GenServerResult<List<AssColumn>> assColumns(String tableName, Long tableId);
|
||||
|
||||
/**
|
||||
* 通过table获取到关联信息
|
||||
*
|
||||
* @param tableId
|
||||
* @return
|
||||
*/
|
||||
GenServerResult<List<AssColumn>> assColumnsByTable(Long tableId);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
package com.hchyun.generator.service.impl;
|
||||
|
||||
import com.hchyun.generator.dao.AssociatedDao;
|
||||
import com.hchyun.generator.entity.AssColumn;
|
||||
import com.hchyun.generator.service.AssociatedService;
|
||||
import com.hchyun.generator.utils.AssociatedUtils;
|
||||
import com.hchyun.generator.utils.GenReturnConstants;
|
||||
import com.hchyun.generator.utils.GenServerResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author 18209
|
||||
* @Date 2021/2/5 17:56
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Service
|
||||
public class AssociatedServiceImpl implements AssociatedService {
|
||||
private Logger logger = LoggerFactory.getLogger(AssociatedServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private AssociatedDao associatedDao;
|
||||
|
||||
@Override
|
||||
public GenServerResult<List<AssColumn>> assColumnsByTable(Long tableId) {
|
||||
try {
|
||||
List<AssColumn> assColumns = associatedDao.selectTableColumnByTableId(tableId);
|
||||
return new GenServerResult<>(assColumns);
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return new GenServerResult<>(false, GenReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenServerResult<List<Map<String, Object>>> tableInfos() {
|
||||
try {
|
||||
List<Map<String, Object>> dataMap = associatedDao.tableInfos();
|
||||
return new GenServerResult<>(dataMap);
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return new GenServerResult<>(false, GenReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenServerResult<List<AssColumn>> assColumns(String tableName, Long tableId) {
|
||||
try {
|
||||
List<AssColumn> assColumns = associatedDao.selectTableColumn(tableName);
|
||||
for (AssColumn assColumn : assColumns) {
|
||||
AssociatedUtils.initAssColumn(assColumn, tableId);
|
||||
}
|
||||
return new GenServerResult<>(assColumns);
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return new GenServerResult<>(false, GenReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,6 @@ import java.util.stream.Collectors;
|
|||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import com.hchyun.generator.dao.AssociatedDao;
|
||||
import com.hchyun.generator.dao.RelDao;
|
||||
import com.hchyun.generator.entity.*;
|
||||
import com.hchyun.generator.service.GenTableService;
|
||||
|
|
@ -52,8 +51,6 @@ public class GenTableServiceImpl implements GenTableService {
|
|||
@Autowired
|
||||
private GenTableColumnDao genTableColumnDao;
|
||||
|
||||
@Autowired
|
||||
private AssociatedDao associatedDao;
|
||||
|
||||
@Autowired
|
||||
private RelDao relDao;
|
||||
|
|
@ -154,11 +151,6 @@ public class GenTableServiceImpl implements GenTableService {
|
|||
int row = genTableDao.updateGenTable(genTable);
|
||||
if (row > 0) {
|
||||
genTableColumnDao.updateGenTableColumn(genTable.getColumns());
|
||||
List<AssColumn> assColumns = genTable.getAssColumns();
|
||||
if (assColumns != null) {
|
||||
associatedDao.deleteTableColumn(genTable.getTableId());
|
||||
associatedDao.insertColumns(assColumns);
|
||||
}
|
||||
if (genTable.getTplCategory().equals("rel")){
|
||||
List<RelTable> relTables = relDao.relTableByTableId(genTable.getTableId());
|
||||
for (RelTable relTable : relTables) {
|
||||
|
|
|
|||
|
|
@ -1,75 +0,0 @@
|
|||
package com.hchyun.generator.utils;
|
||||
|
||||
import com.hchyun.generator.entity.AssColumn;
|
||||
import com.hchyun.generator.utils.constant.GenConstants;
|
||||
|
||||
/**
|
||||
* @Author 18209
|
||||
* @Date 2021/2/6 14:48
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class AssociatedUtils {
|
||||
|
||||
|
||||
public static void initAssColumn(AssColumn assColumn, Long tableId) {
|
||||
//获取数据库数据类型
|
||||
String dataType = GenUtils.getDbType(assColumn.getColumnType());
|
||||
//获取字段名称
|
||||
String columnName = assColumn.getColumnName();
|
||||
//设置tableid
|
||||
assColumn.setTableId(tableId);
|
||||
//设置创建者id
|
||||
assColumn.setCreateBy(1);
|
||||
//转为设置java字段名称
|
||||
assColumn.setJavaField(GenStringUtils.toCamelCase(columnName));
|
||||
//默认类型
|
||||
assColumn.setJavaType(GenConstants.TYPE_STRING);
|
||||
//默认查询条件 精确查询
|
||||
assColumn.setQueryType(GenConstants.QUERY_EQ);
|
||||
|
||||
if (GenUtils.arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || GenUtils.arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType)) {
|
||||
//字符串长度超500设置htmlType为文本域
|
||||
Integer columnLength = GenUtils.getColumnLength(assColumn.getColumnType());
|
||||
String htmlType = columnLength >= 500 || GenUtils.arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType) ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT;
|
||||
assColumn.setHtmlType(htmlType);
|
||||
} else if (GenUtils.arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) {
|
||||
assColumn.setJavaType(GenConstants.TYPE_DATE);
|
||||
assColumn.setHtmlType(GenConstants.HTML_DATETIME);
|
||||
} else if (GenUtils.arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) {
|
||||
assColumn.setHtmlType(GenConstants.HTML_INPUT);
|
||||
|
||||
// 如果是浮点型 统一用BigDecimal
|
||||
String[] str = GenStringUtils.split(GenStringUtils.substringBetween(assColumn.getColumnType(), "(", ")"), ",");
|
||||
if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) {
|
||||
assColumn.setJavaType(GenConstants.TYPE_BIGDECIMAL);
|
||||
}
|
||||
// 如果是整形
|
||||
else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) {
|
||||
assColumn.setJavaType(GenConstants.TYPE_INTEGER);
|
||||
}
|
||||
// 长整形
|
||||
else {
|
||||
assColumn.setJavaType(GenConstants.TYPE_LONG);
|
||||
}
|
||||
}
|
||||
// 列表字段
|
||||
assColumn.setIsList(GenConstants.REQUIRE);
|
||||
// 查询字段
|
||||
assColumn.setIsQuery(GenConstants.NO_REQUIRE);
|
||||
// 查询字段类型
|
||||
if (GenStringUtils.endsWithIgnoreCase(columnName, "name")) {
|
||||
assColumn.setQueryType(GenConstants.QUERY_LIKE);
|
||||
}
|
||||
// 状态字段设置单选框
|
||||
if (GenStringUtils.endsWithIgnoreCase(columnName, "status")) {
|
||||
assColumn.setHtmlType(GenConstants.HTML_RADIO);
|
||||
}
|
||||
// 类型&性别字段设置下拉框
|
||||
else if (GenStringUtils.endsWithIgnoreCase(columnName, "type")
|
||||
|| GenStringUtils.endsWithIgnoreCase(columnName, "sex")) {
|
||||
assColumn.setHtmlType(GenConstants.HTML_SELECT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -56,6 +56,8 @@ public class RelUtil {
|
|||
relColumn.setIsList(GenConstants.REQUIRE);
|
||||
// 查询字段
|
||||
relColumn.setIsQuery(GenConstants.NO_REQUIRE);
|
||||
//初始化字典
|
||||
relColumn.setDictType("");
|
||||
// 查询字段类型
|
||||
if (GenStringUtils.endsWithIgnoreCase(columnName, "name")) {
|
||||
relColumn.setQueryType(GenConstants.QUERY_LIKE);
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.hchyun.generator.dao.AssociatedDao">
|
||||
<select id="tableInfos" resultType="java.util.HashMap">
|
||||
select table_name, table_comment
|
||||
from information_schema.tables
|
||||
where table_schema = (select database())
|
||||
AND table_name NOT LIKE 'qrtz_%'
|
||||
AND table_name NOT LIKE 'gen_%'
|
||||
</select>
|
||||
<select id="selectTableColumnByTableId" resultType="com.hchyun.generator.entity.AssColumn" parameterType="Long">
|
||||
select * from gen_ass_column where table_id = #{tableId} order by sort
|
||||
</select>
|
||||
|
||||
<select id="selectTableColumn" resultType="com.hchyun.generator.entity.AssColumn" parameterType="String">
|
||||
select column_name, ordinal_position as sort, column_comment, column_type
|
||||
from information_schema.columns
|
||||
where table_schema = (select database())
|
||||
and table_name = (#{tableNAme})
|
||||
order by sort
|
||||
</select>
|
||||
|
||||
<delete id="deleteTableColumn" parameterType="Long">
|
||||
delete
|
||||
from gen_ass_column
|
||||
where table_id = #{tableId}
|
||||
</delete>
|
||||
|
||||
|
||||
|
||||
<insert id="insertColumns" parameterType="java.util.List">
|
||||
insert into gen_ass_column(table_id, column_name, column_comment, column_type, java_type, java_field, is_list,
|
||||
is_query, query_type, html_type, dict_type, sort, create_by, update_by)
|
||||
values
|
||||
<foreach collection="list" item="item" index="index" separator=",">
|
||||
(#{item.tableId},#{item.columnName},#{item.columnComment},#{item.columnType},
|
||||
#{item.javaType},#{item.javaField},#{item.isList},#{item.isQuery},
|
||||
#{item.queryType},#{item.htmlType},#{item.dictType},#{item.sort},
|
||||
#{item.createBy},#{item.updateBy})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -20,10 +20,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="genType" column="gen_type" />
|
||||
<result property="genPath" column="gen_path" />
|
||||
<result property="options" column="options" />
|
||||
<result property="assTableName" column="ass_table_name" />
|
||||
<result property="assTableColumn" column="ass_table_column" />
|
||||
<result property="assTableFkColumn" column="ass_table_fk_column"/>
|
||||
<result property="assQueryType" column="ass_query_type"/>
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
|
|
@ -32,22 +28,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="AssColumnResult" type="com.hchyun.generator.entity.AssColumn">
|
||||
<id property="id" column="id" />
|
||||
<result property="tableId" column="table_id" />
|
||||
<result property="columnName" column="column_name" />
|
||||
<result property="columnComment" column="column_comment" />
|
||||
<result property="columnType" column="column_type" />
|
||||
<result property="javaType" column="java_type" />
|
||||
<result property="javaField" column="java_field" />
|
||||
<result property="isList" column="is_list" />
|
||||
<result property="isQuery" column="is_query" />
|
||||
<result property="queryType" column="query_type" />
|
||||
<result property="htmlType" column="html_type" />
|
||||
<result property="dictType" column="dict_type" />
|
||||
<result property="sort" column="sort" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.hchyun.generator.entity.GenTableColumn" id="GenTableColumnResult">
|
||||
<id property="columnId" column="column_id" />
|
||||
<result property="tableId" column="table_id" />
|
||||
|
|
@ -81,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<sql id="selectGenTableVo">
|
||||
select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category,
|
||||
package_name, module_name, business_name, function_name, function_author, gen_type, gen_path,
|
||||
options, ass_table_name, ass_table_column, ass_table_fk_column, ass_query_type, create_by, create_time, update_by, update_time, remark from gen_table
|
||||
options, create_by, create_time, update_by, update_time, remark from gen_table
|
||||
</sql>
|
||||
|
||||
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
|
||||
|
|
@ -138,37 +118,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<!--todo 获取表信息 预览代码使用-->
|
||||
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
|
||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name,t.ass_table_name,t.ass_table_column,
|
||||
t.ass_table_fk_column, t.ass_query_type, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name,
|
||||
t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
||||
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required,
|
||||
c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort, c.is_regular, r.regular
|
||||
FROM gen_table t
|
||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||
LEFT JOIN gen_regular r ON c.is_regular = r.id
|
||||
where t.table_id = #{tableId} order by c.sort
|
||||
SELECT gt.table_id, gt.table_name, gt.table_comment, gt.sub_table_name, gt.sub_table_fk_name, gt.class_name, gt.tpl_category, gt.package_name,
|
||||
gt.module_name, gt.business_name, gt.function_name, gt.function_author, gt.gen_type, gt.gen_path, gt.options, gt.remark,
|
||||
gtc.column_id, gtc.column_name, gtc.column_comment, gtc.column_type, gtc.java_type, gtc.java_field, gtc.is_pk, gtc.is_increment, gtc.is_required,
|
||||
gtc.is_insert, gtc.is_edit, gtc.is_list, gtc.is_query, gtc.query_type, gtc.html_type, gtc.dict_type, gtc.sort, gtc.is_regular, gr.regular
|
||||
FROM gen_table gt
|
||||
LEFT JOIN gen_table_column gtc ON gt.table_id = gtc.table_id
|
||||
LEFT JOIN gen_regular gr ON gtc.is_regular = gr.id
|
||||
where gt.table_id = #{tableId} order by gtc.sort
|
||||
</select>
|
||||
<!--todo 获取表信息 生成代码使用-->
|
||||
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
|
||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name,t.ass_table_name,t.ass_table_column,
|
||||
t.ass_table_fk_column, t.ass_query_type, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name,
|
||||
t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
||||
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required,
|
||||
c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort, c.is_regular, r.regular
|
||||
FROM gen_table t
|
||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||
LEFT JOIN gen_regular r ON c.is_regular = r.id
|
||||
where t.table_name = #{tableName} order by c.sort
|
||||
SELECT gt.table_id, gt.table_name, gt.table_comment, gt.sub_table_name, gt.sub_table_fk_name,gt.class_name, gt.tpl_category,
|
||||
gt.package_name, gt.module_name, gt.business_name, gt.function_name, gt.function_author, gt.gen_type, gt.gen_path,
|
||||
gt.options, gt.remark, gtc.column_id, gtc.column_name, gtc.column_comment, gtc.column_type, gtc.java_type,
|
||||
gtc.java_field, gtc.is_pk, gtc.is_increment, gtc.is_required, gtc.is_insert, gtc.is_edit, gtc.is_list,
|
||||
gtc.is_query, gtc.query_type, gtc.html_type, gtc.dict_type, gtc.sort, gtc.is_regular, gr.regular
|
||||
FROM gen_table gt
|
||||
LEFT JOIN gen_table_column gtc ON gt.table_id = gtc.table_id
|
||||
LEFT JOIN gen_regular gr ON gtc.is_regular = gr.id
|
||||
where gt.table_name = #{tableName} order by gtc.sort
|
||||
</select>
|
||||
<!-- todo 查询数据库行配置信息-->
|
||||
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
|
||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name,t.ass_table_name,t.ass_table_column,t.ass_table_fk_column,t.ass_query_type,
|
||||
t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
|
||||
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert,
|
||||
c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
||||
FROM gen_table t
|
||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||
order by c.sort
|
||||
SELECT gt.table_id, gt.table_name, gt.table_comment, gt.sub_table_name, gt.sub_table_fk_name, gt.class_name, gt.tpl_category,
|
||||
gt.package_name, gt.module_name, gt.business_name, gt.function_name, gt.function_author, gt.options, gt.remark,
|
||||
gtc.column_id, gtc.column_name, gtc.column_comment, gtc.column_type, gtc.java_type, gtc.java_field, gtc.is_pk,
|
||||
gtc.is_increment, gtc.is_required, gtc.is_insert,gtc.is_edit, gtc.is_list, gtc.is_query, gtc.query_type,
|
||||
gtc.html_type, gtc.dict_type, gtc.sort
|
||||
FROM gen_table gt
|
||||
LEFT JOIN gen_table_column gtc ON gt.table_id = gtc.table_id
|
||||
order by gtc.sort
|
||||
</select>
|
||||
|
||||
<insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId">
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@
|
|||
from information_schema.columns
|
||||
where table_schema = (select database())
|
||||
and table_name = (#{tableName})
|
||||
order by sort desc
|
||||
order by sort
|
||||
</select>
|
||||
|
||||
<insert id="insertRelTables" parameterType="java.util.List">
|
||||
|
|
@ -96,7 +96,7 @@
|
|||
from gen_rel_table grt
|
||||
left join gen_rel_column grc on grt.id = grc.rel_id
|
||||
where grt.table_id = #{tableId}
|
||||
order by grt.sort desc
|
||||
order by grt.sort
|
||||
</select>
|
||||
|
||||
<delete id="deleteRelColumnByRelId">
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class ${ClassName}Controller extends HcyBaseController {
|
|||
@PutMapping("/list")
|
||||
public Serializable list(@Validated @RequestBody ${ClassName} ${className}) {
|
||||
try {
|
||||
startPage(${className}.getParams());
|
||||
startPage(${className}.getPageInfo());
|
||||
ServerResult<List<${ClassName}>> genServerResult = ${className}Service.select${ClassName}List(${className});
|
||||
if (genServerResult.isStart()) {
|
||||
#if($table.crud || $table.sub || $tplCategory.equals("rel"))
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public interface ${ClassName}Dao {
|
|||
/**
|
||||
* 批量删除${subTable.functionName}
|
||||
*
|
||||
* @param customerIds 需要删除的数据ID
|
||||
* @param ${pkColumn.javaField}s 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||
|
|
@ -82,7 +82,7 @@ public interface ${ClassName}Dao {
|
|||
/**
|
||||
* 通过${functionName}ID删除${subTable.functionName}信息
|
||||
*
|
||||
* @param roleIds 角色ID
|
||||
* @param ${pkColumn.javaField} ${functionName}ID
|
||||
* @return 结果
|
||||
*/
|
||||
int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
|
|
|
|||
|
|
@ -8,18 +8,18 @@ import ${import};
|
|||
#elseif($table.tree)
|
||||
#set($Entity="TreeEntity")
|
||||
#end
|
||||
#if($table.tplCategory.equals("ass"))
|
||||
#set($Entity="BaseEntity")
|
||||
#if($table.tplCategory.equals("rel"))
|
||||
import com.hchyun.common.annotation.Excels;
|
||||
import ${packageName}.entity.${assClassName};
|
||||
#elseif($table.tplCategory.equals("sub"))
|
||||
import ${packageName}.entity.${subClassName};
|
||||
#end
|
||||
import com.hchyun.common.core.entity.${Entity};
|
||||
import com.hchyun.common.annotation.Excel;
|
||||
import com.hchyun.common.annotation.Excels;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
|
||||
/**
|
||||
* ${functionName}对象 ${tableName}
|
||||
|
|
|
|||
|
|
@ -195,9 +195,9 @@
|
|||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||
#elseif($column.list && $column.htmlType == "datetime")
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
#elseif($column.list && "" != $column.dictType)
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" :formatter="${javaField}Format" />
|
||||
|
|
@ -475,7 +475,7 @@ export default {
|
|||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if(${column.dictType} != '')
|
||||
#if(${column.dictType}!='')
|
||||
// $comment字典
|
||||
${column.javaField}Options: [],
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
|
|
@ -493,9 +493,9 @@ export default {
|
|||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if(!$column.dictType.equals(""))
|
||||
#if(${column.dictType}!="")
|
||||
// $comment字典
|
||||
${table.relclass}${column.javaField}Options: [],
|
||||
${table.relclass}${column.javaField}Options: [],
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
// $comment时间范围
|
||||
|
|
@ -505,10 +505,11 @@ export default {
|
|||
#end
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
params:{
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
pageInfo:{
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
params:{},
|
||||
#foreach ($column in $columns)
|
||||
#if($column.query && $column.htmlType != "datetime" && $column.queryType != "BETWEEN")
|
||||
$column.javaField: null#if($velocityCount != $columns.size()),#end
|
||||
|
|
@ -523,9 +524,12 @@ export default {
|
|||
${column.javaField}: null#if($velocityCount != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
|
||||
params:{},
|
||||
#if($velocityCount != $relTables.size()),#end
|
||||
#end
|
||||
#end
|
||||
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
|
|
@ -554,7 +558,7 @@ export default {
|
|||
created() {
|
||||
this.getList();
|
||||
#foreach ($column in $columns)
|
||||
#if(${column.dictType} != '')
|
||||
#if(${column.dictType}!='')
|
||||
this.getDicts("${column.dictType}").then(response => {
|
||||
this.${column.javaField}Options = response.data;
|
||||
});
|
||||
|
|
@ -563,7 +567,7 @@ export default {
|
|||
#if($table.tplCategory.equals("rel"))
|
||||
#foreach ($table in $relTables)
|
||||
#foreach ($column in $table.relColumns)
|
||||
#if(${column.dictType} != '')
|
||||
#if(${column.dictType}!='')
|
||||
this.getDicts("${column.dictType}").then(response => {
|
||||
this.${table.relclass}${column.javaField}Options = response.data;
|
||||
});
|
||||
|
|
@ -579,6 +583,7 @@ export default {
|
|||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.queryParams.params={}
|
||||
if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) {
|
||||
this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0];
|
||||
this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1];
|
||||
|
|
@ -589,6 +594,7 @@ export default {
|
|||
#foreach($column in $table.relColumns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.queryParams.${table.relclass}.params={}
|
||||
if (null != this.ass${AttrName} && '' != this.ass${AttrName}) {
|
||||
this.queryParams.${table.relclass}.params["begin${AttrName}"] = this.ass${AttrName}[0];
|
||||
this.queryParams.${table.relclass}.params["end${AttrName}"] = this.ass${AttrName}[1];
|
||||
|
|
@ -656,6 +662,7 @@ export default {
|
|||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.daterange${AttrName} = [];
|
||||
this.queryParams.params={}
|
||||
#end
|
||||
#end
|
||||
#if($tplCategory.equals("rel"))
|
||||
|
|
@ -663,7 +670,8 @@ export default {
|
|||
#foreach($column in $table.relColumns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.${table.relass}${AttrName} = [];
|
||||
this.${table.relclass}${AttrName} = [];
|
||||
this.queryParams.${table.relclass}.params={}
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#if($table.tplCategory.equals("rel"))
|
||||
<resultMap id="${ClassName}AllResult" type="${packageName}.entity.${ClassName}" extends="${ClassName}Result">
|
||||
#foreach($table in $relTables)
|
||||
<collection property="${table.relClass}" notNullColumn="${table.relColumn}" javaType="${packageName}.entity.${table.relClass}" resultMap="${table.relClass}Result" />
|
||||
<collection property="${table.relclass}" notNullColumn="${table.relColumn}" javaType="${packageName}.entity.${table.relClass}" resultMap="${table.relClass}Result" />
|
||||
#end
|
||||
</resultMap>
|
||||
#foreach($table in $relTables)
|
||||
|
|
@ -52,13 +52,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#end
|
||||
#end
|
||||
#set($indexs = 0)
|
||||
#foreach($column in $table.relColumns) #if($column.isList == "1")#set($indexs = $indexs + 1)${table.relAs}.$column.columnName#if($indexs != $count),#end#end#end#if($velocityCount != $columns.size()),
|
||||
#foreach($column in $table.relColumns) #if($column.isList == "1")#set($indexs = $indexs + 1)${table.relAs}.$column.columnName#if($indexs != $count),#end#end#end#if($velocityCount != $relTables.size()),
|
||||
#end
|
||||
#end
|
||||
|
||||
from ${tableName} ${tableMapping}
|
||||
from ${tableName} ${tableMapping}
|
||||
#foreach($table in $relTables)
|
||||
${table.queryType} join ${table.relName} on ${table.tableAs}.${table.tableColumn} = ${table.relAs}.${table.relColumn}
|
||||
${table.queryType} join ${table.relName} ${table.relAs} on ${table.tableAs}.${table.tableColumn} = ${table.relAs}.${table.relColumn}
|
||||
#end
|
||||
<where>
|
||||
#foreach($column in $columns)
|
||||
|
|
@ -92,7 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#set($queryType=$column.queryType)
|
||||
#set($javaField=$table.relclass + "." + $column.javaField)
|
||||
#set($javaType=$column.javaType)
|
||||
#set($columnName=$table.relclass+'.'+$column.columnName)
|
||||
#set($columnName=$table.relAs+'.'+$column.columnName)
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#if($column.isQuery.equals("1"))
|
||||
#if($column.queryType == "EQ")
|
||||
|
|
@ -149,14 +149,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#elseif($tplCategory.equals("ass"))${ClassName}AllResult#else${ClassName}Result#end">
|
||||
<select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
|
||||
#if($table.crud || $table.tree || $tplCategory.equals("rel"))
|
||||
<include refid="select${ClassName}Vo"/>
|
||||
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||
#elseif($table.sub)
|
||||
select#foreach($column in $columns) ${tableMapping}.$column.columnName#if($velocityCount != $columns.size()),#end#end,
|
||||
#foreach($column in $subTable.columns) ${subMapping}.$column.columnName#if($velocityCount != $subTable.columns.size()),#end#end
|
||||
|
||||
from ${tableName} ${tableMapping}
|
||||
left join ${subTableName} ${subMapping} on ${subMapping}.${subTableFkName} = ${tableMapping}.${pkColumn.columnName}
|
||||
where ${tableMapping}.${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||
|
|
@ -173,13 +172,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#end
|
||||
#end
|
||||
#set($indexs = 0)
|
||||
#foreach($column in $table.relColumns) #if($column.isList == "1")#set($indexs = $indexs + 1)${table.relAs}.$column.columnName#if($indexs != $count),#end#end#end#if($velocityCount != $columns.size()),
|
||||
#foreach($column in $table.relColumns) #if($column.isList == "1")#set($indexs = $indexs + 1)${table.relAs}.$column.columnName#if($indexs != $count),#end#end#end#if($velocityCount != $relTables.size()),
|
||||
#end
|
||||
#end
|
||||
|
||||
from ${tableName} ${tableMapping}
|
||||
#foreach($table in $relTables)
|
||||
${table.queryType} join ${table.relName} on ${table.tableAs}.${table.tableColumn} = ${table.relAs}.${table.relColumn}
|
||||
${table.queryType} join ${table.relName} ${table.relAs} on ${table.tableAs}.${table.tableColumn} = ${table.relAs}.${table.relColumn}
|
||||
#end
|
||||
where ${tableMapping}.${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -1,26 +1,35 @@
|
|||
package com.hchyun.test.controller;
|
||||
|
||||
import com.hchyun.common.annotation.Log;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
import com.hchyun.common.constant.ReturnConstants;
|
||||
import com.hchyun.common.core.controller.HcyBaseController;
|
||||
import com.hchyun.common.core.entity.AjaxResult;
|
||||
import com.hchyun.common.enums.BusinessType;
|
||||
import com.hchyun.common.utils.ServerResult;
|
||||
import com.hchyun.common.utils.poi.ExcelUtil;
|
||||
import com.hchyun.test.entity.RelA;
|
||||
import com.hchyun.test.service.RelAService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.hchyun.common.annotation.Log;
|
||||
import com.hchyun.common.core.entity.AjaxResult;
|
||||
import com.hchyun.common.enums.BusinessType;
|
||||
import com.hchyun.test.entity.RelA;
|
||||
import com.hchyun.test.service.RelAService;
|
||||
import com.hchyun.common.utils.poi.ExcelUtil;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 测试aController
|
||||
|
|
@ -46,10 +55,10 @@ public class RelAController extends HcyBaseController {
|
|||
@PutMapping("/list")
|
||||
public Serializable list(@Validated @RequestBody RelA relA) {
|
||||
try {
|
||||
startPage(relA.getParams());
|
||||
startPage(relA.getPageInfo());
|
||||
ServerResult<List<RelA>> genServerResult = relAService.selectRelAList(relA);
|
||||
if (genServerResult.isStart()) {
|
||||
return AjaxResult.success(genServerResult.getData());
|
||||
return getDataTable(genServerResult.getData());
|
||||
} else {
|
||||
return AjaxResult.info(genServerResult.getMsg());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
package com.hchyun.test.dao;
|
||||
|
||||
import com.hchyun.test.entity.RelA;
|
||||
|
||||
import java.util.List;
|
||||
import com.hchyun.test.entity.RelA;
|
||||
|
||||
/**
|
||||
* 测试aMapper接口
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package com.hchyun.test.entity;
|
||||
|
||||
import com.hchyun.common.annotation.Excel;
|
||||
import com.hchyun.common.annotation.Excels;
|
||||
import com.hchyun.common.core.entity.BaseEntity;
|
||||
import com.hchyun.common.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
|
@ -27,14 +27,14 @@ public class RelA extends BaseEntity{
|
|||
private String infoa;
|
||||
|
||||
|
||||
/** 测试c表信息 */
|
||||
@Excels({@Excel(name = "关联ID",targetAttr = "uniconId"),@Excel(name = "c表id",targetAttr = "cid"),@Excel(name = "c表信息",targetAttr = "infoc"),})
|
||||
private RelC relC;
|
||||
|
||||
/** 测试b表信息 */
|
||||
@Excels({@Excel(name = "信息b",targetAttr = "infob"),@Excel(name = "关联id",targetAttr = "uniconId"),@Excel(name = "b表id",targetAttr = "bid"),})
|
||||
@Excels({@Excel(name = "b创建时间",targetAttr = "createTime"),@Excel(name = "信息b",targetAttr = "infob"),@Excel(name = "关联id",targetAttr = "uniconId"),@Excel(name = "b表id",targetAttr = "bid"),})
|
||||
private RelB relB;
|
||||
|
||||
/** 测试c表信息 */
|
||||
@Excels({@Excel(name = "c表信息",targetAttr = "infoc"),@Excel(name = "关联ID",targetAttr = "uniconId"),@Excel(name = "c表id",targetAttr = "cid"),@Excel(name = "c创建时间",targetAttr = "createTime"),})
|
||||
private RelC relC;
|
||||
|
||||
|
||||
public void setAid(Long aid){
|
||||
this.aid = aid;
|
||||
|
|
@ -51,13 +51,6 @@ public class RelA extends BaseEntity{
|
|||
return infoa;
|
||||
}
|
||||
|
||||
public RelC getRelC(){
|
||||
return relC;
|
||||
}
|
||||
|
||||
public void setRelC(RelC relC){
|
||||
this.relC = relC;
|
||||
}
|
||||
public RelB getRelB(){
|
||||
return relB;
|
||||
}
|
||||
|
|
@ -65,13 +58,21 @@ public class RelA extends BaseEntity{
|
|||
public void setRelB(RelB relB){
|
||||
this.relB = relB;
|
||||
}
|
||||
public RelC getRelC(){
|
||||
return relC;
|
||||
}
|
||||
|
||||
public void setRelC(RelC relC){
|
||||
this.relC = relC;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("aid", getAid())
|
||||
.append("infoa", getInfoa())
|
||||
.append("relC",getRelC())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("relB",getRelB())
|
||||
.append("relC",getRelC())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.hchyun.test.entity;
|
|||
|
||||
import com.hchyun.common.annotation.Excel;
|
||||
import com.hchyun.common.core.entity.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.hchyun.test.entity;
|
|||
|
||||
import com.hchyun.common.annotation.Excel;
|
||||
import com.hchyun.common.core.entity.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
package com.hchyun.test.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hchyun.common.utils.ServerResult;
|
||||
import com.hchyun.test.entity.RelA;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 测试aService接口
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
package com.hchyun.test.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hchyun.common.constant.ReturnConstants;
|
||||
import com.hchyun.common.utils.DateUtils;
|
||||
import com.hchyun.common.utils.ServerResult;
|
||||
import com.hchyun.test.dao.RelADao;
|
||||
import com.hchyun.test.entity.RelA;
|
||||
import com.hchyun.test.service.RelAService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import com.hchyun.test.dao.RelADao;
|
||||
import com.hchyun.test.entity.RelA;
|
||||
import com.hchyun.test.service.RelAService;
|
||||
|
||||
/**
|
||||
* 测试aService业务层处理
|
||||
|
|
|
|||
|
|
@ -3,50 +3,76 @@
|
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.hchyun.test.dao.RelADao">
|
||||
|
||||
|
||||
<resultMap type="com.hchyun.test.entity.RelA" id="RelAResult">
|
||||
<result property="aid" column="aid" />
|
||||
<result property="infoa" column="infoa" />
|
||||
<result property="createTime" column="create_time" />
|
||||
</resultMap>
|
||||
<resultMap id="RelAAllResult" type="com.hchyun.test.entity.RelA" extends="RelAResult">
|
||||
<collection property="RelC" notNullColumn="unicon_id" javaType="com.hchyun.test.entity.RelC" resultMap="RelCResult" />
|
||||
<collection property="RelB" notNullColumn="unicon_id" javaType="com.hchyun.test.entity.RelB" resultMap="RelBResult" />
|
||||
</resultMap>
|
||||
<resultMap id="RelCResult" type="com.hchyun.test.entity.RelC">
|
||||
<result property="uniconId" column="unicon_id" />
|
||||
<result property="cid" column="cId" />
|
||||
<result property="infoc" column="infoc" />
|
||||
<collection property="relB" notNullColumn="unicon_id" javaType="com.hchyun.test.entity.RelB" resultMap="RelBResult" />
|
||||
<collection property="relC" notNullColumn="unicon_id" javaType="com.hchyun.test.entity.RelC" resultMap="RelCResult" />
|
||||
</resultMap>
|
||||
<resultMap id="RelBResult" type="com.hchyun.test.entity.RelB">
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="infob" column="infob" />
|
||||
<result property="uniconId" column="unicon_id" />
|
||||
<result property="bid" column="bid" />
|
||||
</resultMap>
|
||||
<resultMap id="RelCResult" type="com.hchyun.test.entity.RelC">
|
||||
<result property="infoc" column="infoc" />
|
||||
<result property="uniconId" column="unicon_id" />
|
||||
<result property="cid" column="cId" />
|
||||
<result property="createTime" column="create_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectRelAVo">
|
||||
select aid, infoa from test_rel_a
|
||||
select aid, infoa, create_time from test_rel_a
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="selectRelAList" parameterType="RelA" resultMap="RelAAllResult">
|
||||
select tra.aid, tra.infoa, tra.create_time,
|
||||
trb.create_time, trb.infob, trb.unicon_id, trb.bid,
|
||||
trc.infoc, trc.unicon_id, trc.cId, trc.create_time
|
||||
from test_rel_a tra
|
||||
left join test_rel_b trb on tra.aid = trb.unicon_id
|
||||
left join test_rel_c trc on trb.bid = trc.unicon_id
|
||||
<where>
|
||||
<if test="infoa != null and infoa != ''"> and tra.infoa like concat('%', #{infoa}, '%')</if>
|
||||
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and tra.create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
|
||||
<if test="relB.params.beginCreateTime != null and relB.params.beginCreateTime != '' and relB.params.endCreateTime != null and relB.params.endCreateTime != ''"> and trb.create_time between #{relB.params.beginCreateTime} and #{relB.params.endCreateTime}</if>
|
||||
<if test="relB.infob != null and relB.infob != ''"> and trb.infob like concat('%', #{relB.infob}, '%')</if>
|
||||
<if test="relC.infoc != null and relC.infoc != ''"> and trc.infoc like concat('%', #{relC.infoc}, '%')</if>
|
||||
<if test="relC.params.beginCreateTime != null and relC.params.beginCreateTime != '' and relC.params.endCreateTime != null and relC.params.endCreateTime != ''"> and trc.create_time between #{relC.params.beginCreateTime} and #{relC.params.endCreateTime}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectRelAById" parameterType="Long" resultMap="RelAResult">
|
||||
<include refid="selectRelAVo"/>
|
||||
where aid = #{aid}
|
||||
</select>
|
||||
<select id="selectRelAAllById" parameterType="Long" resultMap="RelAAllResult">
|
||||
select tra.aid, tra.infoa, tra.create_time,
|
||||
trb.create_time, trb.infob, trb.unicon_id, trb.bid,
|
||||
trc.infoc, trc.unicon_id, trc.cId, trc.create_time
|
||||
from test_rel_a tra
|
||||
left join test_rel_b trb on tra.aid = trb.unicon_id
|
||||
left join test_rel_c trc on trb.bid = trc.unicon_id
|
||||
where tra.aid = #{aid}
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertRelA" parameterType="RelA">
|
||||
insert into test_rel_a
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="aid != null">aid,</if>
|
||||
<if test="infoa != null">infoa,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="aid != null">#{aid},</if>
|
||||
<if test="infoa != null">#{infoa},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
|
@ -54,6 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
update test_rel_a
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="infoa != null">infoa = #{infoa},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
</trim>
|
||||
where aid = #{aid}
|
||||
</update>
|
||||
|
|
@ -63,7 +90,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</delete>
|
||||
|
||||
<delete id="deleteRelAByIds" parameterType="String">
|
||||
delete from test_rel_a where aid in
|
||||
delete from test_rel_a where aid in
|
||||
<foreach item="aid" collection="array" open="(" separator="," close=")">
|
||||
#{aid}
|
||||
</foreach>
|
||||
|
|
|
|||
Loading…
Reference in New Issue