|
@@ -15,51 +15,71 @@
|
|
|
*/
|
|
|
package com.baomidou.mybatisplus.core.conditions.where;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.TableInfoHelper;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.support.Property;
|
|
|
-
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.AbstractWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.TableInfoHelper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.sql.SqlUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.support.Property;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 查询条件封装
|
|
|
+ * Lambda 语法使用 Wrapper
|
|
|
* </p>
|
|
|
*
|
|
|
* @author hubin miemie HCL
|
|
|
* @since 2017-05-26
|
|
|
*/
|
|
|
-public class LamEntityWrapper<T> extends AbstractEntityWrapper<T, Property<T, ?>, LamEntityWrapper<T>> {
|
|
|
+public class LambdaEntityWrapper<T> extends AbstractWrapper<T, Property<T, ?>, LambdaEntityWrapper<T>> {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * SQL 查询字段内容,例如:id,name,age
|
|
|
+ */
|
|
|
+ private String sqlSelect;
|
|
|
|
|
|
- public LamEntityWrapper() {
|
|
|
- initNeed();
|
|
|
+
|
|
|
+ public LambdaEntityWrapper() {
|
|
|
+ this(null, null);
|
|
|
}
|
|
|
|
|
|
- public LamEntityWrapper(T entity) {
|
|
|
- this.entity = entity;
|
|
|
- initNeed();
|
|
|
+ public LambdaEntityWrapper(T entity) {
|
|
|
+ this(entity, null);
|
|
|
}
|
|
|
|
|
|
- public LamEntityWrapper(T entity, String sqlSelect) {
|
|
|
+ public LambdaEntityWrapper(T entity, String sqlSelect) {
|
|
|
this.entity = entity;
|
|
|
this.sqlSelect = sqlSelect;
|
|
|
- initNeed();
|
|
|
+ this.initNeed();
|
|
|
}
|
|
|
|
|
|
- private LamEntityWrapper(T entity, String sqlSelect, AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
|
|
|
+ private LambdaEntityWrapper(T entity, String sqlSelect, AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
|
|
|
this.entity = entity;
|
|
|
this.sqlSelect = sqlSelect;
|
|
|
this.paramNameSeq = paramNameSeq;
|
|
|
this.paramNameValuePairs = paramNameValuePairs;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String getSqlSelect() {
|
|
|
+ return StringUtils.isEmpty(sqlSelect) ? null : SqlUtils.stripSqlInjection(sqlSelect);
|
|
|
+ }
|
|
|
+
|
|
|
+ public LambdaEntityWrapper<T> setSqlSelect(String sqlSelect) {
|
|
|
+ if (StringUtils.isNotEmpty(sqlSelect)) {
|
|
|
+ this.sqlSelect = sqlSelect;
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public String columnToString(Property<T, ?> column) {
|
|
|
return TableInfoHelper.toColumn(column);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- protected LamEntityWrapper<T> instance(AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
|
|
|
- return new LamEntityWrapper<>(entity, sqlSelect, paramNameSeq, paramNameValuePairs);
|
|
|
+ protected LambdaEntityWrapper<T> instance(AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
|
|
|
+ return new LambdaEntityWrapper<>(entity, sqlSelect, paramNameSeq, paramNameValuePairs);
|
|
|
}
|
|
|
}
|