This commit is contained in:
20932067@zju.edu.cn 2021-02-02 23:54:24 +08:00
parent ff0fcf36c0
commit fea4dc4540
53 changed files with 503 additions and 129 deletions

View File

@ -3,8 +3,8 @@ ENV = 'development'
# 宏驰云管理系统/开发环境
#VUE_APP_BASE_API = '/dev-api'
#VUE_APP_BASE_API = 'http://localhost:8085/dev-api'
VUE_APP_BASE_API = 'http://apibase.hchyun.com/dev-api'
VUE_APP_BASE_API = 'http://localhost:8085/dev-api'
#VUE_APP_BASE_API = 'http://apibase.hchyun.com/dev-api'
# 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true

View File

@ -76,3 +76,19 @@ export function previewQueryData(data) {
data: data
})
}
// 获取查询基本信息
export function getRealInfo(id){
return request({
url: "/query/real/"+id,
method: 'get',
})
}
// 查询数据
export function getRealData(data){
return request({
url: "/query/real",
method: 'put',
data:data
})
}

View File

@ -129,7 +129,13 @@ export const constantRoutes = [
component: (resolve) => require(['@/views/tool/query/uniQuery'], resolve),
name: 'UniQuery',
meta: { title: '万能查询配置' }
}
},
// {
// path: 'data/:dataId(\\d+)',
// component: (resolve) => require(['@/views/tool/query/queryDate'], resolve),
// name: 'QueryDate',
// meta: { title: '信息统计' }
// }
]
},
{

View File

@ -0,0 +1,131 @@
<template>
<div class="app-container">
<el-form ref="ucon" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item v-for="item in uconList"
:key="item.id"
:label="item.ucName">
<el-input v-model="item.ucReal"
clearable
:placeholder="outPlaceholder(item)"
size="small"
@keyup.enter.native="handleQuery"
/>
</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="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['tool:query:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="handleQuery"></right-toolbar>
</el-row>
<el-table :data="realDate.data">
<el-table-column v-for="item in realDate.header"
:label="item"
align="center"
:key="item"
:prop="item"/>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="handleQuery"
/>
</div>
</template>
<script>
import {getRealInfo, getRealData} from "@/api/tool/query"
export default {
name: "queryDate",
data() {
return {
dataId: null,
uconList: [],
showSearch: true,
realDate: {
data: [],
header: [],
},
total: 0,
queryParams: {
pageNum: 1,
pageSize: 10,
},
}
},
created() {
this.dataId = this.$route.fullPath.split("/")[3]
getRealInfo(this.dataId).then(res => {
this.uconList = res.data
})
this.handleQuery()
},
methods: {
outPlaceholder(item) {
return "请输入" + item.ucName
},
/**
* 重置
*/
resetQuery() {
for (let i = 0; this.uconList.length; i++) {
this.uconList[i].ucReal = null
}
},
/**
* 搜索
*/
handleQuery() {
let data = {
id: this.dataId,
pageNum: this.queryParams.pageNum,
pageSize: this.queryParams.pageSize,
}
let list = this.uconList
data.uniCons = list
getRealData(data).then(res => {
this.realDate.data = res.rows
this.total = res.total
this.realDate.header = []
for (var key in this.realDate.data[0]) {
this.realDate.header.push(key)
}
console.log(res)
})
console.log(5)
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有万能查询数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
// return exportQuery(queryParams);
}).then(response => {
this.download(response.msg);
})
}
}
}
</script>
<style scoped>
</style>

View File

