This commit is contained in:
parent
d727139e99
commit
4fe69b0824
|
|
@ -5,5 +5,5 @@ ENV = 'staging'
|
||||||
|
|
||||||
# 宏驰云管理系统/测试环境
|
# 宏驰云管理系统/测试环境
|
||||||
#VUE_APP_BASE_API = '/dev-api'
|
#VUE_APP_BASE_API = '/dev-api'
|
||||||
#VUE_APP_BASE_API = 'http://localhost:8085/dev-api'
|
VUE_APP_BASE_API = 'http://localhost:8085/dev-api'
|
||||||
VUE_APP_BASE_API = 'http://hchyunapi.tomey.live/dev-api'
|
#VUE_APP_BASE_API = 'http://hchyunapi.tomey.live/dev-api'
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ service.interceptors.response.use(res => {
|
||||||
type: 'error'
|
type: 'error'
|
||||||
})
|
})
|
||||||
return Promise.reject(new Error(msg))
|
return Promise.reject(new Error(msg))
|
||||||
14 }else if (code == 199){
|
}else if (code == 199){
|
||||||
Message({
|
Message({
|
||||||
message: "查询结果为空!",
|
message: "查询结果为空!",
|
||||||
type: 'info'
|
type: 'info'
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,11 @@
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-table ref="dragTable" :data="cloumns" row-key="columnId" :max-height="tableHeight">
|
<el-table ref="dragTable" :data="cloumns" row-key="columnId" :max-height="tableHeight">
|
||||||
<el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag"/>
|
<el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag"/>
|
||||||
|
<el-table-column label="查询名称" min-width="10%">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-input v-model="scope.row.ucName"></el-input>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="条件描述" min-width="10%">
|
<el-table-column label="条件描述" min-width="10%">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-input v-model="scope.row.ucDescribe"></el-input>
|
<el-input v-model="scope.row.ucDescribe"></el-input>
|
||||||
|
|
@ -47,7 +52,7 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="条件" min-width="10%">
|
<el-table-column label="条件" min-width="10%">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-select v-model="scope.row.ucName" @change="ucTypeChang(scope.$index,scope.row)">
|
<el-select v-model="scope.row.ucCon" @change="ucTypeChang(scope.$index,scope.row)">
|
||||||
<el-option label="=" value="EQ"/>
|
<el-option label="=" value="EQ"/>
|
||||||
<el-option label="!=" value="NE"/>
|
<el-option label="!=" value="NE"/>
|
||||||
<el-option label=">" value="GT"/>
|
<el-option label=">" value="GT"/>
|
||||||
|
|
@ -83,7 +88,9 @@
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-else-if="scope.row.type ==3"
|
v-else-if="scope.row.type ==3"
|
||||||
v-model="scope.row.ucMock"
|
v-model="scope.row.ucMock"
|
||||||
type="datetime"
|
type="date"
|
||||||
|
format="yyyy-MM-dd"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
placeholder="选择日期时间">
|
placeholder="选择日期时间">
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
<el-date-picker v-else-if="scope.row.type ==4"
|
<el-date-picker v-else-if="scope.row.type ==4"
|
||||||
|
|
@ -142,7 +149,7 @@ function JSONString(list) {
|
||||||
} else if (list[i].type == 4) {
|
} else if (list[i].type == 4) {
|
||||||
let time = {
|
let time = {
|
||||||
startTime: list[i].ucMock[0],
|
startTime: list[i].ucMock[0],
|
||||||
endTime: list[i].ucMock[0],
|
endTime: list[i].ucMock[1],
|
||||||
}
|
}
|
||||||
list[i].ucMock = JSON.stringify(time)
|
list[i].ucMock = JSON.stringify(time)
|
||||||
}
|
}
|
||||||
|
|
@ -171,9 +178,9 @@ export default {
|
||||||
// 表列信息
|
// 表列信息
|
||||||
cloumns: [],
|
cloumns: [],
|
||||||
total: 0,
|
total: 0,
|
||||||
queryParams:{
|
queryParams: {
|
||||||
pageNum:1,
|
pageNum: 1,
|
||||||
pageSize:10,
|
pageSize: 10,
|
||||||
},
|
},
|
||||||
queryId: null,
|
queryId: null,
|
||||||
info: {
|
info: {
|
||||||
|
|
@ -237,16 +244,19 @@ export default {
|
||||||
this.cloumns.splice(index, 1);
|
this.cloumns.splice(index, 1);
|
||||||
},
|
},
|
||||||
ucTypeChang(index, row) {
|
ucTypeChang(index, row) {
|
||||||
if (row.ucType == 'input' && row.ucName != 'BETWEEN') {
|
console.log(typeof this.cloumns[index].ucMock)
|
||||||
|
if (row.ucType == 'input' && row.ucCon != 'BETWEEN') {
|
||||||
this.cloumns[index].type = 1
|
this.cloumns[index].type = 1
|
||||||
this.cloumns[index].ucMock = ''
|
if (typeof (this.cloumns[index].ucMock) != 'string') {
|
||||||
} else if (row.ucType == 'input' && row.ucName == 'BETWEEN') {
|
this.cloumns[index].ucMock = ''
|
||||||
|
}
|
||||||
|
} else if (row.ucType == 'input' && row.ucCon == 'BETWEEN') {
|
||||||
this.cloumns[index].type = 2
|
this.cloumns[index].type = 2
|
||||||
this.cloumns[index].ucMock = {begin:'',end:''}
|
this.cloumns[index].ucMock = {begin: '', end: ''}
|
||||||
} else if (row.ucType == 'datetime' && row.ucName != 'BETWEEN') {
|
} else if (row.ucType == 'datetime' && row.ucCon != 'BETWEEN') {
|
||||||
this.cloumns[index].type = 3
|
this.cloumns[index].type = 3
|
||||||
this.cloumns[index].ucMock = ''
|
this.cloumns[index].ucMock = ''
|
||||||
} else if (row.ucType == 'datetime' && row.ucName == 'BETWEEN') {
|
} else if (row.ucType == 'datetime' && row.ucCon == 'BETWEEN') {
|
||||||
this.cloumns[index].type = 4
|
this.cloumns[index].type = 4
|
||||||
this.cloumns[index].ucMock = []
|
this.cloumns[index].ucMock = []
|
||||||
}
|
}
|
||||||
|
|
@ -256,7 +266,8 @@ export default {
|
||||||
let row = {
|
let row = {
|
||||||
id: null,
|
id: null,
|
||||||
uqId: this.queryId,
|
uqId: this.queryId,
|
||||||
ucName: 'EQ',
|
ucName: '',
|
||||||
|
ucCon: 'EQ',
|
||||||
ucDescribe: '',
|
ucDescribe: '',
|
||||||
ucKey: '',
|
ucKey: '',
|
||||||
ucMock: '',
|
ucMock: '',
|
||||||
|
|
@ -277,8 +288,8 @@ export default {
|
||||||
console.log(res)
|
console.log(res)
|
||||||
this.cloumns = JSONparse(list)
|
this.cloumns = JSONparse(list)
|
||||||
Message({
|
Message({
|
||||||
message:res.msg,
|
message: res.msg,
|
||||||
type:'success'
|
type: 'success'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -291,13 +302,15 @@ export default {
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.form-header{
|
.form-header {
|
||||||
margin: 18px 10px 0px 10px !important;
|
margin: 18px 10px 0px 10px !important;
|
||||||
}
|
}
|
||||||
.el-table{
|
|
||||||
|
.el-table {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
.pagination-container{
|
|
||||||
|
.pagination-container {
|
||||||
height: 50px !important;
|
height: 50px !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,13 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||||
public static String getDate() {
|
public static String getDate() {
|
||||||
return dateTimeNow(YYYY_MM_DD);
|
return dateTimeNow(YYYY_MM_DD);
|
||||||
}
|
}
|
||||||
|
public static String getDate(String time){
|
||||||
|
try {
|
||||||
|
return new SimpleDateFormat(YYYY_MM_DD).parse(time).toString();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static final String getTime() {
|
public static final String getTime() {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.hchyun.generator.entity;
|
package com.hchyun.generator.entity;
|
||||||
|
|
||||||
|
import com.hchyun.common.core.entity.BaseEntity;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
package com.hchyun.generator.service.impl;
|
package com.hchyun.generator.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.hchyun.common.constant.ReturnConstants;
|
import com.hchyun.common.constant.ReturnConstants;
|
||||||
|
import com.hchyun.common.utils.DateUtils;
|
||||||
import com.hchyun.common.utils.ServerResult;
|
import com.hchyun.common.utils.ServerResult;
|
||||||
import com.hchyun.generator.dao.QueryDao;
|
import com.hchyun.generator.dao.QueryDao;
|
||||||
import com.hchyun.generator.dao.UniQueryDao;
|
import com.hchyun.generator.dao.UniQueryDao;
|
||||||
|
import com.hchyun.generator.entity.UniCon;
|
||||||
import com.hchyun.generator.entity.UniQuery;
|
import com.hchyun.generator.entity.UniQuery;
|
||||||
import com.hchyun.generator.service.QueryService;
|
import com.hchyun.generator.service.QueryService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
@ -82,13 +85,21 @@ public class QueryServiceImpl implements QueryService {
|
||||||
public ServerResult<List<Map<String,Object>>> previewQuery(UniQuery uniQuery) {
|
public ServerResult<List<Map<String,Object>>> previewQuery(UniQuery uniQuery) {
|
||||||
try {
|
try {
|
||||||
String sql = uniQuery.getUqSql();
|
String sql = uniQuery.getUqSql();
|
||||||
|
List<UniCon> uniConList = uniQuery.getUniCons();
|
||||||
sql = sql.toLowerCase();
|
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 ")){
|
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等特殊字符!");
|
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);
|
||||||
|
}
|
||||||
|
sql = sql + " 1=1";
|
||||||
|
}
|
||||||
|
|
||||||
List<Map<String,Object>> dataMap = queryDao.UniQuery(uniQuery.getUqSql());
|
List<Map<String,Object>> dataMap = queryDao.UniQuery(sql);
|
||||||
|
|
||||||
return new ServerResult<List<Map<String,Object>>>(true,dataMap);
|
return new ServerResult<List<Map<String,Object>>>(true,dataMap);
|
||||||
}catch (RuntimeException e){
|
}catch (RuntimeException e){
|
||||||
|
|
@ -96,4 +107,43 @@ public class QueryServiceImpl implements QueryService {
|
||||||
return new ServerResult<List<Map<String,Object>>>(false,e.getMessage());
|
return new ServerResult<List<Map<String,Object>>>(false,e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String conversion(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")){
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(uniCon.getUcMock());
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue