diff --git a/db/pig_codegen.sql b/db/pig_codegen.sql
index eecbcdf3..e88e63d3 100644
--- a/db/pig_codegen.sql
+++ b/db/pig_codegen.sql
@@ -7,24 +7,6 @@ SET FOREIGN_KEY_CHECKS = 0;
USE `pig_codegen`;
-/*
- *
- * * Copyright (c) 2019-2020, 冷冷 (wangiegie@gmail.com).
- * *
- * * Licensed under the GNU Lesser General Public License 3.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * https://www.gnu.org/licenses/lgpl.html
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- *
- */
-
-- ----------------------------
-- Table structure for gen_datasource_conf
-- ----------------------------
@@ -38,7 +20,6 @@ CREATE TABLE `gen_datasource_conf` (
`create_date` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_date` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新',
`del_flag` char(1) DEFAULT '0',
- `tenant_id` int(11) DEFAULT NULL COMMENT '租户ID',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COMMENT='数据源表';
@@ -53,7 +34,6 @@ CREATE TABLE `gen_form_conf` (
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`del_flag` char(1) DEFAULT '0',
- `tenant_id` int(11) DEFAULT NULL COMMENT '所属租户',
PRIMARY KEY (`id`) USING BTREE,
KEY `table_name` (`table_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='表单配置';
diff --git a/db/pig_config.sql b/db/pig_config.sql
index 3f130b1f..e09dea2b 100644
--- a/db/pig_config.sql
+++ b/db/pig_config.sql
@@ -189,24 +189,6 @@ CREATE TABLE `tenant_capacity` (
UNIQUE KEY `uk_tenant_id` (`tenant_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='租户容量信息表';
-/*
- *
- * * Copyright (c) 2019-2020, 冷冷 (wangiegie@gmail.com).
- * *
- * * Licensed under the GNU Lesser General Public License 3.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * https://www.gnu.org/licenses/lgpl.html
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- *
- */
-
-- ----------------------------
-- Table structure for tenant_info
-- ----------------------------
diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenDatasourceConf.java b/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenDatasourceConf.java
index 33808d4c..0b3a9e46 100755
--- a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenDatasourceConf.java
+++ b/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenDatasourceConf.java
@@ -72,9 +72,4 @@ public class GenDatasourceConf extends Model {
*/
@TableLogic
private String delFlag;
- /**
- * 租户ID
- */
- private Integer tenantId;
-
}
diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenFormConf.java b/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenFormConf.java
index 5687d5c9..3ebceac7 100755
--- a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenFormConf.java
+++ b/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenFormConf.java
@@ -72,9 +72,4 @@ public class GenFormConf extends Model {
*/
@ApiModelProperty(value = "删除标记")
private String delFlag;
- /**
- * 所属租户
- */
- @ApiModelProperty(value = "所属租户", hidden = true)
- private Integer tenantId;
}
diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenDatasourceConfServiceImpl.java b/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenDatasourceConfServiceImpl.java
index a259938c..82e8e0b6 100755
--- a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenDatasourceConfServiceImpl.java
+++ b/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenDatasourceConfServiceImpl.java
@@ -25,6 +25,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pig.codegen.service.GenDatasourceConfService;
import com.pig4cloud.pig.codegen.entity.GenDatasourceConf;
import com.pig4cloud.pig.codegen.mapper.GenDatasourceConfMapper;
+import com.pig4cloud.pig.common.datasource.support.DataSourceConstants;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jasypt.encryption.StringEncryptor;
@@ -123,6 +124,7 @@ public class GenDatasourceConfServiceImpl extends ServiceImpl hiddenColumns = config.getList("hiddenColumn");
+
//列信息
List columnList = new ArrayList<>();
for (Map column : columns) {
@@ -132,12 +131,7 @@ public class CodeGenUtils {
columnEntity.setExtra(column.get("extra"));
columnEntity.setNullable("NO".equals(column.get("isNullable")));
columnEntity.setColumnType(column.get("columnType"));
- //隐藏不需要的在接口文档中展示的字段
- if (hiddenColumns.contains(column.get("columnName"))) {
- columnEntity.setHidden(Boolean.TRUE);
- } else {
- columnEntity.setHidden(Boolean.FALSE);
- }
+ columnEntity.setHidden(Boolean.FALSE);
//列名转换成Java属性名
String attrName = columnToJava(columnEntity.getColumnName());
columnEntity.setCaseAttrName(attrName);
diff --git a/pig-codegen/src/main/resources/generator.properties b/pig-codegen/src/main/resources/generator.properties
index 163624cd..45d0f5a3 100755
--- a/pig-codegen/src/main/resources/generator.properties
+++ b/pig-codegen/src/main/resources/generator.properties
@@ -26,7 +26,7 @@ moduleName=generator
author=pig code generator
#\u8868\u524D\u7F00(\u7C7B\u540D\u4E0D\u4F1A\u5305\u542B\u8868\u524D\u7F00)
-tablePrefix=tb_
+tablePrefix=table_
#\u7C7B\u578B\u8F6C\u6362\uFF0C\u914D\u7F6E\u4FE1\u606F
tinyint=Integer
@@ -50,6 +50,3 @@ longtext=String
date=LocalDateTime
datetime=LocalDateTime
timestamp=LocalDateTime
-
-# hidden columns in Swagger Models
-hiddenColumn=tenant_id
diff --git a/pig-codegen/src/main/resources/mapper/GenFormConfMapper.xml b/pig-codegen/src/main/resources/mapper/GenFormConfMapper.xml
index 0a7f7d96..941f155a 100755
--- a/pig-codegen/src/main/resources/mapper/GenFormConfMapper.xml
+++ b/pig-codegen/src/main/resources/mapper/GenFormConfMapper.xml
@@ -29,6 +29,5 @@
-
diff --git a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/mybatis/SqlFilterArgumentResolver.java b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/mybatis/SqlFilterArgumentResolver.java
index ec13add4..99f22487 100644
--- a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/mybatis/SqlFilterArgumentResolver.java
+++ b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/mybatis/SqlFilterArgumentResolver.java
@@ -18,11 +18,9 @@
package com.pig4cloud.pig.common.core.mybatis;
-import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.pig4cloud.pig.common.core.exception.CheckedException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.MethodParameter;
import org.springframework.web.bind.support.WebDataBinderFactory;
@@ -32,7 +30,11 @@ import org.springframework.web.method.support.ModelAndViewContainer;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import java.util.Optional;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
/**
* @author lengleng
@@ -71,8 +73,8 @@ public class SqlFilterArgumentResolver implements HandlerMethodArgumentResolver
HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
- String ascs = request.getParameter("ascs");
- String descs = request.getParameter("descs");
+ String[] ascs = request.getParameterValues("ascs");
+ String[] descs = request.getParameterValues("descs");
String current = request.getParameter("current");
String size = request.getParameter("size");
@@ -85,52 +87,31 @@ public class SqlFilterArgumentResolver implements HandlerMethodArgumentResolver
page.setSize(Long.parseLong(size));
}
- // 过滤 asc 条件
- List ascList = sqlInject(ascs, "asc");
- // 过滤 desc条件
- List descList = sqlInject(descs, "desc");
-
List orderItemList = new ArrayList<>();
- if (CollUtil.isNotEmpty(ascList)) {
- orderItemList.addAll(ascList);
- }
+ Optional.ofNullable(ascs).ifPresent(s -> orderItemList.addAll(Arrays.stream(s)
+ .filter(sqlInjectPredicate())
+ .map(OrderItem::asc).collect(Collectors.toList())));
+ Optional.ofNullable(descs).ifPresent(s -> orderItemList.addAll(Arrays.stream(s)
+ .filter(sqlInjectPredicate())
+ .map(OrderItem::desc).collect(Collectors.toList())));
+ page.addOrder(orderItemList);
- if (CollUtil.isNotEmpty(descList)) {
- orderItemList.addAll(descList);
- }
- page.setOrders(orderItemList);
return page;
}
/**
- * SQL注入过滤
+ * 判断用户输入里面有没有关键字
*
- * @param str 待验证的字符串
- * @return 返回标准的order 属性
+ * @return Predicate
*/
- private static List sqlInject(String str, String type) {
- if (StrUtil.isBlank(str)) {
- return null;
- }
- //转换成小写
- String inStr = str.toLowerCase();
-
- //判断是否包含非法字符
- for (String keyword : KEYWORDS) {
- if (inStr.contains(keyword)) {
- log.error("查询包含非法字符 {}", keyword);
- throw new CheckedException(keyword + "包含非法字符");
+ private Predicate sqlInjectPredicate() {
+ return sql -> {
+ for (String keyword : KEYWORDS) {
+ if (StrUtil.containsIgnoreCase(sql, keyword)) {
+ return false;
+ }
}
- }
-
- List orderItemList = new ArrayList<>();
- for (String in : str.split(StrUtil.COMMA)) {
- if ("asc".equals(type)) {
- orderItemList.add(OrderItem.asc(in));
- } else {
- orderItemList.add(OrderItem.desc(in));
- }
- }
- return orderItemList;
+ return true;
+ };
}
}