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 = 'http://localhost:8085/dev-api'
|
||||
VUE_APP_BASE_API = 'http://hchyunapi.tomey.live/dev-api'
|
||||
VUE_APP_BASE_API = 'http://localhost:8085/dev-api'
|
||||
#VUE_APP_BASE_API = 'http://hchyunapi.tomey.live/dev-api'
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ service.interceptors.response.use(res => {
|
|||
type: 'error'
|
||||
})
|
||||
return Promise.reject(new Error(msg))
|
||||
14 }else if (code == 199){
|
||||
}else if (code == 199){
|
||||
Message({
|
||||
message: "查询结果为空!",
|
||||
type: 'info'
|
||||
|
|
|
|||
|
|
@ -35,6 +35,11 @@
|
|||
<el-row>
|
||||
<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="查询名称" 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%">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.ucDescribe"></el-input>
|
||||
|
|
@ -47,7 +52,7 @@
|
|||
</el-table-column>
|
||||
<el-table-column label="条件" min-width="10%">
|
||||
<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="NE"/>
|
||||
<el-option label=">" value="GT"/>
|
||||
|
|
@ -83,7 +88,9 @@
|
|||
<el-date-picker
|
||||
v-else-if="scope.row.type ==3"
|
||||
v-model="scope.row.ucMock"
|
||||
type="datetime"
|
||||
type="date"
|
||||
format="yyyy-MM-dd"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="选择日期时间">
|
||||
</el-date-picker>
|
||||
<el-date-picker v-else-if="scope.row.type ==4"
|
||||
|
|
@ -142,7 +149,7 @@ function JSONString(list) {
|
|||
} else if (list[i].type == 4) {
|
||||
let time = {
|
||||
startTime: list[i].ucMock[0],
|
||||
endTime: list[i].ucMock[0],
|
||||
endTime: list[i].ucMock[1],
|
||||
}
|
||||
list[i].ucMock = JSON.stringify(time)
|
||||
}
|
||||
|
|
@ -171,9 +178,9 @@ export default {
|
|||
// 表列信息
|
||||
cloumns: [],
|
||||
total: 0,
|
||||
queryParams:{
|
||||
pageNum:1,
|
||||
pageSize:10,
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
queryId: null,
|
||||
info: {
|
||||
|
|
@ -237,16 +244,19 @@ export default {
|
|||
this.cloumns.splice(index, 1);
|
||||
},
|
||||
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].ucMock = ''
|
||||
} else if (row.ucType == 'input' && row.ucName == 'BETWEEN') {
|
||||
if (typeof (this.cloumns[index].ucMock) != 'string') {
|
||||
this.cloumns[index].ucMock = ''
|
||||
}
|
||||
} else if (row.ucType == 'input' && row.ucCon == 'BETWEEN') {
|
||||
this.cloumns[index].type = 2
|
||||
this.cloumns[index].ucMock = {begin:'',end:''}
|
||||
} else if (row.ucType == 'datetime' && row.ucName != 'BETWEEN') {
|
||||
this.cloumns[index].ucMock = {begin: '', end: ''}
|
||||
} else if (row.ucType == 'datetime' && row.ucCon != 'BETWEEN') {
|
||||
this.cloumns[index].type = 3
|
||||
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].ucMock = []
|
||||
}
|
||||
|
|
@ -256,7 +266,8 @@ export default {
|
|||
let row = {
|
||||
id: null,
|
||||
uqId: this.queryId,
|
||||
ucName: 'EQ',
|
||||
ucName: '',
|
||||
ucCon: 'EQ',
|
||||
ucDescribe: '',
|
||||
ucKey: '',
|
||||
ucMock: '',
|
||||
|
|
@ -277,8 +288,8 @@ export default {
|
|||
console.log(res)
|
||||
this.cloumns = JSONparse(list)
|
||||
Message({
|
||||
message:res.msg,
|
||||
type:'success'
|
||||
message: res.msg,
|
||||
type: 'success'
|
||||
})
|
||||
})
|
||||
} else {
|
||||
|
|
@ -291,13 +302,15 @@ export default {
|
|||
|
||||
</script>
|
||||
<style scoped>
|
||||
.form-header{
|
||||
.form-header {
|
||||
margin: 18px 10px 0px 10px !important;
|
||||
}
|
||||
.el-table{
|
||||
|
||||
.el-table {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.pagination-container{
|
||||
|
||||
.pagination-container {
|
||||
height: 50px !important;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -45,6 +45,13 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
public static String getDate() {
|
||||
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() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
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.ToStringStyle;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
package com.hchyun.generator.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hchyun.common.constant.ReturnConstants;
|
||||
import com.hchyun.common.utils.DateUtils;
|
||||
import com.hchyun.common.utils.ServerResult;
|
||||
import com.hchyun.generator.dao.QueryDao;
|
||||
import com.hchyun.generator.dao.UniQueryDao;
|
||||
import com.hchyun.generator.entity.UniCon;
|
||||
import com.hchyun.generator.entity.UniQuery;
|
||||
import com.hchyun.generator.service.QueryService;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -82,13 +85,21 @@ public class QueryServiceImpl implements QueryService {
|
|||
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等特殊字符!");
|
||||
}
|
||||
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);
|
||||
}catch (RuntimeException e){
|
||||
|
|
@ -96,4 +107,43 @@ public class QueryServiceImpl implements QueryService {
|
|||
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