@ -160,6 +160,7 @@ import {Message} from "element-ui";
function JSONString(list) {
for (let i = 0; i < list.length; i++) {
if (list[i].type == 2) {
list[i].ucMock = JSON.stringify(list[i].ucMock)
} else if (list[i].type == 4) {
@ -193,7 +194,7 @@ export default {
tableHeight: document.documentElement.scrollHeight - 245 + "px",
//
cloumns: [],
sqlconfig:{
sqlconfig: {
//
mode: 'sql',
//
@ -204,8 +205,8 @@ export default {
tabSize: 4,
// JS
theme: 'idea',
spellcheck:true,
cursorHeight:0.85,
spellcheck: true,
cursorHeight: 0.85,
//
lineNumbers: true,
line: true,
@ -248,12 +249,48 @@ export default {
this.sqlconfig.coder.setValue(this.info.uqSql)
})
this.$nextTick(function () {
this._initialize();
this.initialize();
});
},
mounted() {
},
methods: {
changUniCon(list) {
console.log(list[0])
console.log(list.length)
for (let i = 0; i < list.length; i++) {
console.log(list[0].ucName)
if (list[i].ucName == "") {
Message({
message: "序号" + i + "查询名称不能为空!",
type: 'error'
})
return false;
}
if (list[i].ucDescribe == "") {
Message({
message: "序号" + i + "描述不能为空!",
type: 'error'
})
return false;
}
if (list[i].ucKey == "") {
Message({
message: "序号" + i + "key不能为空!",
type: 'error'
})
return false;
}
if (list[i].ucMock == "") {
Message({
message: "序号" + i + "模拟数据不能为空!",
type: 'error'
})
return false;
}
}
return true
},
/** 预览 */
previewQuery() {
this.$refs['elForm'].validate(valid => {
@ -261,7 +298,11 @@ export default {
let list = JSONString(this.cloumns)
let data = this.info
if (list.length > 0) {
data.uniCons = list
if (this.changUniCon(list)) {
data.uniCons = list
} else {
return
}
}
data.pageNum = this.queryParams.pageNum
data.pageSize = this.queryParams.pageSize
@ -275,21 +316,18 @@ export default {
this.previewDate.open = true
this.cloumns = JSONparse(list)
})
} else {
return
}
})
},
sqlChang(){
sqlChang() {
console.log(this.sqlconfig.coder.getValue())
},
_initialize() {
initialize() {
//
this.sqlconfig.coder = CodeMirror.fromTextArea(this.$refs.textarea, this.sqlconfig.options)
//
this.sqlconfig.coder.setValue(this.info.uqSql)
console.log(this.sqlconfig.coder.cm.defaultCharWidth(1))
//
//
this.sqlconfig.coder.on('change', (coder) => {
this.info.uqSql = coder.getValue()
console.log(this.info.uqSql)
@ -367,11 +405,13 @@ export default {
border: 1px solid #DCDFE6;
height: 150px;
}
.CodeMirror-line{
.CodeMirror-line {
height: 20px;
line-height: 20px !important;
}
.CodeMirror-linenumber{
.CodeMirror-linenumber {
height: 20px;
line-height: 20px !important;
}

View File

@ -22,4 +22,6 @@ public class ReturnConstants {
* 接口为空
*/
public static final String INTER_NULL = "该类下接口数据为空,请先添加接口!";
public static final String STATE_ERROR = "状态错错误!";
}

View File

@ -11,7 +11,7 @@ import com.hchyun.common.utils.StringUtils;
* @author hchyun
*/
public class AjaxResult extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
/**
* 状态码

View File

@ -15,7 +15,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
* @author hchyun
*/
public class BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 搜索值

View File

@ -10,7 +10,7 @@ import java.util.List;
*/
public class TreeEntity extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 父菜单名称 */
private String parentName;

View File

@ -14,7 +14,7 @@ import com.hchyun.common.core.entity.entity.SysMenu;
*/
public class TreeSelect implements Serializable
{
private static final long serialVersionUID = 1L;
/** 节点ID */
private Long id;

View File

@ -16,7 +16,7 @@ import com.hchyun.common.core.entity.BaseEntity;
*/
public class SysDept extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 部门ID */
private Long deptId;

View File

@ -16,7 +16,7 @@ import com.hchyun.common.core.entity.BaseEntity;
*/
public class SysDictData extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 字典编码 */
@Excel(name = "字典编码", cellType = ColumnType.NUMERIC)

View File

@ -15,7 +15,7 @@ import com.hchyun.common.core.entity.BaseEntity;
*/
public class SysDictType extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 字典主键 */
@Excel(name = "字典主键", cellType = ColumnType.NUMERIC)

View File

@ -15,7 +15,7 @@ import com.hchyun.common.core.entity.BaseEntity;
* @author hchyun
*/
public class SysMenu extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 菜单ID

View File

@ -15,7 +15,7 @@ import com.hchyun.common.core.entity.BaseEntity;
*/
public class SysRole extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 角色ID */
@Excel(name = "角色序号", cellType = ColumnType.NUMERIC)

View File

@ -22,7 +22,7 @@ import com.hchyun.common.core.entity.BaseEntity;
*/
public class SysUser extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 用户ID */
@Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")

View File

@ -14,7 +14,7 @@ import com.hchyun.common.core.entity.entity.SysUser;
*/
public class LoginUser implements UserDetails
{
private static final long serialVersionUID = 1L;
/**
* 用户唯一标识

View File

@ -10,7 +10,7 @@ import java.util.List;
*/
public class TableDataInfo implements Serializable
{
private static final long serialVersionUID = 1L;
/** 总记录数 */
private long total;

View File

@ -10,7 +10,7 @@ import com.hchyun.common.utils.StringUtils;
*/
public class BaseException extends RuntimeException
{
private static final long serialVersionUID = 1L;
/**
* 所属模块

View File

@ -7,7 +7,7 @@ package com.hchyun.common.exception;
*/
public class CustomException extends RuntimeException
{
private static final long serialVersionUID = 1L;
private Integer code;

View File

@ -7,7 +7,7 @@ package com.hchyun.common.exception;
*/
public class DemoModeException extends RuntimeException
{
private static final long serialVersionUID = 1L;
public DemoModeException()
{

View File

@ -9,7 +9,7 @@ import com.hchyun.common.exception.BaseException;
*/
public class FileException extends BaseException
{
private static final long serialVersionUID = 1L;
public FileException(String code, Object[] args)
{

View File

@ -7,7 +7,7 @@ package com.hchyun.common.exception.file;
*/
public class FileNameLengthLimitExceededException extends FileException
{
private static final long serialVersionUID = 1L;
public FileNameLengthLimitExceededException(int defaultFileNameLength)
{

View File

@ -7,7 +7,7 @@ package com.hchyun.common.exception.file;
*/
public class FileSizeLimitExceededException extends FileException
{
private static final long serialVersionUID = 1L;
public FileSizeLimitExceededException(long defaultMaxSize)
{

View File

@ -10,7 +10,7 @@ import org.apache.commons.fileupload.FileUploadException;
*/
public class InvalidExtensionException extends FileUploadException
{
private static final long serialVersionUID = 1L;
private String[] allowedExtension;
private String extension;
@ -41,7 +41,7 @@ public class InvalidExtensionException extends FileUploadException
public static class InvalidImageExtensionException extends InvalidExtensionException
{
private static final long serialVersionUID = 1L;
public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename)
{
@ -51,7 +51,7 @@ public class InvalidExtensionException extends FileUploadException
public static class InvalidFlashExtensionException extends InvalidExtensionException
{
private static final long serialVersionUID = 1L;
public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename)
{
@ -61,7 +61,7 @@ public class InvalidExtensionException extends FileUploadException
public static class InvalidMediaExtensionException extends InvalidExtensionException
{
private static final long serialVersionUID = 1L;
public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename)
{

View File

@ -7,7 +7,7 @@ package com.hchyun.common.exception.job;
*/
public class TaskException extends Exception
{
private static final long serialVersionUID = 1L;
private Code code;

View File

@ -7,7 +7,7 @@ package com.hchyun.common.exception.user;
*/
public class CaptchaException extends UserException
{
private static final long serialVersionUID = 1L;
public CaptchaException()
{

View File

@ -7,7 +7,7 @@ package com.hchyun.common.exception.user;
*/
public class CaptchaExpireException extends UserException
{
private static final long serialVersionUID = 1L;
public CaptchaExpireException()
{

View File

@ -9,7 +9,7 @@ import com.hchyun.common.exception.BaseException;
*/
public class UserException extends BaseException
{
private static final long serialVersionUID = 1L;
public UserException(String code, Object[] args)
{

View File

@ -7,7 +7,7 @@ package com.hchyun.common.exception.user;
*/
public class UserPasswordNotMatchException extends UserException
{
private static final long serialVersionUID = 1L;
public UserPasswordNotMatchException()
{

View File

@ -13,6 +13,9 @@ import com.hchyun.common.utils.sql.SqlUtil;
import com.hchyun.generator.entity.UniCon;
import com.hchyun.generator.entity.UniQuery;
import com.hchyun.generator.service.QueryService;
import com.hchyun.generator.service.UniQueryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -32,28 +35,46 @@ import java.util.Map;
* @Version 1.0
*/
@RestController
@Api("query")
@RequestMapping("/query")
public class QueryController extends BaseController {
protected final Logger logger = LoggerFactory.getLogger(QueryController.class);
@Autowired
private QueryService queryService;
@Autowired
private UniQueryService uniQueryService;
@PreAuthorize("@ss.hasPermi('query:list')")
@GetMapping("/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id){
@ApiOperation("获取查询基本信息")
@PreAuthorize("@ss.hasPermi('query:real:list')")
@GetMapping("/real/{id}")
public AjaxResult getRealInfo(@PathVariable("id") Long id) {
try {
ServerResult<UniQuery> serverResult = queryService.selectQueryById(id);
if (id == null) {
return AjaxResult.error("id不能为空!");
}
ServerResult<List<UniCon>> serverResult = queryService.getRealInfo(id);
if (serverResult.isStart()) {
return AjaxResult.success(serverResult.getData());
} else {
return AjaxResult.error(serverResult.getMsg());
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
return AjaxResult.error(ReturnConstants.SYS_ERROR);
}
}
@PreAuthorize("@ss.hasAnyPermi('query:real:data')")
@PutMapping("/real")
public Serializable getRealData(@Validated @RequestBody UniQuery uniQuery){
try {
ServerResult<List<Map<String,Object>>> serverResult = queryService.getRealData(uniQuery);
if (serverResult.isStart()){
UniQuery uniQuery = serverResult.getData();
Map<String,Object> modeMap = new HashMap<String, Object>();
List<UniCon> uniCons = uniQuery.getUniCons();
uniQuery.setUniCons(null);
modeMap.put("info",uniQuery);
modeMap.put("list",uniCons);
return AjaxResult.success(modeMap);
return getDataTable(serverResult.getData());
}else {
return AjaxResult.error(serverResult.getMsg());
}
@ -62,6 +83,29 @@ public class QueryController extends BaseController {
return AjaxResult.error(ReturnConstants.SYS_ERROR);
}
}
@PreAuthorize("@ss.hasPermi('query:list')")
@GetMapping("/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
try {
ServerResult<UniQuery> serverResult = queryService.selectQueryById(id);
if (serverResult.isStart()) {
UniQuery uniQuery = serverResult.getData();
Map<String, Object> modeMap = new HashMap<String, Object>();
List<UniCon> uniCons = uniQuery.getUniCons();
uniQuery.setUniCons(null);
modeMap.put("info", uniQuery);
modeMap.put("list", uniCons);
return AjaxResult.success(modeMap);
} else {
return AjaxResult.error(serverResult.getMsg());
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
return AjaxResult.error(ReturnConstants.SYS_ERROR);
}
}
// @PreAuthorize("@ss.hasPermi('query:list')")
// @GetMapping("/list")
// public AjaxResult list(UniQuery uniQuery){
@ -75,15 +119,15 @@ public class QueryController extends BaseController {
@PreAuthorize("@ss.hasPermi('query:edit')")
@PutMapping
public AjaxResult edit(@Validated @RequestBody UniQuery uniQuery){
public AjaxResult edit(@Validated @RequestBody UniQuery uniQuery) {
try {
ServerResult serverResult = queryService.updateQueryInfo(uniQuery);
if (serverResult.isStart()){
if (serverResult.isStart()) {
return AjaxResult.success();
}else {
} else {
return AjaxResult.error(serverResult.getMsg());
}
}catch (RuntimeException e){
} catch (RuntimeException e) {
logger.error(e.getMessage());
return AjaxResult.error(ReturnConstants.SYS_ERROR);
}
@ -91,30 +135,32 @@ public class QueryController extends BaseController {
@PreAuthorize("@ss.hasPermi('query:preview')")
@PutMapping("preview")
public Serializable Preview(@Validated @RequestBody UniQuery uniQuery){
public Serializable Preview(@Validated @RequestBody UniQuery uniQuery) {
try {
startPage(uniQuery);
ServerResult<List<Map<String,Object>>> serverResult = queryService.previewQuery(uniQuery);
if (serverResult.isStart()){
ServerResult<List<Map<String, Object>>> serverResult = queryService.previewQuery(uniQuery);
if (serverResult.isStart()) {
return getDataTable(serverResult.getData());
}else {
} else {
return AjaxResult.error(serverResult.getMsg());
}
}catch (RuntimeException e){
} catch (RuntimeException e) {
logger.error(e.getMessage());
return AjaxResult.error(ReturnConstants.SYS_ERROR);
}
}
@PreAuthorize("@ss.hasPermi('query:edit')")
@GetMapping("/export/{id}")
public AjaxResult Export(@PathVariable("id") Long id){
public AjaxResult Export(@PathVariable("id") Long id) {
try {
return AjaxResult.success();
}catch (RuntimeException e){
} catch (RuntimeException e) {
logger.error(e.getMessage());
return AjaxResult.error(ReturnConstants.SYS_ERROR);
}
}
/**
* 设置请求分页数据
*/

View File

@ -23,4 +23,7 @@ public interface QueryDao {
Integer insertUniCon(List<UniCon> uniCons);
List<Map<String,Object>> UniQuery(String paramSQL);
List<UniCon> queryRealInfo(Long id);
}

View File

@ -17,7 +17,7 @@ import java.util.List;
*/
@ApiModel("接口类名")
public class Apiclass extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 类id

View File

@ -15,7 +15,7 @@ import com.hchyun.common.utils.StringUtils;
*/
public class GenTable extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 编号 */
private Long tableId;

View File

@ -11,7 +11,7 @@ import com.hchyun.common.utils.StringUtils;
*/
public class GenTableColumn extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 编号 */
private Long columnId;

View File

@ -14,7 +14,7 @@ import java.util.List;
* @date 2021-01-24
*/
public class Module extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 模块id

View File

@ -11,7 +11,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
* @date 2021-01-30
*/
public class UniCon {
private static final long serialVersionUID = 1L;
/**
* id
@ -43,6 +43,11 @@ public class UniCon {
*/
private String ucMock;
/**
* 真实数据
*/
private String ucReal;
/**
* 描述
*/
@ -125,4 +130,12 @@ public class UniCon {
public void setUcDescribe(String ucDescribe) {
this.ucDescribe = ucDescribe;
}
public String getUcReal() {
return ucReal;
}
public void setUcReal(String ucReal) {
this.ucReal = ucReal;
}
}

View File

@ -4,6 +4,7 @@ import com.hchyun.common.core.entity.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.ArrayList;
import java.util.List;
/**
@ -13,7 +14,6 @@ import java.util.List;
* @date 2021-01-30
*/
public class UniQuery extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* id
@ -35,12 +35,26 @@ public class UniQuery extends BaseEntity {
*/
private String uqDescribe;
/**
* 是否发布(0:,1:发布)
*/
private Integer isRelease;
private List<UniCon> uniCons;
private Integer pageNum;
private Integer pageSize;
public Integer getIsRelease() {
return isRelease;
}
public void setIsRelease(Integer isRelease) {
this.isRelease = isRelease;
}
public Integer getPageNum() {
return pageNum;
}
@ -58,11 +72,15 @@ public class UniQuery extends BaseEntity {
}
public List<UniCon> getUniCons() {
return uniCons;
if (uniCons == null){
return uniCons = new ArrayList<UniCon>();
}else {
return uniCons;
}
}
public void setUniCons(List<UniCon> uniCons) {
this.uniCons = uniCons;
this.uniCons = uniCons;
}
public void setId(Long id) {

View File

@ -1,6 +1,7 @@
package com.hchyun.generator.service;
import com.hchyun.common.utils.ServerResult;
import com.hchyun.generator.entity.UniCon;
import com.hchyun.generator.entity.UniQuery;
import java.util.List;
@ -32,4 +33,18 @@ public interface QueryService {
* @return
*/
ServerResult<List<Map<String,Object>>> previewQuery(UniQuery uniQuery);
/**
* 获取真实查询基本信息
* @param id
* @return
*/
ServerResult<List<UniCon>> getRealInfo(Long id);
/**
* 获取查询信息
* @param uniQuery
* @return
*/
ServerResult<List<Map<String,Object>>> getRealData(UniQuery uniQuery);
}

View File

@ -1,6 +1,7 @@
package com.hchyun.generator.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.hchyun.common.constant.ReturnConstants;
import com.hchyun.common.utils.DateUtils;
import com.hchyun.common.utils.ServerResult;
@ -17,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.List;
import java.util.Locale;
import java.util.Map;
/**
@ -27,13 +29,16 @@ import java.util.Map;
@Service
public class QueryServiceImpl implements QueryService {
private Logger logger = LoggerFactory.getLogger(QueryServiceImpl.class);
@Autowired
private QueryDao queryDao;
@Autowired
private UniQueryDao uniQueryDao;
/**
* 查询万能查询的基本信息和条件信息
*
* @param id
* @return
*/
@ -46,15 +51,44 @@ public class QueryServiceImpl implements QueryService {
} else {
return new ServerResult<UniQuery>(false, ReturnConstants.RESULT_EMPTY);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
return new ServerResult<UniQuery>(false, ReturnConstants.SYS_FAILL);
}
}
@Override
public ServerResult<List<Map<String, Object>>> getRealData(UniQuery uniQuery) {
try {
List<UniCon> uniCons = uniQuery.getUniCons();
Integer pageNum = uniQuery.getPageNum();
Integer pageSize = uniQuery.getPageSize();
uniQuery = uniQueryDao.selectUniQueryById(uniQuery.getId());
String sql = uniQuery.getUqSql().toLowerCase();
sql = sql.toLowerCase();
if (uniQuery.getIsRelease() == 0) {
return new ServerResult<List<Map<String, Object>>>(false, ReturnConstants.STATE_ERROR);
} else {
if (uniCons.size() > 0) {
sql += " where ";
for (UniCon uniCon : uniCons) {
sql += conversionReal(uniCon);
}
sql+= " 1 = 1";
}
PageHelper.startPage(pageNum, pageSize, "");
List<Map<String, Object>> dataMap = queryDao.UniQuery(sql);
return new ServerResult<List<Map<String, Object>>>(true, dataMap);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
return new ServerResult<List<Map<String, Object>>>(false, ReturnConstants.SYS_FAILL);
}
}
/**
* 更新万能查询基本信息和条件
*
* @param uniQuery
* @return
*/
@ -64,16 +98,16 @@ public class QueryServiceImpl implements QueryService {
try {
Integer uqrenewal = uniQueryDao.updateUniQuery(uniQuery);
if (uqrenewal > 0) {
if (uniQuery.getUniCons()!=null){
if (uniQuery.getUniCons() != null) {
queryDao.deleteUniCon(uniQuery.getId());
Integer ucrenewal = queryDao.insertUniCon(uniQuery.getUniCons());
if (ucrenewal==0){
return new ServerResult(false,"操作失败!");
if (ucrenewal == 0) {
return new ServerResult(false, "操作失败!");
}
}
return new ServerResult(true);
}
return new ServerResult(false,"操作失败!");
return new ServerResult(false, "操作失败!");
} catch (RuntimeException e) {
logger.error(e.getMessage());
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@ -82,68 +116,113 @@ public class QueryServiceImpl implements QueryService {
}
@Override
public ServerResult<List<Map<String,Object>>> previewQuery(UniQuery uniQuery) {
public ServerResult<List<Map<String, Object>>> previewQuery(UniQuery uniQuery) {
try {
String sql = uniQuery.getUqSql();
List<UniCon> uniConList = uniQuery.getUniCons();
sql = sql.toLowerCase();
if (sql.contains("insert")||sql.contains("delete ")||sql.contains("update ")||sql.contains("drop ")||sql.contains("database ")||sql.contains("create ")||sql.contains("view ")||sql.contains("alter ")){
return new ServerResult<List<Map<String,Object>>>(false,"sql语句含有insert,delete,update,drop,database,view,alter等特殊字符!");
if (sql.contains("insert") || sql.contains("delete ") || sql.contains("update ") || sql.contains("drop ") || sql.contains("database ") || sql.contains("create ") || sql.contains("view ") || sql.contains("alter ")) {
return new ServerResult<List<Map<String, Object>>>(false, "sql语句含有insert,delete,update,drop,database,view,alter等特殊字符!");
}
sql = sql + " where ";
if(uniConList!=null){
for (UniCon uniCon: uniConList) {
sql += conversion(uniCon);
if (uniConList.size() > 0) {
sql = sql + " where ";
for (UniCon uniCon : uniConList) {
sql += conversionPreview(uniCon);
}
sql = sql + " 1=1";
sql+= " 1 = 1";
}
List<Map<String,Object>> dataMap = queryDao.UniQuery(sql);
return new ServerResult<List<Map<String,Object>>>(true,dataMap);
}catch (RuntimeException e){
List<Map<String, Object>> dataMap = queryDao.UniQuery(sql);
return new ServerResult<List<Map<String, Object>>>(true, dataMap);
} catch (RuntimeException e) {
logger.error(e.getMessage());
return new ServerResult<List<Map<String,Object>>>(false,e.getMessage());
return new ServerResult<List<Map<String, Object>>>(false, e.getMessage());
}
}
@Override
public ServerResult<List<UniCon>> getRealInfo(Long id) {
try {
List<UniCon> uniCons = queryDao.queryRealInfo(id);
return new ServerResult<List<UniCon>>(true, uniCons);
} catch (RuntimeException e) {
logger.error(e.getMessage());
return new ServerResult<List<UniCon>>(false, ReturnConstants.DB_EX);
}
}
public String conversion(UniCon uniCon){
if (uniCon.getType().equals("datetime")){
public String conversionReal(UniCon uniCon) {
if (uniCon.getUcReal() == null) {
return "";
} else {
if (uniCon.getUcType().equals("datetime")) {
uniCon.setUcReal(DateUtils.getDate(uniCon.getUcReal()));
}
String sql = "";
if (uniCon.getUcCon().equals("EQ")) {
sql += uniCon.getUcKey() + " = '" + uniCon.getUcReal() + "' and ";
} else if (uniCon.getUcCon().equals("NE")) {
sql += uniCon.getUcKey() + " != '" + uniCon.getUcReal() + "' and ";
} else if (uniCon.getUcCon().equals("GT")) {
sql += uniCon.getUcKey() + " > '" + uniCon.getUcReal() + "' and ";
} else if (uniCon.getUcCon().equals("GTE")) {
sql += uniCon.getUcKey() + " >= '" + uniCon.getUcReal() + "' and ";
} else if (uniCon.getUcCon().equals("LT")) {
sql += uniCon.getUcKey() + " < '" + uniCon.getUcReal() + "' and ";
} else if (uniCon.getUcCon().equals("LTE")) {
sql += uniCon.getUcKey() + " <= '" + uniCon.getUcReal() + "' and ";
} else if (uniCon.getUcCon().equals("LIKE")) {
sql += uniCon.getUcKey() + " like '%" + uniCon.getUcReal() + "%'";
} else if (uniCon.getUcCon().equals("BETWEEN")) {
JSONObject jsonObject = JSONObject.parseObject(uniCon.getUcReal());
if (uniCon.getUcType().equals("input")) {
Object begin = jsonObject.get("begin");
Object end = jsonObject.get("end");
sql += uniCon.getUcKey() + " between '" + begin + "' AND '" + end + "' and ";
} else if (uniCon.getUcType().equals("datetime")) {
Object startTime = jsonObject.get("startTime");
Object endTime = jsonObject.get("endTime");
sql += uniCon.getUcKey() + " between '" + startTime + "' AND '" + endTime + "' and ";
}
}
return sql;
}
}
public String conversionPreview(UniCon uniCon) {
if (uniCon.getType().equals("datetime")) {
uniCon.setUcMock(DateUtils.getDate(uniCon.getUcMock()));
}
String sql = "";
if (uniCon.getUcCon().equals("EQ")){
sql += uniCon.getUcKey() + " = '" + uniCon.getUcMock()+ "' and ";
}else if (uniCon.getUcCon().equals("NE")){
sql += uniCon.getUcKey() + " != '" + uniCon.getUcMock()+ "' and ";
}else if (uniCon.getUcCon().equals("GT")){
sql += uniCon.getUcKey() + " > '" + uniCon.getUcMock()+ "' and ";
}else if (uniCon.getUcCon().equals("GTE")){
sql += uniCon.getUcKey() + " >= '" + uniCon.getUcMock()+ "' and ";
}else if (uniCon.getUcCon().equals("LT")){
sql += uniCon.getUcKey() + " < '" + uniCon.getUcMock()+ "' and ";
}else if (uniCon.getUcCon().equals("LTE")){
sql += uniCon.getUcKey() + " <= '" + uniCon.getUcMock()+ "' and ";
}else if (uniCon.getUcCon().equals("LIKE")){
sql += uniCon.getUcKey() + " like '%" + uniCon.getUcMock()+ "%' and ";
}else if (uniCon.getUcCon().equals("BETWEEN")){
if (uniCon.getUcCon().equals("EQ")) {
sql += uniCon.getUcKey() + " = '" + uniCon.getUcMock() + "' and ";
} else if (uniCon.getUcCon().equals("NE")) {
sql += uniCon.getUcKey() + " != '" + uniCon.getUcMock() + "' and ";
} else if (uniCon.getUcCon().equals("GT")) {
sql += uniCon.getUcKey() + " > '" + uniCon.getUcMock() + "' and ";
} else if (uniCon.getUcCon().equals("GTE")) {
sql += uniCon.getUcKey() + " >= '" + uniCon.getUcMock() + "' and ";
} else if (uniCon.getUcCon().equals("LT")) {
sql += uniCon.getUcKey() + " < '" + uniCon.getUcMock() + "' and ";
} else if (uniCon.getUcCon().equals("LTE")) {
sql += uniCon.getUcKey() + " <= '" + uniCon.getUcMock() + "' and ";
} else if (uniCon.getUcCon().equals("LIKE")) {
sql += uniCon.getUcKey() + " like '%" + uniCon.getUcMock() + "%'";
} else if (uniCon.getUcCon().equals("BETWEEN")) {
JSONObject jsonObject = JSONObject.parseObject(uniCon.getUcMock());
if (uniCon.getUcType().equals("input")){
if (uniCon.getUcType().equals("input")) {
Object begin = jsonObject.get("begin");
Object end = jsonObject.get("end");
sql += uniCon.getUcKey() + " between '" + begin +"' AND '" + end + "' and";
}else if (uniCon.getUcType().equals("datetime")){
sql += uniCon.getUcKey() + " between '" + begin + "' AND '" + end + "' and ";
} else if (uniCon.getUcType().equals("datetime")) {
Object startTime = jsonObject.get("startTime");
Object endTime = jsonObject.get("endTime");
sql += uniCon.getUcKey() + " between '" + startTime +"' AND '" + endTime + "' and";
sql += uniCon.getUcKey() + " between '" + startTime + "' AND '" + endTime + "' and ";
}
}
return sql;
}
}

View File

@ -31,6 +31,10 @@
</select>
<select id="queryRealInfo" parameterType="Long" resultMap="UniConResult">
select * from gen_uni_con where uq_id = #{id}
</select>
<select id="selectQueryInfo" parameterType="Long" resultMap="QueryResult">
select uq.id, uq.uq_name, uq.uq_sql, uq.uq_describe, uq.create_by, uq.create_time, uq.update_by, uq.update_time,
uc.id as uc_id, uc.uq_id, uc.uc_name, uc.uc_key, uc.uc_con, uc.uc_mock, uc.uc_describe ,uc.uc_type,uc.type

View File

@ -9,6 +9,7 @@
<result property="uqName" column="uq_name" />
<result property="uqSql" column="uq_sql" />
<result property="uqDescribe" column="uq_describe" />
<result property="isRelease" column="is_release" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
@ -17,7 +18,7 @@
<sql id="selectUniQueryVo">
select id, uq_name, uq_sql, uq_describe, create_by, create_time, update_by, update_time from gen_uni_query
select id, uq_name, uq_sql, uq_describe, is_release, create_by, create_time, update_by, update_time from gen_uni_query
</sql>
<select id="selectUniQueryList" parameterType="UniQuery" resultMap="UniQueryResult">

View File

@ -21,7 +21,7 @@ import com.hchyun.quartz.util.CronUtils;
*/
public class SysJob extends BaseEntity implements Serializable
{
private static final long serialVersionUID = 1L;
/** 任务ID */
@Excel(name = "任务序号", cellType = ColumnType.NUMERIC)

View File

@ -13,7 +13,7 @@ import com.hchyun.common.core.entity.BaseEntity;
*/
public class SysJobLog extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** ID */
@Excel(name = "日志序号")

View File

@ -13,7 +13,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
*/
public class Regular extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long id;

View File

@ -15,7 +15,7 @@ import com.hchyun.common.core.entity.BaseEntity;
*/
public class SysConfig extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 参数主键 */
@Excel(name = "参数主键", cellType = ColumnType.NUMERIC)

View File

@ -13,7 +13,7 @@ import com.hchyun.common.core.entity.BaseEntity;
*/
public class SysLogininfor extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** ID */
@Excel(name = "序号", cellType = ColumnType.NUMERIC)

View File

@ -13,7 +13,7 @@ import com.hchyun.common.core.entity.BaseEntity;
*/
public class SysNotice extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 公告ID */
private Long noticeId;

View File

@ -13,7 +13,7 @@ import com.hchyun.common.core.entity.BaseEntity;
*/
public class SysOperLog extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 日志主键 */
@Excel(name = "操作序号", cellType = ColumnType.NUMERIC)

View File

@ -15,7 +15,7 @@ import com.hchyun.common.core.entity.BaseEntity;
*/
public class SysPost extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 岗位序号 */
@Excel(name = "岗位序号", cellType = ColumnType.NUMERIC)

View File

@ -16,7 +16,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
@ApiModel("成绩")
public class Results extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
@ApiModelProperty("id")

View File

@ -14,7 +14,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
*/
public class Stu extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long id;

View File

@ -13,7 +13,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
*/
public class TestTree extends TreeEntity
{
private static final long serialVersionUID = 1L;
/** 主键id */
private Long id;