top维护管理

This commit is contained in:
clay 2021-07-21 01:27:03 +08:00
parent 136998c938
commit 8bc2ba9e1c
13 changed files with 1115 additions and 9 deletions

View File

@ -7,4 +7,4 @@ gen:
# 自动去除表前缀默认是false
autoRemovePre: true
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
tablePrefix: sys_,test_
tablePrefix: sys_,test_,gen_

View File

@ -0,0 +1,151 @@
package com.ebts.generator.controller;
import java.io.Serializable;
import java.util.List;
import com.ebts.common.core.controller.EBTSController;
import com.ebts.common.core.text.Convert;
import com.ebts.common.utils.ServerResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
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.ebts.common.annotation.Log;
import com.ebts.common.core.entity.AjaxResult;
import com.ebts.common.enums.BusinessType;
import com.ebts.generator.entity.TopSearchTable;
import com.ebts.generator.service.TopSearchTableService;
import com.ebts.common.utils.poi.ExcelUtil;
/**
* top万能查询主Controller
*
* @author clay
* @date 2021-07-20
*/
@RestController
@RequestMapping("/tool/table")
public class TopSearchTableController extends EBTSController {
protected final Logger logger = LoggerFactory.getLogger(TopSearchTableController.class);
@Autowired
private TopSearchTableService topSearchTableService;
/**
* 查询top万能查询主列表
*/
@PreAuthorize("@ebts.hasPermi('tool:table:list')")
@PostMapping("/list")
public Serializable list(@Validated @RequestBody TopSearchTable topSearchTable) {
startPage(topSearchTable.getPageInfo());
ServerResult<List<TopSearchTable>> genServerResult = topSearchTableService.selectTopSearchTableList(topSearchTable);
if (genServerResult.isStart()) {
return getDataTable(genServerResult.getData());
} else {
return AjaxResult.info(genServerResult.getMsg());
}
}
/**
* 导出top万能查询主列表
*/
@PreAuthorize("@ebts.hasPermi('tool:table:export')")
@Log(title = "top万能查询主", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public AjaxResult export(@Validated @RequestBody TopSearchTable topSearchTable) {
ServerResult<List<TopSearchTable>> genServerResult = topSearchTableService.selectTopSearchTableList(topSearchTable);
ExcelUtil<TopSearchTable> util = new ExcelUtil<TopSearchTable>(TopSearchTable. class);
if (genServerResult.isStart()) {
return util.exportExcel(genServerResult.getData(), "table");
} else {
return AjaxResult.error(genServerResult.getMsg());
}
}
/**
* 获取top万能查询主详细信息
*/
@PreAuthorize("@ebts.hasPermi('tool:table:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
ServerResult<TopSearchTable> genServerResult = topSearchTableService.selectTopSearchTableById(id);
if (genServerResult.isStart()) {
return AjaxResult.success(genServerResult.getData());
} else {
return AjaxResult.info(genServerResult.getMsg());
}
}
/**
* 新增top万能查询主
*/
@PreAuthorize("@ebts.hasPermi('tool:table:add')")
@Log(title = "top万能查询主", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody TopSearchTable topSearchTable) {
ServerResult<Integer> genServerResult = topSearchTableService.insertTopSearchTable(topSearchTable);
if (genServerResult.isStart()) {
return AjaxResult.success();
} else {
return AjaxResult.error(genServerResult.getMsg());
}
}
/**
* 修改top万能查询主
*/
@PreAuthorize("@ebts.hasPermi('tool:table:edit')")
@Log(title = "top万能查询主", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody TopSearchTable topSearchTable) {
ServerResult<Integer> genServerResult = topSearchTableService.updateTopSearchTable(topSearchTable);
if (genServerResult.isStart()) {
return AjaxResult.success();
} else {
return AjaxResult.error(genServerResult.getMsg());
}
}
/**
* 删除top万能查询主
*/
@PreAuthorize("@ebts.hasPermi('tool:table:remove')")
@Log(title = "top万能查询主", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
if (ids.length<0){
return AjaxResult.error("id不能为空!");
}
ServerResult<Integer> genServerResult = topSearchTableService.deleteTopSearchTableByIds(ids);
if (genServerResult.isStart()) {
return AjaxResult.success();
} else {
return AjaxResult.error(genServerResult.getMsg());
}
}
/**
* 导入表结构保存
*/
@PreAuthorize("@ebts.hasPermi('tool:gen:list')")
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
@PostMapping("/importTopTable")
public AjaxResult importTableSave(String tables) {
String[] tableNames = Convert.toStrArray(tables);
// 查询表信息
List<TopSearchTable> tableList = topSearchTableService.selectDbTableListByNames(tableNames);
topSearchTableService.importGenTable(tableList);
return AjaxResult.success();
}
}

View File

@ -0,0 +1,70 @@
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;
/**
* top万能查询角色关系Mapper接口
*
* @author clay
* @date 2021-07-21
*/
public interface SearchTableRoleDao {
/**
* 查询top万能查询角色关系
*
* @param searchTableId top万能查询角色关系ID
* @return top万能查询角色关系
*/
SearchTableRole selectSearchTableRoleById(Long searchTableId);
/**
* 查询top万能查询角色关系列表
*
* @param searchTableRole top万能查询角色关系
* @return top万能查询角色关系集合
*/
List<SearchTableRole> selectSearchTableRoleList(SearchTableRole searchTableRole);
/**
* 新增top万能查询角色关系
*
* @param searchTableRole top万能查询角色关系
* @return 结果
*/
int insertSearchTableRole(SearchTableRole searchTableRole);
/**
* 修改top万能查询角色关系
*
* @param searchTableRole top万能查询角色关系
* @return 结果
*/
int updateSearchTableRole(SearchTableRole searchTableRole);
/**
* 删除top万能查询角色关系
*
* @param searchTableId top万能查询角色关系ID
* @return 结果
*/
int deleteSearchTableRoleById(Long searchTableId);
/**
* 批量删除top万能查询角色关系
*
* @param searchTableIds 需要删除的数据ID
* @return 结果
*/
int deleteSearchTableRoleByIds(Long[] searchTableIds);
int batchSearchTableRole(List<SearchTableRole> roleList);
}

View File

@ -0,0 +1,97 @@
package com.ebts.generator.dao;
import java.util.List;
import com.ebts.generator.entity.TopSearchTable;
import com.ebts.generator.entity.TopSearchColumn;
/**
* top万能查询主Mapper接口
*
* @author clay
* @date 2021-07-20
*/
public interface TopSearchTableDao {
/**
* 查询top万能查询主
*
* @param id top万能查询主ID
* @return top万能查询主
*/
TopSearchTable selectTopSearchTableById(Long id);
/**
* 查询top万能查询主列表
*
* @param topSearchTable top万能查询主
* @return top万能查询主集合
*/
List<TopSearchTable> selectTopSearchTableList(TopSearchTable topSearchTable);
/**
* 查询据库列表
*
* @param tableNames 表名称组
* @return 数据库表集合
*/
List<TopSearchTable> selectDbTableListByNames(String[] tableNames);
List<TopSearchColumn> selectDbTableColumnsByName(String tableName);
/**
* 新增top万能查询主
*
* @param topSearchTable top万能查询主
* @return 结果
*/
int insertTopSearchTable(TopSearchTable topSearchTable);
/**
* 修改top万能查询主
*
* @param topSearchTable top万能查询主
* @return 结果
*/
int updateTopSearchTable(TopSearchTable topSearchTable);
/**
* 删除top万能查询主
*
* @param id top万能查询主ID
* @return 结果
*/
int deleteTopSearchTableById(Long id);
/**
* 批量删除top万能查询主
*
* @param ids 需要删除的数据ID
* @return 结果
*/
int deleteTopSearchTableByIds(Long[] ids);
/**
* 批量删除top万能查询字段
*
* @param ids 需要删除的数据ID
* @return 结果
*/
int deleteTopSearchColumnBySearchTableIds(Long[] ids);
/**
* 批量新增top万能查询字段
*
* @param topSearchColumnList top万能查询字段列表
* @return 结果
*/
int batchTopSearchColumn(List<TopSearchColumn> topSearchColumnList);
/**
* 通过top万能查询主ID删除top万能查询字段信息
*
* @param id top万能查询主ID
* @return 结果
*/
int deleteTopSearchColumnBySearchTableId(Long id);
}

View File

@ -0,0 +1,61 @@
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;
/**
* top万能查询角色关系对象 gen_search_table_role
*
* @author clay
* @date 2021-07-21
*/
public class SearchTableRole extends BaseEntity{
/** 表格id */
private Long searchTableId;
/** 角色id */
private Long roleId;
public SearchTableRole(Long searchTableId, Long roleId) {
this.searchTableId = searchTableId;
this.roleId = roleId;
}
public SearchTableRole() {
}
public void setSearchTableId(Long searchTableId){
this.searchTableId = searchTableId;
}
public Long getSearchTableId(){
return searchTableId;
}
public void setRoleId(Long roleId){
this.roleId = roleId;
}
public Long getRoleId(){
return roleId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("searchTableId", getSearchTableId())
.append("roleId", getRoleId())
.toString();
}
}

View File

@ -0,0 +1,111 @@
package com.ebts.generator.entity;
import com.ebts.common.annotation.Excel;
import com.ebts.common.core.entity.BaseEntity;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
/**
* top万能查询字段对象 gen_top_search_column
*
* @author clay
* @date 2021-07-20
*/
public class TopSearchColumn extends BaseEntity{
/** 主键id */
private Long id;
/** top万能查询表格主键id */
@Excel(name = "top万能查询表格主键id")
private Long searchTableId;
/** 列名称 */
@Excel(name = "列名称")
private String columnName;
/** 列描述 */
@Excel(name = "列描述")
private String columnComment;
/** 列类型 */
@Excel(name = "列类型")
private String columnType;
/** 是否使用 */
@Excel(name = "是否使用")
private Integer isUse;
private Integer isPk;
private Integer sort;
public Integer getSort() {
return sort;
}
public Integer getIsPk() {
return isPk;
}
public void setIsPk(Integer isPk) {
this.isPk = isPk;
}
public void setId(Long id){
this.id = id;
}
public Long getId(){
return id;
}
public void setSearchTableId(Long searchTableId){
this.searchTableId = searchTableId;
}
public Long getSearchTableId(){
return searchTableId;
}
public void setColumnName(String columnName){
this.columnName = columnName;
}
public String getColumnName(){
return columnName;
}
public void setColumnComment(String columnComment){
this.columnComment = columnComment;
}
public String getColumnComment(){
return columnComment;
}
public void setColumnType(String columnType){
this.columnType = columnType;
}
public String getColumnType(){
return columnType;
}
public void setIsUse(Integer isUse){
this.isUse = isUse;
}
public Integer getIsUse(){
return isUse;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("searchTableId", getSearchTableId())
.append("columnName", getColumnName())
.append("columnComment", getColumnComment())
.append("columnType", getColumnType())
.append("isUse", getIsUse())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,91 @@
package com.ebts.generator.entity;
import java.util.List;
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;
/**
* top万能查询主对象 gen_top_search_table
*
* @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;
public Long[] getRoleIds() {
return roleIds;
}
public void setRoleIds(Long[] roleIds) {
this.roleIds = roleIds;
}
public void setId(Long id){
this.id = id;
}
public Long getId(){
return id;
}
public void setTableName(String tableName){
this.tableName = tableName;
}
public String getTableName(){
return tableName;
}
public void setTableComment(String tableComment){
this.tableComment = tableComment;
}
public String getTableComment(){
return tableComment;
}
public List<TopSearchColumn> getTopSearchColumnList(){
return topSearchColumnList;
}
public void setTopSearchColumnList(List<TopSearchColumn> topSearchColumnList){
this.topSearchColumnList = topSearchColumnList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("tableName", getTableName())
.append("tableComment", getTableComment())
.append("remark", getRemark())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("topSearchColumnList", getTopSearchColumnList())
.toString();
}
}

View File

@ -0,0 +1,67 @@
package com.ebts.generator.service;
import java.util.List;
import com.ebts.common.utils.ServerResult;
import com.ebts.generator.entity.TopSearchTable;
/**
* top万能查询主Service接口
*
* @author clay
* @date 2021-07-20
*/
public interface TopSearchTableService
{
/**
* 查询top万能查询主
*
* @param id top万能查询主ID
* @return top万能查询主
*/
ServerResult<TopSearchTable> selectTopSearchTableById(Long id);
/**
* 查询top万能查询主列表
*
* @param topSearchTable top万能查询主
* @return top万能查询主集合
*/
ServerResult<List<TopSearchTable>> selectTopSearchTableList(TopSearchTable topSearchTable);
/**
* 新增top万能查询主
*
* @param topSearchTable top万能查询主
* @return 结果
*/
ServerResult<Integer> insertTopSearchTable(TopSearchTable topSearchTable);
/**
* 修改top万能查询主
*
* @param topSearchTable top万能查询主
* @return 结果
*/
ServerResult<Integer> updateTopSearchTable(TopSearchTable topSearchTable);
List<TopSearchTable> selectDbTableListByNames(String[] tableNames);
void importGenTable(List<TopSearchTable> tableList);
/**
* 批量删除top万能查询主
*
* @param ids 需要删除的top万能查询主ID
* @return 结果
*/
ServerResult<Integer> deleteTopSearchTableByIds(Long[] ids);
/**
* 删除top万能查询主信息
*
* @param id top万能查询主ID
* @return 结果
*/
ServerResult<Integer> deleteTopSearchTableById(Long id);
}

View File

@ -0,0 +1,263 @@
package com.ebts.generator.service.impl;
import java.util.List;
import com.ebts.common.constant.ReturnConstants;
import com.ebts.common.exception.EbtsException;
import com.ebts.common.utils.SecurityUtils;
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.SearchTableRoleDao;
import com.ebts.generator.entity.SearchTableRole;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import com.ebts.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.ebts.generator.entity.TopSearchColumn;
import com.ebts.generator.dao.TopSearchTableDao;
import com.ebts.generator.entity.TopSearchTable;
import com.ebts.generator.service.TopSearchTableService;
/**
* top万能查询主Service业务层处理
*
* @author clay
* @date 2021-07-20
*/
@Service
public class TopSearchTableServiceImpl implements TopSearchTableService {
private Logger logger = LoggerFactory.getLogger(TopSearchTableServiceImpl.class);
@Autowired
private TopSearchTableDao topSearchTableDao;
@Autowired
private SearchTableRoleDao searchTableRoleDao;
/**
* 查询top万能查询主
*
* @param id top万能查询主ID
* @return top万能查询主
*/
@Override
public ServerResult<TopSearchTable> selectTopSearchTableById(Long id) {
try {
TopSearchTable topSearchTable = topSearchTableDao.selectTopSearchTableById(id);
List<SearchTableRole> roleList = searchTableRoleDao.selectSearchTableRoleList(new SearchTableRole());
Long[] roles = new Long[roleList.size()] ;
for (int i = 0; i < roleList.size(); i++) {
roles[i] = roleList.get(i).getRoleId();
}
topSearchTable.setRoleIds(roles);
if (topSearchTable != null){
return new ServerResult<>(true,topSearchTable);
}else {
return new ServerResult<>(false, ReturnConstants.RESULT_EMPTY);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
}
/**
* 查询top万能查询主列表
*
* @param topSearchTable top万能查询主
* @return top万能查询主
*/
@Override
public ServerResult<List<TopSearchTable>> selectTopSearchTableList(TopSearchTable topSearchTable) {
try {
List<TopSearchTable> topSearchTableList = topSearchTableDao.selectTopSearchTableList(topSearchTable);
if (topSearchTableList.size()>0){
return new ServerResult<>(true,topSearchTableList);
}else {
return new ServerResult<>(false,ReturnConstants.RESULT_EMPTY);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
}
/**
* 新增top万能查询主
*
* @param topSearchTable top万能查询主
* @return 结果
*/
@Transactional
@Override
public ServerResult<Integer> insertTopSearchTable(TopSearchTable topSearchTable) {
try {
topSearchTable.setCreateBy(SecurityUtils.getUserId());
int renewal = topSearchTableDao.insertTopSearchTable(topSearchTable);
if (insertTopSearchColumn(topSearchTable)){
return new ServerResult<>(false,ReturnConstants.DB_EX);
}
if (renewal >0){
return new ServerResult<>(true,renewal);
}else {
return new ServerResult<>(false,ReturnConstants.SYS_FAILL);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
}
/**
* 修改top万能查询主
*
* @param topSearchTable top万能查询主
* @return 结果
*/
@Transactional
@Override
public ServerResult<Integer> updateTopSearchTable(TopSearchTable topSearchTable) {
try {
topSearchTable.setUpdateBy(SecurityUtils.getUserId());
topSearchTableDao.deleteTopSearchColumnBySearchTableId(topSearchTable.getId());
if (insertTopSearchColumn(topSearchTable)){
return new ServerResult<>(false,ReturnConstants.DB_EX);
}
List<SearchTableRole> searchTableRoles = new ArrayList<>();
for (Long roleId : topSearchTable.getRoleIds()) {
searchTableRoles.add(new SearchTableRole(topSearchTable.getId(),roleId));
}
boolean renewalRole = inserTopTableRole(searchTableRoles);
Integer renewal = topSearchTableDao.updateTopSearchTable(topSearchTable);
if (renewal >0 && renewalRole){
return new ServerResult<>(true,renewal);
}else {
return new ServerResult<>(false,ReturnConstants.OP_ERROR);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
}
@Override
public List<TopSearchTable> selectDbTableListByNames(String[] tableNames) {
try {
return topSearchTableDao.selectDbTableListByNames(tableNames);
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void importGenTable(List<TopSearchTable> tableList) {
try {
Long createBy = SecurityUtils.getUserId();
for (TopSearchTable table : tableList) {
String tableName = table.getTableName();
table.setCreateBy(createBy);
int row = topSearchTableDao.insertTopSearchTable(table);
if (row>0){
List<TopSearchColumn> searchColumns = topSearchTableDao.selectDbTableColumnsByName(tableName);
for (TopSearchColumn searchColumn : searchColumns) {
searchColumn.setSearchTableId(table.getId());
}
if (searchColumns.size() > 0) {
topSearchTableDao.batchTopSearchColumn(searchColumns);
}
}
}
}catch (RuntimeException e){
logger.error(e.getMessage());
throw new EbtsException("导入失败:" + e.getMessage(),e);
}
}
/**
* 批量删除top万能查询主
*
* @param ids 需要删除的top万能查询主ID
* @return 结果
*/
@Transactional
@Override
public ServerResult<Integer> deleteTopSearchTableByIds(Long[] ids) {
try {
//批量删除子表数据
topSearchTableDao.deleteTopSearchColumnBySearchTableIds(ids);
Integer renewal = topSearchTableDao.deleteTopSearchTableByIds(ids);
if (renewal >0){
return new ServerResult<>(true,renewal);
}else {
return new ServerResult<>(false,ReturnConstants.SYS_FAILL);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
}
/**
* 删除top万能查询主信息
*
* @param id top万能查询主ID
* @return 结果
*/
@Override
public ServerResult<Integer> deleteTopSearchTableById(Long id) {
try {
//删除子表数据
topSearchTableDao.deleteTopSearchColumnBySearchTableId(id);
Integer renewal = topSearchTableDao.deleteTopSearchTableById(id);
if (renewal >0){
return new ServerResult<>(true,renewal);
}else {
return new ServerResult<>(false,ReturnConstants.SYS_FAILL);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
}
public boolean inserTopTableRole(List<SearchTableRole> roleList){
if (StringUtils.isNotNull(roleList)){
Integer renewal = searchTableRoleDao.batchSearchTableRole(roleList);
if (renewal>0){
return true;
}
}
return false;
}
/**
* 新增top万能查询字段信息
*
* @param topSearchTable top万能查询主对象
*/
public boolean insertTopSearchColumn(TopSearchTable topSearchTable) {
List<TopSearchColumn> topSearchColumnList = topSearchTable.getTopSearchColumnList();
Long id = topSearchTable.getId();
if (StringUtils.isNotNull(topSearchColumnList)) {
List<TopSearchColumn> list = new ArrayList<TopSearchColumn>();
for (TopSearchColumn topSearchColumn : topSearchColumnList){
topSearchColumn.setSearchTableId(id);
list.add(topSearchColumn);
}
if (list.size() > 0) {
Integer renewal = topSearchTableDao.batchTopSearchColumn(list);
if (renewal>0){
return false;
}
}
}
return true;
}
}

View File

@ -81,11 +81,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</where>
</select>
<!--AND table_name NOT LIKE 'gen_%'-->
<select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables
where table_schema = (select database())
AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%'
AND table_name NOT LIKE 'qrtz_%'
AND table_name NOT IN (select table_name from gen_table)
<if test="tableName != null and tableName != ''">
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
@ -100,11 +101,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
</select>
<!-- AND table_name NOT LIKE 'gen_%' -->
<select id="selectDbTableListByNames" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables
where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
and table_name in
where table_name NOT LIKE 'qrtz_%'
AND table_schema = (select database())
AND table_name in
<foreach collection="array" item="name" open="(" separator="," close=")">
#{name}
</foreach>
@ -112,8 +115,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables
where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
and table_name = #{tableName}
where table_comment <![CDATA[ <> ]]> '' AND table_schema = (select database())
AND table_name = #{tableName}
</select>
<!--todo 获取表信息 预览代码使用-->

View File

@ -0,0 +1,65 @@
<?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.SearchTableRoleDao">
<resultMap type="com.ebts.generator.entity.SearchTableRole" id="SearchTableRoleResult">
<result property="searchTableId" column="search_table_id" />
<result property="roleId" column="role_id" />
</resultMap>
<sql id="selectSearchTableRoleVo">
select search_table_id, role_id from gen_search_table_role
</sql>
<select id="selectSearchTableRoleList" parameterType="SearchTableRole" resultMap="SearchTableRoleResult">
<include refid="selectSearchTableRoleVo"/>
<where>
<if test="searchTableId != null "> and search_table_id = #{searchTableId}</if>
<if test="roleId != null "> and role_id = #{roleId}</if>
</where>
</select>
<select id="selectSearchTableRoleById" parameterType="Long" resultMap="SearchTableRoleResult">
<include refid="selectSearchTableRoleVo"/>
where search_table_id = #{searchTableId}
</select>
<insert id="insertSearchTableRole" parameterType="SearchTableRole">
insert into gen_search_table_role
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="searchTableId != null">search_table_id,</if>
<if test="roleId != null">role_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="searchTableId != null">#{searchTableId},</if>
<if test="roleId != null">#{roleId},</if>
</trim>
</insert>
<update id="updateSearchTableRole" parameterType="SearchTableRole">
update gen_search_table_role
<trim prefix="SET" suffixOverrides=",">
<if test="roleId != null">role_id = #{roleId},</if>
</trim>
where search_table_id = #{searchTableId}
</update>
<delete id="deleteSearchTableRoleById" parameterType="Long">
delete from gen_search_table_role where search_table_id = #{searchTableId}
</delete>
<delete id="deleteSearchTableRoleByIds" parameterType="String">
delete from gen_search_table_role where search_table_id in
<foreach item="searchTableId" collection="array" open="(" separator="," close=")">
#{searchTableId}
</foreach>
</delete>
<insert id="batchSearchTableRole">
insert into gen_search_table_role (search_table_id, role_id) values
<foreach collection="list" separator="," item="item" index="index">
(#{item.searchTableId},#{item.roleId})
</foreach>
</insert>
</mapper>

View File

@ -0,0 +1,127 @@
<?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.TopSearchTableDao">
<resultMap type="com.ebts.generator.entity.TopSearchTable" id="TopSearchTableResult">
<result property="id" column="id" />
<result property="tableName" column="table_name" />
<result property="tableComment" column="table_comment" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<resultMap id="TopSearchTableTopSearchColumnResult" type="com.ebts.generator.entity.TopSearchTable" extends="TopSearchTableResult">
<collection property="topSearchColumnList" notNullColumn="id" javaType="java.util.List" resultMap="TopSearchColumnResult" />
</resultMap>
<resultMap type="com.ebts.generator.entity.TopSearchColumn" id="TopSearchColumnResult">
<result property="id" column="id" />
<result property="searchTableId" column="search_table_id" />
<result property="columnName" column="column_name" />
<result property="columnComment" column="column_comment" />
<result property="columnType" column="column_type" />
<result property="isPk" column="is_pk" />
<result property="isUse" column="is_use" />
<result property="sort" column="sort" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</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="selectTopSearchTableList" parameterType="TopSearchTable" resultMap="TopSearchTableResult">
<include refid="selectTopSearchTableVo"/>
<where>
<if test="tableName != null and tableName != ''"> and table_name like concat('%', #{tableName}, '%')</if>
<if test="tableComment != null and tableComment != ''"> and table_comment like concat('%', #{tableComment}, '%')</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
<if test="params.beginUpdateTime != null and params.beginUpdateTime != '' and params.endUpdateTime != null and params.endUpdateTime != ''"> and update_time between #{params.beginUpdateTime} and #{params.endUpdateTime}</if>
</where>
</select>
<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
left join gen_top_search_column gtsc on gtsc.search_table_id = gtst.id
where gtst.id = #{id}
</select>
<select id="selectDbTableListByNames" resultMap="TopSearchTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables
where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
and table_name in
<foreach collection="array" item="name" open="(" separator="," close=")">
#{name}
</foreach>
</select>
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="TopSearchColumnResult">
select column_name, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, column_type
from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName})
order by ordinal_position
</select>
<insert id="insertTopSearchTable" parameterType="TopSearchTable" useGeneratedKeys="true" keyProperty="id">
insert into gen_top_search_table
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tableName != null">table_name,</if>
<if test="tableComment != null">table_comment,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tableName != null">#{tableName},</if>
<if test="tableComment != null">#{tableComment},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
</trim>
</insert>
<update id="updateTopSearchTable" parameterType="TopSearchTable">
update gen_top_search_table
<trim prefix="SET" suffixOverrides=",">
<if test="tableName != null">table_name = #{tableName},</if>
<if test="tableComment != null">table_comment = #{tableComment},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteTopSearchTableById" parameterType="Long">
delete from gen_top_search_table where id = #{id}
</delete>
<delete id="deleteTopSearchTableByIds" parameterType="String">
delete from gen_top_search_table where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteTopSearchColumnBySearchTableIds" parameterType="String">
delete from gen_top_search_column where search_table_id in
<foreach item="searchTableId" collection="array" open="(" separator="," close=")">
#{searchTableId}
</foreach>
</delete>
<delete id="deleteTopSearchColumnBySearchTableId" parameterType="Long">
delete from gen_top_search_column where search_table_id = #{searchTableId}
</delete>
<insert id="batchTopSearchColumn">
insert into gen_top_search_column(search_table_id,column_name,column_comment,column_type,is_use,create_by,create_time,update_by,update_time) values
<foreach item="item" index="index" collection="list" separator=",">
(#{item.searchTableId},#{item.columnName},#{item.columnComment},#{item.columnType},#{item.isUse},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime})
</foreach>
</insert>
</mapper>

View File

@ -185,7 +185,7 @@
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" type="index" align="center">
<template slot-scope="scope">
<span>{{ ((queryParams.pageInfo.pageNum - 1) * queryParams.pageInfo.pageSize + scope.$index + 1)}}</span>
<span>{{ ((queryParams.pageInfo.pageNum - 1) * queryParams.pageInfo.pageSize + scope.$ index + 1)}}</span>
</template>
</el-table-column>
#foreach($column in $columns)