top管理

This commit is contained in:
clay 2021-07-22 21:58:27 +08:00
parent ddf9bb5dcc
commit aed22239ec
14 changed files with 493 additions and 89 deletions

View File

@ -9,6 +9,15 @@ export function listTable(data) {
data: data
})
}
// 查询top万能查询主列表
export function listInfoTable() {
return request({
url: '/tool/table/info',
method: 'post',
})
}
// 导出top万能查询主
export function exportTable(data) {
@ -18,6 +27,13 @@ export function exportTable(data) {
data: data
})
}
// 导出top万能查询主
export function columns(id) {
return request({
url: '/tool/table/columns/'+id,
method: 'get',
})
}
// 导入表

View File

@ -1,3 +1,4 @@
<script src="../../../api/tool/table.js"></script>
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
@ -148,7 +149,7 @@
<el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row>
<el-col :span="12">
<el-col :span="8">
<el-form-item label="表名:" prop="tableName">
<span>{{form.tableName}}</span>
</el-form-item>
@ -170,8 +171,64 @@
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="16">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddTopSearchColumn">添加</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteTopSearchColumn">删除</el-button>
</el-col>
</el-row>
<el-table :data="relationalMapList" :row-class-name="rowRelationalMapIndex" @selection-change="handleRelationalMapSelectionChange" ref="relationalMap">
<el-table-column type="selection" width="50" align="center" prop="index" />
<el-table-column label="序号" align="center" prop="index" width="50"/>
<el-table-column label="外键" prop="mainKey">
<template slot-scope="scope">
<el-select v-model="scope.row.mainKey" placeholder="外键">
<el-option
v-for="item in topSearchColumnList"
:key="item.id"
:label="item.columnName+':'+item.columnComment"
:value="item.columnName">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="关联表" prop="childId">
<template slot-scope="scope">
<el-select v-model="scope.row.childId" @change="changeChildList(scope.row.childId,scope.$index)" placeholder="关联表">
<el-option
v-for="(item,index) in tableInfoList"
:key="index"
:label="item.tableName+':'+item.tableComment"
:value="item.id">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="关联字段" prop="childKey">
<template slot-scope="scope">
<el-select v-model="scope.row.childKey" placeholder="关联表">
<el-option
v-for="(item,index) in scope.row.childListColumn"
:key="index"
:label="item.columnName+':'+item.columnComment"
:value="item.columnName">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="关联方式" prop="types">
<template slot-scope="scope">
<el-select v-model="scope.row.types" multiple placeholder="关联方式">
<el-option label="hasOne" :value="1"/>
<el-option label="hasMany" :value="2"/>
<el-option label="belongsTo" :value="3"/>
</el-select>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<el-divider content-position="center">top万能查询字段信息</el-divider>
@ -183,7 +240,7 @@
<!-- <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteTopSearchColumn">删除</el-button>-->
<!-- </el-col>-->
</el-row>
<el-table :data="topSearchColumnList" :row-class-name="rowTopSearchColumnIndex" @selection-change="handleTopSearchColumnSelectionChange" ref="topSearchColumn">
<el-table :data="topSearchColumnList" :row-class-name="rowTopSearchColumnIndex" ref="topSearchColumn">
<el-table-column label="序号" align="center" prop="index" width="50"/>
<el-table-column label="列名称" prop="columnName">
<template slot-scope="scope">
@ -210,11 +267,11 @@
<span>{{scope.row.createTime}}</span>
</template>
</el-table-column>
<el-table-column label="更新时间" prop="updateTime">
<template slot-scope="scope">
<span>{{scope.row.updateTime}}</span>
</template>
</el-table-column>
<!-- <el-table-column label="更新时间" prop="updateTime">-->
<!-- <template slot-scope="scope">-->
<!-- <span>{{scope.row.updateTime}}</span>-->
<!-- </template>-->
<!-- </el-table-column>-->
</el-table>
</el-form>
<div slot="footer" class="dialog-footer">
@ -228,7 +285,7 @@
</template>
<script>
import { listTable, getTable, delTable, addTable, updateTable, exportTable } from "@/api/tool/table";
import { listTable,columns, getTable, delTable, addTable, updateTable, exportTable, listInfoTable } from "@/api/tool/table";
import {listRole} from '../../../api/system/role'
import importTopTable from "./importTopTable";
export default {
@ -241,7 +298,7 @@ export default {
//
ids: [],
//
checkedTopSearchColumn: [],
checkedRelationalMapList: [],
//
single: true,
//
@ -256,6 +313,8 @@ export default {
roleOptions: [],
// top
topSearchColumnList: [],
relationalMapList: [],
tableInfoList: [],
//
title: "",
//
@ -264,7 +323,6 @@ export default {
daterangeCreateTime: [],
//
daterangeUpdateTime: [],
//
queryParams: {
pageInfo:{
@ -331,6 +389,7 @@ export default {
roleIds:[],
};
this.topSearchColumnList = [];
this.relationalMapList = [];
this.resetForm("form");
},
/** 搜索按钮操作 */
@ -367,9 +426,29 @@ export default {
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
listInfoTable().then( res=>{
this.tableInfoList = res.rows
})
getTable(id).then(response => {
this.form = response.data;
this.topSearchColumnList = response.data.topSearchColumnList;
let relList = response.data.relationalMapList;
for (let i = 0; i < relList.length; i++) {
let item = {
mainId:relList[i].mainId,
childId:relList[i].childId,
mainKey:relList[i].mainKey,
childKey:relList[i].childKey,
type:relList[i].type,
types:[],
}
let list = relList[i].type.split(",");
for (const listKey in list) {
item.types.push(parseInt(list[listKey]))
}
this.relationalMapList.push(item)
}
console.log(this.topSearchColumnList)
this.open = true;
this.title = "修改top万能查询主";
});
@ -379,6 +458,18 @@ export default {
this.$refs["form"].validate(valid => {
if (valid) {
this.form.topSearchColumnList = this.topSearchColumnList;
for (let i = 0; i < this.relationalMapList.length; i++) {
this.relationalMapList[i].type = ""
for (let j = 0; j < this.relationalMapList[i].types.length; j++) {
if (j===this.relationalMapList[i].types.length-1){
this.relationalMapList[i].type+=this.relationalMapList[i].types[j]
}else {
this.relationalMapList[i].type+=(this.relationalMapList[i].types[j]+',')
}
}
}
this.form.relationalMapList = this.relationalMapList;
this.form.relationalMapList = this.relationalMapList
if (this.form.id != null) {
updateTable(this.form).then(response => {
this.msgSuccess("修改成功");
@ -412,33 +503,45 @@ export default {
/** top万能查询字段序号 */
rowTopSearchColumnIndex({ row, rowIndex }) {
row.index = rowIndex + 1;
},
/** top万能查询字段序号 */
rowRelationalMapIndex({ row, rowIndex }) {
row.index = rowIndex + 1;
},
/** top万能查询字段添加按钮操作 */
handleAddTopSearchColumn() {
let obj = {};
obj.columnName = "";
obj.columnComment = "";
obj.columnType = "";
obj.isUse = "";
obj.createTime = "";
obj.updateTime = "";
this.topSearchColumnList.push(obj);
let obj = {
mainId : this.form.id,
childId : null,
mainKey : null,
childKey : null,
type : null,
types : [],
childListColumn:[],
};
this.relationalMapList.push(obj);
},
/** top万能查询字段删除按钮操作 */
handleDeleteTopSearchColumn() {
if (this.checkedTopSearchColumn.length == 0) {
if (this.checkedRelationalMapList.length == 0) {
this.$alert("请先选择要删除的top万能查询字段数据", "提示", { confirmButtonText: "确定", });
} else {
this.topSearchColumnList.splice(this.checkedTopSearchColumn[0].index - 1, 1);
this.relationalMapList.splice(this.checkedRelationalMapList[0].index - 1, 1);
}
},
changeChildList(id,index){
//todo
columns(id).then(res=>{
this.relationalMapList[index].childListColumn = res.data
})
},
/** 单选框选中数据 */
handleTopSearchColumnSelectionChange(selection) {
handleRelationalMapSelectionChange(selection) {
if (selection.length > 1) {
this.$refs.topSearchColumn.clearSelection();
this.$refs.topSearchColumn.toggleRowSelection(selection.pop());
this.$refs.relationalMap.clearSelection();
this.$refs.relationalMap.toggleRowSelection(selection.pop());
} else {
this.checkedTopSearchColumn = selection;
this.checkedRelationalMapList = selection;
}
},
/** 导出按钮操作 */

View File

@ -12,14 +12,7 @@ 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;
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 org.springframework.web.bind.annotation.*;
import com.ebts.common.annotation.Log;
import com.ebts.common.core.entity.AjaxResult;
import com.ebts.common.enums.BusinessType;
@ -56,6 +49,26 @@ public class TopSearchTableController extends EBTSController {
return AjaxResult.info(genServerResult.getMsg());
}
}
@PreAuthorize("@ebts.hasPermi('tool:table:cloumns')")
@GetMapping("/columns/{id}")
public AjaxResult columns(@PathVariable("id") Long id){
return AjaxResult.success(topSearchTableService.selectTableColumns(id));
}
/**
* 查询top万能查询主列表
*/
@PreAuthorize("@ebts.hasPermi('tool:table:info')")
@PostMapping("/info")
public Serializable info() {
ServerResult<List<TopSearchTable>> genServerResult = topSearchTableService.selectTopSearchTableInfo();
if (genServerResult.isStart()) {
return getDataTable(genServerResult.getData());
} else {
return AjaxResult.info(genServerResult.getMsg());
}
}
/**
* 导出top万能查询主列表

View File

@ -0,0 +1,62 @@
package com.ebts.generator.dao;
import java.util.List;
import com.ebts.generator.entity.RelationalMap;
/**
* top万能查询关系映射Mapper接口
*
* @author clay
* @date 2021-07-21
*/
public interface RelationalMapDao {
/**
* 查询top万能查询关系映射
*
* @param mainId top万能查询关系映射ID
* @return top万能查询关系映射
*/
RelationalMap selectRelationalMapById(Long mainId);
/**
* 查询top万能查询关系映射列表
*
* @param relationalMap top万能查询关系映射
* @return top万能查询关系映射集合
*/
List<RelationalMap> selectRelationalMapList(RelationalMap relationalMap);
/**
* 新增top万能查询关系映射
*
* @param relationalMap top万能查询关系映射
* @return 结果
*/
int insertRelationalMap(RelationalMap relationalMap);
/**
* 修改top万能查询关系映射
*
* @param relationalMap top万能查询关系映射
* @return 结果
*/
int updateRelationalMap(RelationalMap relationalMap);
/**
* 删除top万能查询关系映射
*
* @param mainId top万能查询关系映射ID
* @return 结果
*/
int deleteRelationalMapById(Long mainId);
/**
* 批量删除top万能查询关系映射
*
* @param mainIds 需要删除的数据ID
* @return 结果
*/
int deleteRelationalMapByIds(Long[] mainIds);
int batchRelationalMap(List<RelationalMap> relationalMaps);
}

View File

@ -1,14 +1,6 @@
package com.ebts.generator.dao;
/**
* @author: Clay
* @date: 2021/7/21 0:44
* @descriptionSearchTableRoleDao
* @email: clay@hchyun.com
*/
import java.util.List;
import com.ebts.generator.entity.SearchTableRole;
/**
@ -18,14 +10,6 @@ import com.ebts.generator.entity.SearchTableRole;
* @date 2021-07-21
*/
public interface SearchTableRoleDao {
/**
* 查询top万能查询角色关系
*
* @param searchTableId top万能查询角色关系ID
* @return top万能查询角色关系
*/
SearchTableRole selectSearchTableRoleById(Long searchTableId);
/**
* 查询top万能查询角色关系列表
*
@ -34,22 +18,6 @@ public interface SearchTableRoleDao {
*/
List<SearchTableRole> selectSearchTableRoleList(SearchTableRole searchTableRole);
/**
* 新增top万能查询角色关系
*
* @param searchTableRole top万能查询角色关系
* @return 结果
*/
int insertSearchTableRole(SearchTableRole searchTableRole);
/**
* 修改top万能查询角色关系
*
* @param searchTableRole top万能查询角色关系
* @return 结果
*/
int updateSearchTableRole(SearchTableRole searchTableRole);
/**
* 删除top万能查询角色关系
*
@ -59,12 +27,10 @@ public interface SearchTableRoleDao {
int deleteSearchTableRoleById(Long searchTableId);
/**
* 批量删除top万能查询角色关系
* 批量添加top万能查询角色关系
*
* @param searchTableIds 需要删除的数据ID
* @param roleList
* @return 结果
*/
int deleteSearchTableRoleByIds(Long[] searchTableIds);
int batchSearchTableRole(List<SearchTableRole> roleList);
}

View File

@ -27,6 +27,14 @@ public interface TopSearchTableDao {
*/
List<TopSearchTable> selectTopSearchTableList(TopSearchTable topSearchTable);
List<TopSearchColumn> selectTableColumns(Long id);
/**
*
* @return
*/
List<TopSearchTable> selectTopSearchTableInfo();
/**
* 查询据库列表
*
@ -34,6 +42,12 @@ public interface TopSearchTableDao {
* @return 数据库表集合
*/
List<TopSearchTable> selectDbTableListByNames(String[] tableNames);
/**
* 根据表名查询列
* @param tableName
* @return
*/
List<TopSearchColumn> selectDbTableColumnsByName(String tableName);

View File

@ -0,0 +1,77 @@
package com.ebts.generator.entity;
import com.ebts.common.core.entity.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* top万能查询关系映射对象 gen_relational_mapping
*
* @author clay
* @date 2021-07-21
*/
public class RelationalMap extends BaseEntity{
/** 主表id */
private Long mainId;
/** 字表id */
private Long childId;
/** 主表字段 */
private String mainKey;
/** 字表字段 */
private String childKey;
/** 关系 1:hasOne 2:hasMany 3: belongsTo */
private String type;
public void setMainId(Long mainId){
this.mainId = mainId;
}
public Long getMainId(){
return mainId;
}
public void setChildId(Long childId){
this.childId = childId;
}
public Long getChildId(){
return childId;
}
public void setMainKey(String mainKey){
this.mainKey = mainKey;
}
public String getMainKey(){
return mainKey;
}
public void setChildKey(String childKey){
this.childKey = childKey;
}
public String getChildKey(){
return childKey;
}
public void setType(String type){
this.type = type;
}
public String getType(){
return type;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("mainId", getMainId())
.append("childId", getChildId())
.append("mainKey", getMainKey())
.append("childKey", getChildKey())
.append("type", getType())
.toString();
}
}

View File

@ -1,15 +1,6 @@
package com.ebts.generator.entity;
/**
* @author: Clay
* @date: 2021/7/21 0:43
* @descriptionSearchTableRole
* @email: clay@hchyun.com
*/
import com.ebts.common.core.entity.BaseEntity;
import com.ebts.common.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

View File

@ -14,29 +14,32 @@ import org.apache.commons.lang3.builder.ToStringStyle;
* @author clay
* @date 2021-07-20
*/
@ApiModel("top万能查询主")
public class TopSearchTable extends BaseEntity{
/** 主键id */
@ApiModelProperty("主键id")
private Long id;
/** 表名 */
@Excel(name = "表名")
@ApiModelProperty("表名")
private String tableName;
/** 表描述 */
@Excel(name = "表描述")
@ApiModelProperty("表描述")
private String tableComment;
/** top万能查询字段信息 */
@ApiModelProperty("top万能查询字段信息")
private List<TopSearchColumn> topSearchColumnList;
private Long[] roleIds;
private List<RelationalMap> relationalMapList;
public List<RelationalMap> getRelationalMapList() {
return relationalMapList;
}
public void setRelationalMapList(List<RelationalMap> relationalMapList) {
this.relationalMapList = relationalMapList;
}
public Long[] getRoleIds() {
return roleIds;
}
@ -88,4 +91,5 @@ public class TopSearchTable extends BaseEntity{
.append("topSearchColumnList", getTopSearchColumnList())
.toString();
}
}

View File

@ -3,6 +3,7 @@ package com.ebts.generator.service;
import java.util.List;
import com.ebts.common.utils.ServerResult;
import com.ebts.generator.entity.TopSearchColumn;
import com.ebts.generator.entity.TopSearchTable;
/**
@ -29,6 +30,13 @@ public interface TopSearchTableService
*/
ServerResult<List<TopSearchTable>> selectTopSearchTableList(TopSearchTable topSearchTable);
/**
*
* @return
*/
ServerResult<List<TopSearchTable>> selectTopSearchTableInfo();
List<TopSearchColumn> selectTableColumns(Long id);
/**
* 新增top万能查询主
*

View File

@ -9,7 +9,9 @@ import com.ebts.common.utils.DateUtils;
import com.ebts.common.utils.SecurityUtils;
import com.ebts.common.utils.DateUtils;
import com.ebts.common.utils.ServerResult;
import com.ebts.generator.dao.RelationalMapDao;
import com.ebts.generator.dao.SearchTableRoleDao;
import com.ebts.generator.entity.RelationalMap;
import com.ebts.generator.entity.SearchTableRole;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -37,6 +39,8 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
private TopSearchTableDao topSearchTableDao;
@Autowired
private SearchTableRoleDao searchTableRoleDao;
@Autowired
private RelationalMapDao relationalMapDao;
/**
* 查询top万能查询主
@ -86,6 +90,21 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
}
}
@Override
public ServerResult<List<TopSearchTable>> selectTopSearchTableInfo() {
try {
List<TopSearchTable> tableList = topSearchTableDao.selectTopSearchTableInfo();
return new ServerResult<>(true,tableList);
}catch (RuntimeException e){
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
}
public List<TopSearchColumn> selectTableColumns(Long id){
return topSearchTableDao.selectTableColumns(id);
}
/**
* 新增top万能查询主
*
@ -131,16 +150,25 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
for (Long roleId : topSearchTable.getRoleIds()) {
searchTableRoles.add(new SearchTableRole(topSearchTable.getId(),roleId));
}
relationalMapDao.deleteRelationalMapById(topSearchTable.getId());
List<RelationalMap> relationalMapList = topSearchTable.getRelationalMapList();
for (RelationalMap relationalMap : relationalMapList) {
relationalMap.setMainId(topSearchTable.getId());
}
boolean renewalMap = insertRelationalMap(relationalMapList);
searchTableRoleDao.deleteSearchTableRoleById(topSearchTable.getId());
boolean renewalRole = inserTopTableRole(searchTableRoles);
Integer renewal = topSearchTableDao.updateTopSearchTable(topSearchTable);
if (renewal >0 && renewalRole){
if (renewal >0 && renewalRole && renewalMap){
return new ServerResult<>(true,renewal);
}else {
return new ServerResult<>(false,ReturnConstants.OP_ERROR);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
e.printStackTrace();
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
}
@ -236,6 +264,15 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
}
return false;
}
public boolean insertRelationalMap(List<RelationalMap> relationalMaps){
if (StringUtils.isNotNull(relationalMaps)){
Integer renewal = relationalMapDao.batchRelationalMap(relationalMaps);
if (renewal>0){
return true;
}
}
return false;
}
/**
* 新增top万能查询字段信息

View File

@ -0,0 +1,82 @@
<?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.ebts.generator.dao.RelationalMapDao">
<resultMap type="com.ebts.generator.entity.RelationalMap" id="RelationalMapResult">
<result property="mainId" column="main_id" />
<result property="childId" column="child_id" />
<result property="mainKey" column="main_key" />
<result property="childKey" column="child_key" />
<result property="type" column="type" />
</resultMap>
<sql id="selectRelationalMapVo">
select main_id, child_id, main_key, child_key, type from gen_relational_mapping
</sql>
<select id="selectRelationalMapList" parameterType="RelationalMap" resultMap="RelationalMapResult">
<include refid="selectRelationalMapVo"/>
<where>
<if test="mainId != null "> and main_id = #{mainId}</if>
<if test="childId != null "> and child_id = #{childId}</if>
<if test="mainKey != null and mainKey != ''"> and main_key like concat('%', #{mainKey}, '%')</if>
<if test="childKey != null and childKey != ''"> and child_key like concat('%', #{childKey}, '%')</if>
<if test="type != null and type != ''"> and type = #{type}</if>
</where>
</select>
<select id="selectRelationalMapById" parameterType="Long" resultMap="RelationalMapResult">
<include refid="selectRelationalMapVo"/>
where main_id = #{mainId}
</select>
<insert id="insertRelationalMap" parameterType="RelationalMap">
insert into gen_relational_mapping
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="mainId != null">main_id,</if>
<if test="childId != null">child_id,</if>
<if test="mainKey != null">main_key,</if>
<if test="childKey != null">child_key,</if>
<if test="type != null">type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="mainId != null">#{mainId},</if>
<if test="childId != null">#{childId},</if>
<if test="mainKey != null">#{mainKey},</if>
<if test="childKey != null">#{childKey},</if>
<if test="type != null">#{type},</if>
</trim>
</insert>
<update id="updateRelationalMap" parameterType="RelationalMap">
update gen_relational_mapping
<trim prefix="SET" suffixOverrides=",">
<if test="childId != null">child_id = #{childId},</if>
<if test="mainKey != null">main_key = #{mainKey},</if>
<if test="childKey != null">child_key = #{childKey},</if>
<if test="type != null">type = #{type},</if>
</trim>
where main_id = #{mainId}
</update>
<delete id="deleteRelationalMapById" parameterType="Long">
delete from gen_relational_mapping where main_id = #{mainId}
</delete>
<delete id="deleteRelationalMapByIds" parameterType="String">
delete from gen_relational_mapping where main_id in
<foreach item="mainId" collection="array" open="(" separator="," close=")">
#{mainId}
</foreach>
</delete>
<insert id="batchRelationalMap">
insert into gen_relational_mapping(main_id, child_id, main_key, child_key, type) values
<foreach collection="list" index="index" item="item" separator=",">
(#{item.mainId},#{item.childId},#{item.mainKey},#{item.childKey},#{item.type})
</foreach>
</insert>
</mapper>

View File

@ -9,6 +9,14 @@
<result property="roleId" column="role_id" />
</resultMap>
<select id="selectSearchTableRoleList" parameterType="SearchTableRole" resultMap="SearchTableRoleResult">
select search_table_id, role_id from gen_search_table_role
<where>
<if test="searchTableId != null "> and search_table_id = #{searchTableId}</if>
<if test="roleId != null "> and role_id = #{roleId}</if>
</where>
</select>
<delete id="deleteSearchTableRoleById" parameterType="Long">
delete from gen_search_table_role where search_table_id = #{searchTableId}
</delete>

View File

@ -17,10 +17,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap id="TopSearchTableTopSearchColumnResult" type="com.ebts.generator.entity.TopSearchTable" extends="TopSearchTableResult">
<collection property="topSearchColumnList" notNullColumn="id" javaType="java.util.List" resultMap="TopSearchColumnResult" />
<collection property="relationalMapList" notNullColumn="id" javaType="java.util.List" resultMap="RelationalMappingResult" />
</resultMap>
<resultMap type="com.ebts.generator.entity.TopSearchColumn" id="TopSearchColumnResult">
<result property="id" column="id" />
<result property="id" column="column_id" />
<result property="searchTableId" column="search_table_id" />
<result property="columnName" column="column_name" />
<result property="columnComment" column="column_comment" />
@ -33,10 +34,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<resultMap type="com.ebts.generator.entity.RelationalMap" id="RelationalMappingResult">
<result property="mainId" column="main_id" />
<result property="childId" column="child_id" />
<result property="mainKey" column="main_key" />
<result property="childKey" column="child_key" />
<result property="type" column="type" />
</resultMap>
<sql id="selectTopSearchTableVo">
select id, table_name, table_comment, remark, create_by, create_time, update_by, update_time from gen_top_search_table
</sql>
<select id="selectTopSearchTableInfo" resultMap="TopSearchTableResult">
select id, table_name ,table_comment from gen_top_search_table where 1=1
</select>
<select id="selectTableColumns" resultMap="TopSearchColumnResult" parameterType="Long">
select column_name ,column_comment from gen_top_search_column where search_table_id = #{id}
</select>
<select id="selectTopSearchTableList" parameterType="TopSearchTable" resultMap="TopSearchTableResult">
<include refid="selectTopSearchTableVo"/>
@ -50,8 +70,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectTopSearchTableById" parameterType="Long" resultMap="TopSearchTableTopSearchColumnResult">
select gtst.id, gtst.table_name, gtst.table_comment, gtst.remark, gtst.create_by, gtst.create_time, gtst.update_by, gtst.update_time,
gtsc.id, gtsc.search_table_id, gtsc.column_name, gtsc.column_comment, gtsc.column_type, gtsc.is_use, gtsc.create_by, gtsc.create_time, gtsc.update_by, gtsc.update_time from gen_top_search_table gtst
gtsc.id as column_id, gtsc.search_table_id, gtsc.column_name, gtsc.column_comment, gtsc.column_type, gtsc.is_use, gtsc.create_by, gtsc.create_time, gtsc.update_by, gtsc.update_time,
grm.main_id, grm.child_id, grm.main_key, grm.child_key, grm.type
from gen_top_search_table gtst
left join gen_top_search_column gtsc on gtsc.search_table_id = gtst.id
left join gen_relational_mapping grm on grm.main_id = gtst.id
where gtst.id = #{id}
</select>