diff --git a/hchyun-ui/.env.staging b/hchyun-ui/.env.staging
index 9b11229..488689f 100644
--- a/hchyun-ui/.env.staging
+++ b/hchyun-ui/.env.staging
@@ -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'
diff --git a/hchyun-ui/src/views/tool/query/uniQuery.vue b/hchyun-ui/src/views/tool/query/uniQuery.vue
index 153bc6e..f5a9465 100644
--- a/hchyun-ui/src/views/tool/query/uniQuery.vue
+++ b/hchyun-ui/src/views/tool/query/uniQuery.vue
@@ -112,22 +112,30 @@
-
diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/QueryController.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/QueryController.java
index 8554a00..668ebd2 100644
--- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/QueryController.java
+++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/QueryController.java
@@ -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>> 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);
+ }
+ }
}
diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/UniQueryController.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/UniQueryController.java
index f8774e6..6ae277b 100644
--- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/UniQueryController.java
+++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/UniQueryController.java
@@ -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
diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/UniQuery.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/UniQuery.java
index 4030312..acf9f64 100644
--- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/UniQuery.java
+++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/UniQuery.java
@@ -37,6 +37,26 @@ public class UniQuery extends BaseEntity {
private List 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 getUniCons() {
return uniCons;
}
diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/GenTableServiceImpl.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/GenTableServiceImpl.java
index 16aac60..550cd34 100644
--- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/GenTableServiceImpl.java
+++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/GenTableServiceImpl.java
@@ -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;
}
diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/InterTableServiceImpl.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/InterTableServiceImpl.java
index c538159..28dafc4 100644
--- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/InterTableServiceImpl.java
+++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/InterTableServiceImpl.java
@@ -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(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(false, "代码生成失败!");
}
}
@@ -330,6 +333,7 @@ public class InterTableServiceImpl implements InterTableService {
return new ServerResult(true, outputStream.toByteArray());
} catch (RuntimeException e) {
logger.error(e.getMessage());
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return new ServerResult(false, "代码生成失败!");
}
}
diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/QueryServiceImpl.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/QueryServiceImpl.java
index 482787d..5b3071f 100644
--- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/QueryServiceImpl.java
+++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/QueryServiceImpl.java
@@ -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 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(false, ReturnConstants.SYS_FAILL);
}
}
@@ -66,7 +81,15 @@ public class QueryServiceImpl implements QueryService {
@Override
public ServerResult>> 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>>(false,"sql语句含有insert,delete,update,drop,database,view,alter等特殊字符!");
+ }
+
+
List