This commit is contained in:
parent
eabeb10554
commit
d727139e99
|
|
@ -5,4 +5,5 @@ ENV = 'staging'
|
|||
|
||||
# 宏驰云管理系统/测试环境
|
||||
#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'
|
||||
|
|
|
|||
|
|
@ -112,22 +112,30 @@
|
|||
</el-table>
|
||||
</el-row>
|
||||
</div>
|
||||
<div class="table-fixed">
|
||||
<div class="el-table">
|
||||
<el-table v-show="previewDate.open" :data="previewDate.data">
|
||||
<el-table-column v-for="item in previewDate.header"
|
||||
:label="item"
|
||||
align="center"
|
||||
:key="item"
|
||||
:prop="item" />
|
||||
:prop="item"/>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="previewQuery"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import {getQueryInfo, editQueryInfo, previewQueryData} from '@/api/tool/query'
|
||||
import {Message} from "element-ui";
|
||||
|
||||
|
||||
function JSONString(list){
|
||||
function JSONString(list) {
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
if (list[i].type == 2) {
|
||||
list[i].ucMock = JSON.stringify(list[i].ucMock)
|
||||
|
|
@ -141,13 +149,14 @@ function JSONString(list){
|
|||
}
|
||||
return list;
|
||||
}
|
||||
function JSONparse(list){
|
||||
|
||||
function JSONparse(list) {
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
if (list[i].type == 2) {
|
||||
list[i].ucMock = JSON.parse(list[i].ucMock)
|
||||
} else if (list[i].type == 4) {
|
||||
let time = JSON.parse(list[i].ucMock)
|
||||
list[i].ucMock = [time.startTime,time.endTime]
|
||||
list[i].ucMock = [time.startTime, time.endTime]
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
|
@ -161,16 +170,22 @@ export default {
|
|||
tableHeight: document.documentElement.scrollHeight - 245 + "px",
|
||||
// 表列信息
|
||||
cloumns: [],
|
||||
total: 0,
|
||||
queryParams:{
|
||||
pageNum:1,
|
||||
pageSize:10,
|
||||
},
|
||||
queryId: null,
|
||||
info: {
|
||||
uqSql: null,
|
||||
uqName: null,
|
||||
uqDescribe: null,
|
||||
},
|
||||
previewDate:{
|
||||
open:false,
|
||||
data:[],
|
||||
header:[],
|
||||
|
||||
previewDate: {
|
||||
open: false,
|
||||
data: [],
|
||||
header: [],
|
||||
},
|
||||
rules: {
|
||||
uqName: [{required: true, message: '请输入名称', trigger: 'blur'}],
|
||||
|
|
@ -192,15 +207,19 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
/** 预览 */
|
||||
previewQuery(){
|
||||
previewQuery() {
|
||||
this.$refs['elForm'].validate(valid => {
|
||||
if (valid) {
|
||||
let list = JSONString(this.cloumns)
|
||||
let data = this.info
|
||||
data.uniCons = list
|
||||
if (list.length > 0) {
|
||||
data.uniCons = list
|
||||
}
|
||||
data.pageNum = this.queryParams.pageNum
|
||||
data.pageSize = this.queryParams.pageSize
|
||||
previewQueryData(data).then(res => {
|
||||
console.log(res)
|
||||
this.previewDate.data = res.data
|
||||
this.previewDate.data = res.rows
|
||||
this.total = res.total
|
||||
this.previewDate.header = []
|
||||
for (var key in this.previewDate.data[0]) {
|
||||
this.previewDate.header.push(key)
|
||||
|
|
@ -208,7 +227,7 @@ export default {
|
|||
this.previewDate.open = true
|
||||
this.cloumns = JSONparse(list)
|
||||
})
|
||||
}else {
|
||||
} else {
|
||||
return
|
||||
}
|
||||
})
|
||||
|
|
@ -223,10 +242,7 @@ export default {
|
|||
this.cloumns[index].ucMock = ''
|
||||
} else if (row.ucType == 'input' && row.ucName == 'BETWEEN') {
|
||||
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') {
|
||||
this.cloumns[index].type = 3
|
||||
this.cloumns[index].ucMock = ''
|
||||
|
|
@ -254,12 +270,18 @@ export default {
|
|||
if (valid) {
|
||||
let list = JSONString(this.cloumns)
|
||||
let data = this.info
|
||||
data.uniCons = list
|
||||
if (list.length > 0) {
|
||||
data.uniCons = list
|
||||
}
|
||||
editQueryInfo(data).then(res => {
|
||||
console.log(res)
|
||||
this.cloumns = JSONparse(list)
|
||||
Message({
|
||||
message:res.msg,
|
||||
type:'success'
|
||||
})
|
||||
})
|
||||
}else {
|
||||
} else {
|
||||
return
|
||||
}
|
||||
})
|
||||
|
|
@ -269,4 +291,13 @@ export default {
|
|||
|
||||
</script>
|
||||
<style scoped>
|
||||
.form-header{
|
||||
margin: 18px 10px 0px 10px !important;
|
||||
}
|
||||
.el-table{
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.pagination-container{
|
||||
height: 50px !important;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,15 @@
|
|||
package com.hchyun.generator.controller;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.hchyun.common.constant.HttpStatus;
|
||||
import com.hchyun.common.constant.ReturnConstants;
|
||||
import com.hchyun.common.core.controller.BaseController;
|
||||
import com.hchyun.common.core.entity.AjaxResult;
|
||||
import com.hchyun.common.core.page.TableDataInfo;
|
||||
import com.hchyun.common.utils.ServerResult;
|
||||
import com.hchyun.common.utils.StringUtils;
|
||||
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;
|
||||
|
|
@ -13,6 +20,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -25,7 +33,7 @@ import java.util.Map;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/query")
|
||||
public class QueryController {
|
||||
public class QueryController extends BaseController {
|
||||
protected final Logger logger = LoggerFactory.getLogger(QueryController.class);
|
||||
|
||||
|
||||
|
|
@ -83,11 +91,12 @@ public class QueryController {
|
|||
|
||||
@PreAuthorize("@ss.hasPermi('query:preview')")
|
||||
@PutMapping("preview")
|
||||
public AjaxResult 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()){
|
||||
return AjaxResult.success(serverResult.getData());
|
||||
return getDataTable(serverResult.getData());
|
||||
}else {
|
||||
return AjaxResult.error(serverResult.getMsg());
|
||||
}
|
||||
|
|
@ -106,8 +115,15 @@ public class QueryController {
|
|||
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 设置请求分页数据
|
||||
*/
|
||||
protected void startPage(UniQuery uniQuery) {
|
||||
Integer pageNum = uniQuery.getPageNum();
|
||||
Integer pageSize = uniQuery.getPageSize();
|
||||
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
|
||||
String orderBy = SqlUtil.escapeOrderBySql("");
|
||||
PageHelper.startPage(pageNum, pageSize, orderBy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,19 @@ import java.io.Serializable;
|
|||
import java.util.List;
|
||||
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.hchyun.common.constant.HttpStatus;
|
||||
import com.hchyun.common.constant.ReturnConstants;
|
||||
import com.hchyun.common.core.controller.BaseController;
|
||||
import com.hchyun.common.core.controller.HcyBaseController;
|
||||
import com.hchyun.common.core.page.PageDomain;
|
||||
import com.hchyun.common.core.page.TableDataInfo;
|
||||
import com.hchyun.common.core.page.TableSupport;
|
||||
import com.hchyun.common.utils.ServerResult;
|
||||
import com.hchyun.common.utils.StringUtils;
|
||||
import com.hchyun.common.utils.poi.ExcelUtil;
|
||||
import com.hchyun.common.utils.sql.SqlUtil;
|
||||
import com.hchyun.generator.entity.UniQuery;
|
||||
import com.hchyun.generator.service.UniQueryService;
|
||||
import io.swagger.annotations.Api;
|
||||
|
|
@ -38,7 +47,7 @@ import com.hchyun.common.enums.BusinessType;
|
|||
@Api(value = "万能查询管理",tags = "万能查询管理")
|
||||
@RestController
|
||||
@RequestMapping("/tool/query")
|
||||
public class UniQueryController extends HcyBaseController {
|
||||
public class UniQueryController extends BaseController {
|
||||
protected final Logger logger = LoggerFactory.getLogger(UniQueryController.class);
|
||||
|
||||
@Autowired
|
||||
|
|
|
|||
|
|
@ -37,6 +37,26 @@ public class UniQuery extends BaseEntity {
|
|||
|
||||
private List<UniCon> uniCons;
|
||||
|
||||
private Integer pageNum;
|
||||
|
||||
private Integer pageSize;
|
||||
|
||||
public Integer getPageNum() {
|
||||
return pageNum;
|
||||
}
|
||||
|
||||
public void setPageNum(Integer pageNum) {
|
||||
this.pageNum = pageNum;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(Integer pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public List<UniCon> getUniCons() {
|
||||
return uniCons;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import com.hchyun.generator.dao.GenTableDao;
|
|||
import com.hchyun.generator.util.GenUtils;
|
||||
import com.hchyun.generator.util.VelocityInitializer;
|
||||
import com.hchyun.generator.util.VelocityUtils;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
/**
|
||||
* 业务 服务层实现
|
||||
|
|
@ -325,6 +326,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||
return true;
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
log.error(e.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import com.hchyun.generator.dao.InterTableDao;
|
|||
import com.hchyun.generator.entity.InterTable;
|
||||
import com.hchyun.generator.service.InterTableService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
/**
|
||||
* 接口信息Service业务层处理
|
||||
|
|
@ -158,6 +159,7 @@ public class InterTableServiceImpl implements InterTableService {
|
|||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return new ServerResult<Integer>(false, ReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
|
|
@ -293,6 +295,7 @@ public class InterTableServiceImpl implements InterTableService {
|
|||
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return new ServerResult<byte[]>(false, "代码生成失败!");
|
||||
}
|
||||
}
|
||||
|
|
@ -330,6 +333,7 @@ public class InterTableServiceImpl implements InterTableService {
|
|||
return new ServerResult<byte[]>(true, outputStream.toByteArray());
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return new ServerResult<byte[]>(false, "代码生成失败!");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -28,6 +29,11 @@ public class QueryServiceImpl implements QueryService {
|
|||
@Autowired
|
||||
private UniQueryDao uniQueryDao;
|
||||
|
||||
/**
|
||||
* 查询万能查询的基本信息和条件信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ServerResult<UniQuery> selectQueryById(Long id) {
|
||||
try {
|
||||
|
|
@ -44,21 +50,30 @@ public class QueryServiceImpl implements QueryService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新万能查询基本信息和条件
|
||||
* @param uniQuery
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public ServerResult updateQueryInfo(UniQuery uniQuery) {
|
||||
try {
|
||||
Integer uqrenewal = uniQueryDao.updateUniQuery(uniQuery);
|
||||
if (uqrenewal > 0) {
|
||||
queryDao.deleteUniCon(uniQuery.getId());
|
||||
Integer ucrenewal = queryDao.insertUniCon(uniQuery.getUniCons());
|
||||
if (ucrenewal>0){
|
||||
return new ServerResult(true);
|
||||
if (uniQuery.getUniCons()!=null){
|
||||
queryDao.deleteUniCon(uniQuery.getId());
|
||||
Integer ucrenewal = queryDao.insertUniCon(uniQuery.getUniCons());
|
||||
if (ucrenewal==0){
|
||||
return new ServerResult(false,"操作失败!");
|
||||
}
|
||||
}
|
||||
return new ServerResult(true);
|
||||
}
|
||||
return new ServerResult(false,"操作失败!");
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
|
||||
}
|
||||
}
|
||||
|
|
@ -66,7 +81,15 @@ public class QueryServiceImpl implements QueryService {
|
|||
@Override
|
||||
public ServerResult<List<Map<String,Object>>> previewQuery(UniQuery uniQuery) {
|
||||
try {
|
||||
String sql = uniQuery.getUqSql();
|
||||
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等特殊字符!");
|
||||
}
|
||||
|
||||
|
||||
List<Map<String,Object>> dataMap = queryDao.UniQuery(uniQuery.getUqSql());
|
||||
|
||||
return new ServerResult<List<Map<String,Object>>>(true,dataMap);
|
||||
}catch (RuntimeException e){
|
||||
logger.error(e.getMessage());
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ import java.util.List;
|
|||
import com.hchyun.common.constant.ReturnConstants;
|
||||
import com.hchyun.common.utils.DateUtils;
|
||||
import com.hchyun.common.utils.SecurityUtils;
|
||||
import com.hchyun.common.utils.DateUtils;
|
||||
import com.hchyun.common.utils.SecurityUtils;
|
||||
import com.hchyun.common.utils.ServerResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -19,6 +17,7 @@ import com.hchyun.test.entity.Results;
|
|||
import com.hchyun.test.dao.StuDao;
|
||||
import com.hchyun.test.entity.Stu;
|
||||
import com.hchyun.test.service.StuService;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
/**
|
||||
* 学生Service业务层处理
|
||||
|
|
@ -98,6 +97,7 @@ public class StuServiceImpl implements StuService {
|
|||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.error(e.getMessage());
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
|
|
@ -126,6 +126,7 @@ public class StuServiceImpl implements StuService {
|
|||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.error(e.getMessage());
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue